diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/acceptance/acme_test.go | 6 | ||||
-rw-r--r-- | test/acceptance/artifacts_test.go | 4 | ||||
-rw-r--r-- | test/acceptance/auth_test.go | 4 | ||||
-rw-r--r-- | test/acceptance/helpers_test.go | 5 | ||||
-rw-r--r-- | test/acceptance/metrics_test.go | 4 | ||||
-rw-r--r-- | test/acceptance/proxyv2_test.go | 4 | ||||
-rw-r--r-- | test/acceptance/redirects_test.go | 4 | ||||
-rw-r--r-- | test/acceptance/rewrites_test.go | 4 | ||||
-rw-r--r-- | test/acceptance/serving_test.go | 10 | ||||
-rw-r--r-- | test/acceptance/stub_test.go | 14 | ||||
-rw-r--r-- | test/acceptance/zip_test.go | 6 |
11 files changed, 32 insertions, 33 deletions
diff --git a/test/acceptance/acme_test.go b/test/acceptance/acme_test.go index 1d6ea4ec..f0259e05 100644 --- a/test/acceptance/acme_test.go +++ b/test/acceptance/acme_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "net/url" "testing" @@ -44,7 +44,7 @@ func TestAcmeChallengesWhenItIsNotConfigured(t *testing.T) { defer rsp.Body.Close() require.NoError(t, err) require.Equal(t, test.expectedStatus, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(body), test.expectedContent) @@ -85,7 +85,7 @@ func TestAcmeChallengesWhenItIsConfigured(t *testing.T) { defer rsp.Body.Close() require.NoError(t, err) require.Equal(t, test.expectedStatus, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(body), test.expectedContent) diff --git a/test/acceptance/artifacts_test.go b/test/acceptance/artifacts_test.go index 01bb1f5c..dddfeb67 100644 --- a/test/acceptance/artifacts_test.go +++ b/test/acceptance/artifacts_test.go @@ -3,7 +3,7 @@ package acceptance_test import ( "crypto/tls" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" @@ -142,7 +142,7 @@ func TestArtifactProxyRequest(t *testing.T) { require.Equal(t, tt.contentType, resp.Header.Get("Content-Type")) if tt.status == http.StatusOK { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Equal(t, tt.content, string(body)) require.Equal(t, tt.length, resp.ContentLength) diff --git a/test/acceptance/auth_test.go b/test/acceptance/auth_test.go index 7ec55d95..3c616f7c 100644 --- a/test/acceptance/auth_test.go +++ b/test/acceptance/auth_test.go @@ -2,7 +2,7 @@ package acceptance_test import ( "fmt" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -278,7 +278,7 @@ func TestCustomErrorPageWithAuth(t *testing.T) { require.Equal(t, http.StatusNotFound, anotherResp.StatusCode) - page, err := ioutil.ReadAll(anotherResp.Body) + page, err := io.ReadAll(anotherResp.Body) require.NoError(t, err) require.Contains(t, string(page), tt.expectedErrorPage) }) diff --git a/test/acceptance/helpers_test.go b/test/acceptance/helpers_test.go index b8181dca..33a19127 100644 --- a/test/acceptance/helpers_test.go +++ b/test/acceptance/helpers_test.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net" "net/http" "net/http/httptest" @@ -261,7 +260,7 @@ func RunPagesProcessWithSSLCertFile(t *testing.T, listeners []ListenSpec, sslCer func RunPagesProcessWithSSLCertDir(t *testing.T, listeners []ListenSpec, sslCertFile string) { // Create temporary cert dir - sslCertDir, err := ioutil.TempDir("", "pages-test-SSL_CERT_DIR") + sslCertDir, err := os.MkdirTemp("", "pages-test-SSL_CERT_DIR") require.NoError(t, err) // Copy sslCertFile into temp cert dir @@ -621,7 +620,7 @@ func defaultUserHandler(t *testing.T, opts *stubOpts) http.HandlerFunc { func newConfigFile(t *testing.T, configs ...string) string { t.Helper() - f, err := ioutil.TempFile(os.TempDir(), "gitlab-pages-config") + f, err := os.CreateTemp(os.TempDir(), "gitlab-pages-config") require.NoError(t, err) defer f.Close() diff --git a/test/acceptance/metrics_test.go b/test/acceptance/metrics_test.go index 0e8237b7..cb4262fb 100644 --- a/test/acceptance/metrics_test.go +++ b/test/acceptance/metrics_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "testing" @@ -28,7 +28,7 @@ func TestPrometheusMetricsCanBeScraped(t *testing.T) { require.NoError(t, err) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Contains(t, string(body), "gitlab_pages_http_in_flight_requests 0") diff --git a/test/acceptance/proxyv2_test.go b/test/acceptance/proxyv2_test.go index 8091e8c6..81a7ff94 100644 --- a/test/acceptance/proxyv2_test.go +++ b/test/acceptance/proxyv2_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "testing" "time" @@ -41,7 +41,7 @@ func TestProxyv2(t *testing.T) { require.Equal(t, tt.expectedStatusCode, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedContent, "content mismatch") diff --git a/test/acceptance/redirects_test.go b/test/acceptance/redirects_test.go index dd1b6891..1ce7a0be 100644 --- a/test/acceptance/redirects_test.go +++ b/test/acceptance/redirects_test.go @@ -2,7 +2,7 @@ package acceptance_test import ( "fmt" - "io/ioutil" + "io" "net/http" "testing" @@ -41,7 +41,7 @@ func TestRedirectStatusPage(t *testing.T) { rsp, err := GetPageFromListener(t, httpListener, "group.redirects.gitlab-example.com", "/project-redirects/_redirects") require.NoError(t, err) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) defer rsp.Body.Close() diff --git a/test/acceptance/rewrites_test.go b/test/acceptance/rewrites_test.go index a446a8cd..5ac16070 100644 --- a/test/acceptance/rewrites_test.go +++ b/test/acceptance/rewrites_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "testing" @@ -49,7 +49,7 @@ func TestRewrites(t *testing.T) { require.NoError(t, err) defer rsp.Body.Close() - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedBody) diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index d401f417..c6a7d3ef 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -2,7 +2,7 @@ package acceptance_test import ( "fmt" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -40,7 +40,7 @@ func TestGroupDomainReturns200(t *testing.T) { defer rsp.Body.Close() require.Equal(t, http.StatusOK, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Equal(t, string(body), "OK\n") @@ -94,7 +94,7 @@ func TestKnownHostReturns200(t *testing.T) { require.NoError(t, err) require.Equal(t, http.StatusOK, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Equal(t, tt.content, string(body)) @@ -156,7 +156,7 @@ func TestCustom404(t *testing.T) { defer rsp.Body.Close() require.Equal(t, http.StatusNotFound, rsp.StatusCode) - page, err := ioutil.ReadAll(rsp.Body) + page, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(page), test.content) } @@ -409,7 +409,7 @@ func TestDomainResolverError(t *testing.T) { require.Equal(t, http.StatusBadGateway, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), "Something went wrong (502)", "content mismatch") diff --git a/test/acceptance/stub_test.go b/test/acceptance/stub_test.go index 10bd3cf6..7fc733a1 100644 --- a/test/acceptance/stub_test.go +++ b/test/acceptance/stub_test.go @@ -2,9 +2,9 @@ package acceptance_test import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" + "os" "regexp" "testing" "time" @@ -110,18 +110,18 @@ func apiHandler(t *testing.T) http.HandlerFunc { func CreateHTTPSFixtureFiles(t *testing.T) (key string, cert string) { t.Helper() - keyfile, err := ioutil.TempFile("", "https-fixture") + keyfile, err := os.CreateTemp("", "https-fixture") require.NoError(t, err) key = keyfile.Name() keyfile.Close() - certfile, err := ioutil.TempFile("", "https-fixture") + certfile, err := os.CreateTemp("", "https-fixture") require.NoError(t, err) cert = certfile.Name() certfile.Close() - require.NoError(t, ioutil.WriteFile(key, []byte(fixture.Key), 0644)) - require.NoError(t, ioutil.WriteFile(cert, []byte(fixture.Certificate), 0644)) + require.NoError(t, os.WriteFile(key, []byte(fixture.Key), 0644)) + require.NoError(t, os.WriteFile(cert, []byte(fixture.Certificate), 0644)) return keyfile.Name(), certfile.Name() } @@ -129,11 +129,11 @@ func CreateHTTPSFixtureFiles(t *testing.T) (key string, cert string) { func CreateGitLabAPISecretKeyFixtureFile(t *testing.T) (filepath string) { t.Helper() - secretfile, err := ioutil.TempFile("", "gitlab-api-secret") + secretfile, err := os.CreateTemp("", "gitlab-api-secret") require.NoError(t, err) secretfile.Close() - require.NoError(t, ioutil.WriteFile(secretfile.Name(), []byte(fixture.GitLabAPISecretKey), 0644)) + require.NoError(t, os.WriteFile(secretfile.Name(), []byte(fixture.GitLabAPISecretKey), 0644)) return secretfile.Name() } diff --git a/test/acceptance/zip_test.go b/test/acceptance/zip_test.go index 3bdd1c49..97a35e2b 100644 --- a/test/acceptance/zip_test.go +++ b/test/acceptance/zip_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net" "net/http" "net/http/httptest" @@ -88,7 +88,7 @@ func TestZipServing(t *testing.T) { require.Equal(t, tt.expectedStatusCode, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedContent, "content mismatch") @@ -171,7 +171,7 @@ func TestZipServingFromDisk(t *testing.T) { require.Equal(t, tt.expectedStatusCode, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedContent, "content mismatch") |