diff options
author | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-06-28 21:03:38 +0300 |
---|---|---|
committer | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-06-30 22:51:43 +0300 |
commit | a0ba5ba1c3397987be7159c7952dfa38da219ab7 (patch) | |
tree | 88e201855aa040c6468080264815bfa391a152f8 /acceptance_test.go | |
parent | 01be853119e87fe56e25901e0c95d92e869f8d52 (diff) |
Add SSL cert file to access control test
Diffstat (limited to 'acceptance_test.go')
-rw-r--r-- | acceptance_test.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index 06fab950..ad22d9d9 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -672,6 +672,12 @@ func TestWhenLoginCallbackWithCorrectStateWithoutEndpoint(t *testing.T) { func TestAccessControl(t *testing.T) { skipUnlessEnabled(t) + transport := (TestHTTPSClient.Transport).(*http.Transport) + defer func(t time.Duration) { + transport.ResponseHeaderTimeout = t + }(transport.ResponseHeaderTimeout) + transport.ResponseHeaderTimeout = 5 * time.Second + testServer := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/oauth/token": @@ -698,6 +704,16 @@ func TestAccessControl(t *testing.T) { } })) + keyFile, certFile := CreateHTTPSFixtureFiles(t) + cert, err := tls.LoadX509KeyPair(certFile, keyFile) + require.NoError(t, err) + defer os.Remove(keyFile) + defer os.Remove(certFile) + + testServer.TLS = &tls.Config{Certificates: []tls.Certificate{cert}} + testServer.StartTLS() + defer testServer.Close() + cases := []struct { Host string Path string @@ -735,13 +751,10 @@ func TestAccessControl(t *testing.T) { }, } - testServer.Start() - defer testServer.Close() - for _, c := range cases { t.Run(fmt.Sprintf("Access Control Test: %s", c.Description), func(t *testing.T) { - teardown := RunPagesProcessWithAuthServer(t, *pagesBinary, listeners, "", testServer.URL) + teardown := RunPagesProcessWithAuthServerWithSSL(t, *pagesBinary, listeners, "", certFile, testServer.URL) defer teardown() rsp, err := GetRedirectPage(t, httpsListener, c.Host, c.Path) |