diff options
Diffstat (limited to 'test/acceptance')
-rw-r--r-- | test/acceptance/artifacts_test.go | 1 | ||||
-rw-r--r-- | test/acceptance/auth_test.go | 7 | ||||
-rw-r--r-- | test/acceptance/metrics_test.go | 1 | ||||
-rw-r--r-- | test/acceptance/serving_test.go | 3 | ||||
-rw-r--r-- | test/acceptance/unknown_http_method_test.go | 1 |
5 files changed, 12 insertions, 1 deletions
diff --git a/test/acceptance/artifacts_test.go b/test/acceptance/artifacts_test.go index 60b18ae3..2b1976a8 100644 --- a/test/acceptance/artifacts_test.go +++ b/test/acceptance/artifacts_test.go @@ -280,6 +280,7 @@ func TestPrivateArtifactProxyRequest(t *testing.T) { // Request auth callback in project domain authrsp, err = GetRedirectPageWithCookie(t, httpsListener, url.Host, url.Path+"?"+url.RawQuery, cookie) require.NoError(t, err) + defer authrsp.Body.Close() // server returns the ticket, user will be redirected to the project page require.Equal(t, http.StatusFound, authrsp.StatusCode) diff --git a/test/acceptance/auth_test.go b/test/acceptance/auth_test.go index d18c2d77..7ec55d95 100644 --- a/test/acceptance/auth_test.go +++ b/test/acceptance/auth_test.go @@ -37,6 +37,7 @@ func TestWhenAuthIsEnabledPrivateWillRedirectToAuthorize(t *testing.T) { require.NoError(t, err) rsp, err = GetRedirectPage(t, httpsListener, url.Host, url.Path+"?"+url.RawQuery) require.NoError(t, err) + defer rsp.Body.Close() require.Equal(t, http.StatusFound, rsp.StatusCode) require.Equal(t, 1, len(rsp.Header["Location"])) @@ -174,6 +175,7 @@ func TestAccessControlUnderCustomDomain(t *testing.T) { // Fetch page in custom domain authrsp, err = GetRedirectPageWithCookie(t, httpListener, tt.domain, tt.path, cookie) require.NoError(t, err) + defer authrsp.Body.Close() require.Equal(t, http.StatusOK, authrsp.StatusCode) }) } @@ -272,6 +274,7 @@ func TestCustomErrorPageWithAuth(t *testing.T) { // Fetch page in custom domain anotherResp, err := GetRedirectPageWithCookie(t, httpListener, tt.domain, tt.path, groupCookie) require.NoError(t, err) + defer anotherResp.Body.Close() require.Equal(t, http.StatusNotFound, anotherResp.StatusCode) @@ -340,6 +343,7 @@ func TestAccessControlUnderCustomDomainWithHTTPSProxy(t *testing.T) { authrsp, err = GetProxyRedirectPageWithCookie(t, proxyListener, "private.domain.com", "/", cookie, true) require.NoError(t, err) + defer authrsp.Body.Close() require.Equal(t, http.StatusOK, authrsp.StatusCode) } @@ -475,6 +479,7 @@ func testAccessControl(t *testing.T, runPages runPagesFunc) { // Request auth callback in project domain authrsp2, err := GetRedirectPageWithCookie(t, httpsListener, authLoc.Host, authLoc.Path+"?"+authLoc.RawQuery, cookie) require.NoError(t, err) + defer authrsp2.Body.Close() // server returns the ticket, user will be redirected to the project page require.Equal(t, http.StatusFound, authrsp2.StatusCode) @@ -558,7 +563,7 @@ func TestHijackedCode(t *testing.T) { impersonatingRes, err := GetProxyRedirectPageWithCookie(t, proxyListener, targetDomain, "/auth?code="+hijackedCode+"&state="+attackerState, attackerCookie, true) require.NoError(t, err) - defer authrsp.Body.Close() + defer impersonatingRes.Body.Close() require.Equal(t, impersonatingRes.StatusCode, http.StatusInternalServerError, "should fail to decode code") } diff --git a/test/acceptance/metrics_test.go b/test/acceptance/metrics_test.go index 37a3c2b9..ab220c51 100644 --- a/test/acceptance/metrics_test.go +++ b/test/acceptance/metrics_test.go @@ -21,6 +21,7 @@ func TestPrometheusMetricsCanBeScraped(t *testing.T) { res, err := GetPageFromListener(t, httpListener, "zip.gitlab.io", "/symlink.html") require.NoError(t, err) + defer res.Body.Close() require.Equal(t, http.StatusOK, res.StatusCode) resp, err := http.Get("http://127.0.0.1:42345/metrics") diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index a4f3085b..c42866ee 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -217,6 +217,7 @@ func TestCORSWhenDisabled(t *testing.T) { for _, spec := range supportedListeners() { for _, method := range []string{http.MethodGet, http.MethodHead, http.MethodOptions} { rsp := doCrossOriginRequest(t, spec, method, method, spec.URL("project/")) + defer rsp.Body.Close() require.Equal(t, http.StatusOK, rsp.StatusCode) require.Equal(t, "", rsp.Header.Get("Access-Control-Allow-Origin")) @@ -264,6 +265,7 @@ func TestCORSAllowsMethod(t *testing.T) { t.Run(tt.name, func(t *testing.T) { for _, spec := range supportedListeners() { rsp := doCrossOriginRequest(t, spec, tt.method, tt.method, spec.URL("project/")) + defer rsp.Body.Close() require.Equal(t, tt.expectedStatus, rsp.StatusCode) require.Equal(t, tt.expectedOrigin, rsp.Header.Get("Access-Control-Allow-Origin")) @@ -281,6 +283,7 @@ func TestCustomHeaders(t *testing.T) { for _, spec := range supportedListeners() { rsp, err := GetPageFromListener(t, spec, "group.gitlab-example.com:", "project/") require.NoError(t, err) + defer rsp.Body.Close() require.Equal(t, http.StatusOK, rsp.StatusCode) require.Equal(t, "Testing1", rsp.Header.Get("X-Test1")) require.Equal(t, "Testing2", rsp.Header.Get("X-Test2")) diff --git a/test/acceptance/unknown_http_method_test.go b/test/acceptance/unknown_http_method_test.go index 87422292..dfe9c82f 100644 --- a/test/acceptance/unknown_http_method_test.go +++ b/test/acceptance/unknown_http_method_test.go @@ -18,6 +18,7 @@ func TestUnknownHTTPMethod(t *testing.T) { resp, err := DoPagesRequest(t, httpListener, req) require.NoError(t, err) + defer resp.Body.Close() require.Equal(t, http.StatusMethodNotAllowed, resp.StatusCode) } |