Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add go-1.14 to test matrix #53

Merged
merged 3 commits into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
18 changes: 9 additions & 9 deletions logging_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}

Expand All @@ -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())
}
}
7 changes: 2 additions & 5 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down