Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVladimir Shushlin <v.shushlin@gmail.com>2021-12-06 16:24:20 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2021-12-07 12:07:31 +0300
commit0ab62643e5b61daf82ecf5a2c1ed196796059514 (patch)
tree87c3aad7e854a40b86ca1c0578d20135965cddd4 /test
parentd228c13c76d11091f8514e40940dc7df1b633e5a (diff)
refactor: enable unparam in .golangci.yml
and fix offences
Diffstat (limited to 'test')
-rw-r--r--test/acceptance/auth_test.go26
-rw-r--r--test/acceptance/helpers_test.go12
-rw-r--r--test/acceptance/metrics_test.go3
-rw-r--r--test/acceptance/zip_test.go12
4 files changed, 25 insertions, 28 deletions
diff --git a/test/acceptance/auth_test.go b/test/acceptance/auth_test.go
index 49d2806d..ad5c343a 100644
--- a/test/acceptance/auth_test.go
+++ b/test/acceptance/auth_test.go
@@ -27,7 +27,7 @@ func TestWhenAuthIsEnabledPrivateWillRedirectToAuthorize(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpsListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -63,7 +63,7 @@ func TestWhenAuthDeniedWillCauseUnauthorized(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpsListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -78,7 +78,7 @@ func TestWhenLoginCallbackWithWrongStateShouldFail(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpsListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -100,7 +100,7 @@ func TestWhenLoginCallbackWithUnencryptedCode(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpsListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -133,7 +133,7 @@ func TestAccessControlUnderCustomDomain(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -214,7 +214,7 @@ func TestCustomErrorPageWithAuth(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -323,7 +323,7 @@ func TestAccessControlUnderCustomDomainWithHTTPSProxy(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{proxyListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -390,7 +390,7 @@ func TestAccessControlGroupDomain404RedirectsAuth(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -409,7 +409,7 @@ func TestAccessControlProject404DoesNotRedirect(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{httpListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -568,7 +568,7 @@ func TestHijackedCode(t *testing.T) {
RunPagesProcess(t,
withListeners([]ListenSpec{proxyListener}),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
)
@@ -643,13 +643,13 @@ func getValidCookieAndState(t *testing.T, domain string) (string, string) {
return cookie, state
}
-func defaultAuthConfigWith(t *testing.T, configs ...string) string {
+func defaultAuthConfig(t *testing.T) string {
t.Helper()
- configs = append(configs,
+ configs := []string{
"gitlab-server=https://public-gitlab-auth.com",
"auth-redirect-uri=https://projects.gitlab-example.com/auth",
- )
+ }
configFile := defaultConfigFileWith(t, configs...)
diff --git a/test/acceptance/helpers_test.go b/test/acceptance/helpers_test.go
index 8433646a..ce2d47d3 100644
--- a/test/acceptance/helpers_test.go
+++ b/test/acceptance/helpers_test.go
@@ -245,7 +245,7 @@ func RunPagesProcessWithSSLCertFile(t *testing.T, listeners []ListenSpec, sslCer
RunPagesProcess(t,
withListeners(listeners),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
withEnv([]string{"SSL_CERT_FILE=" + sslCertFile}),
)
@@ -263,7 +263,7 @@ func RunPagesProcessWithSSLCertDir(t *testing.T, listeners []ListenSpec, sslCert
RunPagesProcess(t,
withListeners(listeners),
withArguments([]string{
- "-config=" + defaultAuthConfigWith(t),
+ "-config=" + defaultAuthConfig(t),
}),
withEnv([]string{"SSL_CERT_DIR=" + sslCertDir}),
)
@@ -464,14 +464,14 @@ func NewGitlabDomainsSourceStub(t *testing.T, opts *stubOpts) *httptest.Server {
router.HandleFunc("/api/v4/internal/pages", pagesHandler)
- authHandler := defaultAuthHandler(t, opts)
+ authHandler := defaultAuthHandler(t)
if opts.authHandler != nil {
authHandler = opts.authHandler
}
router.HandleFunc("/oauth/token", authHandler)
- userHandler := defaultUserHandler(t, opts)
+ userHandler := defaultUserHandler(t)
if opts.userHandler != nil {
userHandler = opts.userHandler
}
@@ -549,7 +549,7 @@ func defaultAPIHandler(t *testing.T, opts *stubOpts) http.HandlerFunc {
}
}
-func defaultAuthHandler(t *testing.T, opts *stubOpts) http.HandlerFunc {
+func defaultAuthHandler(t *testing.T) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, "POST", r.Method)
err := json.NewEncoder(w).Encode(struct {
@@ -561,7 +561,7 @@ func defaultAuthHandler(t *testing.T, opts *stubOpts) http.HandlerFunc {
}
}
-func defaultUserHandler(t *testing.T, opts *stubOpts) http.HandlerFunc {
+func defaultUserHandler(t *testing.T) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, "Bearer abc", r.Header.Get("Authorization"))
w.WriteHeader(http.StatusOK)
diff --git a/test/acceptance/metrics_test.go b/test/acceptance/metrics_test.go
index cb4262fb..32a36638 100644
--- a/test/acceptance/metrics_test.go
+++ b/test/acceptance/metrics_test.go
@@ -9,8 +9,7 @@ import (
)
func TestPrometheusMetricsCanBeScraped(t *testing.T) {
- _, cleanup := newZipFileServerURL(t, "../../shared/pages/group/zip.gitlab.io/public.zip")
- defer cleanup()
+ runObjectStorage(t, "../../shared/pages/group/zip.gitlab.io/public.zip")
RunPagesProcess(t,
withExtraArgument("max-conns", "10"),
diff --git a/test/acceptance/zip_test.go b/test/acceptance/zip_test.go
index f7623340..fcaecf25 100644
--- a/test/acceptance/zip_test.go
+++ b/test/acceptance/zip_test.go
@@ -12,8 +12,7 @@ import (
)
func TestZipServing(t *testing.T) {
- _, cleanup := newZipFileServerURL(t, "../../shared/pages/group/zip.gitlab.io/public.zip")
- defer cleanup()
+ runObjectStorage(t, "../../shared/pages/group/zip.gitlab.io/public.zip")
RunPagesProcess(t,
withListeners([]ListenSpec{httpListener}),
@@ -98,8 +97,7 @@ func TestZipServing(t *testing.T) {
}
func TestZipServingCache(t *testing.T) {
- _, cleanup := newZipFileServerURL(t, "../../shared/pages/group/zip.gitlab.io/public.zip")
- t.Cleanup(cleanup)
+ runObjectStorage(t, "../../shared/pages/group/zip.gitlab.io/public.zip")
RunPagesProcess(t,
withListeners([]ListenSpec{httpListener}),
@@ -246,7 +244,7 @@ func TestZipServingConfigShortTimeout(t *testing.T) {
require.Equal(t, http.StatusInternalServerError, response.StatusCode, "should fail to serve")
}
-func newZipFileServerURL(t *testing.T, zipFilePath string) (string, func()) {
+func runObjectStorage(t *testing.T, zipFilePath string) {
t.Helper()
m := http.NewServeMux()
@@ -271,8 +269,8 @@ func newZipFileServerURL(t *testing.T, zipFilePath string) (string, func()) {
// Start the server.
testServer.Start()
- return testServer.URL, func() {
+ t.Cleanup(func() {
// Cleanup.
testServer.Close()
- }
+ })
}