From aff94b7e9ff609f303e9ed6631118a57b8199094 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 23 May 2020 19:46:46 -0400 Subject: [PATCH 1/3] tests: fix TestProxyURLsError error match for go-1.14 --- options_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/options_test.go b/options_test.go index 377902bfb..e1017eb12 100644 --- a/options_test.go +++ b/options_test.go @@ -118,11 +118,8 @@ func TestProxyURLsError(t *testing.T) { o.Upstreams = append(o.Upstreams, "127.0.0.1:8081") err := o.Validate() assert.NotEqual(t, nil, err) - - expected := errorMsg([]string{ - "error parsing upstream: parse 127.0.0.1:8081: " + - "first path segment in URL cannot contain colon"}) - assert.Equal(t, expected, err.Error()) + assert.Contains(t, err.Error(), "error parsing upstream") + assert.Contains(t, err.Error(), "first path segment in URL cannot contain colon") } func TestCompiledRegex(t *testing.T) { From 11814ae11202f13376594bed9ad873f0fb648988 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 23 May 2020 20:20:54 -0400 Subject: [PATCH 2/3] tests: TestLoggingHandler more robust to timing differences --- logging_handler_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/logging_handler_test.go b/logging_handler_test.go index 4381bc15a..ba8a0e31d 100644 --- a/logging_handler_test.go +++ b/logging_handler_test.go @@ -2,21 +2,24 @@ package main import ( "bytes" - "fmt" "net/http" "net/http/httptest" + "regexp" "testing" "time" + + "github.com/stretchr/testify/assert" ) func TestLoggingHandler_ServeHTTP(t *testing.T) { - ts := time.Now() + datestr := time.Now().Format(`02/Jan/2006:15:04`) tests := []struct { Format, - ExpectedLogMessage string + Expected string }{ - {defaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/foo/bar\" HTTP/1.1 \"\" 200 4 0.000\n", ts.Format("02/Jan/2006:15:04:05 -0700"))}, + {defaultRequestLoggingFormat, + `127.0.0.1 - - \[` + datestr + `:\d{2} [+-]\d{4}\] test-server GET - "/foo/bar" HTTP/1.1 "" 200 4 0.\d{3}` + "\n"}, {"{{.RequestMethod}}", "GET\n"}, } @@ -32,16 +35,13 @@ func TestLoggingHandler_ServeHTTP(t *testing.T) { } h := LoggingHandler(buf, http.HandlerFunc(handler), true, true, test.Format) - r, _ := http.NewRequest("GET", "/foo/bar", nil) r.RemoteAddr = "127.0.0.1" r.Host = "test-server" h.ServeHTTP(httptest.NewRecorder(), r) - actual := buf.String() - if actual != test.ExpectedLogMessage { - t.Errorf("Log message was\n%s\ninstead of expected \n%s", actual, test.ExpectedLogMessage) - } + re := regexp.MustCompile(test.Expected) + assert.Regexp(t, re, buf.String()) } } From 192ba81ddfea4d18b584713a57aa24043731b405 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 23 May 2020 19:01:19 -0400 Subject: [PATCH 3/3] use GitHub Actions for CI and remove Travis-CI config --- .github/workflows/main.yml | 43 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 21 ------------------- README.md | 2 -- 3 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..8c2cc13f3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,43 @@ +name: tests + +on: + push: {branches: [master]} + pull_request: {branches: [master]} + +jobs: + test: + runs-on: ubuntu-18.04 + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + imgtag: + - "golang:1.9-stretch" + - "golang:1.10-stretch" + - "golang:1.11-buster" + - "golang:1.12-buster" + - "golang:1.13-buster" + - "golang:1.14-buster" + + container: "${{matrix.imgtag}}" + env: + GOPATH: "${{github.workspace}}/go" + SRCDIR: "go/src/github.com/ploxiln/oauth2_proxy" + steps: + - uses: actions/checkout@v2 + with: + path: ${{env.SRCDIR}} + - name: dependencies + run: | + cd $SRCDIR + wget --no-verbose -O dep https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64 + chmod +x dep + ./dep ensure -v + - name: build + run: | + cd $SRCDIR + go build + - name: test + run: | + cd $SRCDIR + ./test.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64a931a90..000000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -dist: xenial -language: go -go: - - 1.9.x - - 1.10.x - - 1.11.x - - 1.12.x - - 1.13.x -go_import_path: github.com/ploxiln/oauth2_proxy -install: - - wget -O dep https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64 - - chmod +x dep - - ./dep ensure -v - - go build -script: - - ./test.sh -branches: - only: - - master -notifications: - email: false diff --git a/README.md b/README.md index 02da8cc3f..068352618 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ oauth2_proxy A reverse proxy and static file server that provides authentication using Providers (Google, GitHub, and others) to validate accounts by email, domain or group. -[![Build Status](https://secure.travis-ci.org/ploxiln/oauth2_proxy.svg?branch=master)](http://travis-ci.org/ploxiln/oauth2_proxy) - ![Sign In Page](https://cloud.githubusercontent.com/assets/45028/4970624/7feb7dd8-6886-11e4-93e0-c9904af44ea8.png)