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 <vshushlin@gitlab.com>2021-07-15 12:51:10 +0300
committerVladimir Shushlin <vshushlin@gitlab.com>2021-07-15 12:51:10 +0300
commitb72ce71418f5474b1e7dc455052a32b12ae67c39 (patch)
tree6189508dc2760c7ffb1dbe8e1b63650320320d34 /test
parentb66a6ec4d64ddabf71b99e82ceab9049b18099db (diff)
parent4f6452e22c1a375163765dc2fa61f187f7dd8941 (diff)
Merge branch '571-refactoring-acceptnace-part-4' into 'master'
Update redirect tests See merge request gitlab-org/gitlab-pages!522
Diffstat (limited to 'test')
-rw-r--r--test/acceptance/redirects_test.go16
-rw-r--r--test/acceptance/testdata/api_responses.go16
2 files changed, 25 insertions, 7 deletions
diff --git a/test/acceptance/redirects_test.go b/test/acceptance/redirects_test.go
index 7fd7caab..c7feafca 100644
--- a/test/acceptance/redirects_test.go
+++ b/test/acceptance/redirects_test.go
@@ -10,8 +10,10 @@ import (
)
func TestDisabledRedirects(t *testing.T) {
- teardown := RunPagesProcessWithEnvs(t, true, *pagesBinary, supportedListeners(), "", []string{"FF_ENABLE_REDIRECTS=false"})
- defer teardown()
+ RunPagesProcessWithStubGitLabServer(t,
+ withListeners([]ListenSpec{httpListener}),
+ withEnv([]string{"FF_ENABLE_REDIRECTS=false"}),
+ )
// Test that redirects status page is forbidden
rsp, err := GetPageFromListener(t, httpListener, "group.redirects.gitlab-example.com", "/project-redirects/_redirects")
@@ -29,8 +31,9 @@ func TestDisabledRedirects(t *testing.T) {
}
func TestRedirectStatusPage(t *testing.T) {
- teardown := RunPagesProcess(t, *pagesBinary, supportedListeners(), "")
- defer teardown()
+ RunPagesProcessWithStubGitLabServer(t,
+ withListeners([]ListenSpec{httpListener}),
+ )
rsp, err := GetPageFromListener(t, httpListener, "group.redirects.gitlab-example.com", "/project-redirects/_redirects")
require.NoError(t, err)
@@ -44,8 +47,9 @@ func TestRedirectStatusPage(t *testing.T) {
}
func TestRedirect(t *testing.T) {
- teardown := RunPagesProcess(t, *pagesBinary, supportedListeners(), "")
- defer teardown()
+ RunPagesProcessWithStubGitLabServer(t,
+ withListeners([]ListenSpec{httpListener}),
+ )
// Test that serving a file still works with redirects enabled
rsp, err := GetRedirectPage(t, httpListener, "group.redirects.gitlab-example.com", "/project-redirects/index.html")
diff --git a/test/acceptance/testdata/api_responses.go b/test/acceptance/testdata/api_responses.go
index 07349466..227a72fd 100644
--- a/test/acceptance/testdata/api_responses.go
+++ b/test/acceptance/testdata/api_responses.go
@@ -46,6 +46,11 @@ var DomainResponses = map[string]responseFn{
projectID: 1234,
pathOnDisk: "group.acme/with.acme.challenge",
}),
+ "group.redirects.gitlab-example.com": generateVirtualDomainFromDir("group.redirects", "group.redirects.gitlab-example.com", nil),
+ "redirects.custom-domain.com": customDomain(projectConfig{
+ projectID: 1001,
+ pathOnDisk: "group.redirects/custom-domain",
+ }),
// NOTE: before adding more domains here, generate the zip archive by running (per project)
// make zip PROJECT_SUBDIR=group/serving
// make zip PROJECT_SUBDIR=group/project2
@@ -102,7 +107,8 @@ func generateVirtualDomainFromDir(dir, rootDomain string, perPrefixConfig map[st
ProjectID: cfg.projectID,
AccessControl: cfg.accessControl,
HTTPSOnly: cfg.https,
- Prefix: prefix,
+ // gitlab.Resolve logic expects prefix to have ending slash
+ Prefix: ensureEndingSlash(prefix),
Source: api.Source{
Type: "zip",
Path: fmt.Sprintf("file://%s", wd+"/"+dir+project),
@@ -152,3 +158,11 @@ func customDomain(config projectConfig) responseFn {
}
}
}
+
+func ensureEndingSlash(path string) string {
+ if strings.HasSuffix(path, "/") {
+ return path
+ }
+
+ return path + "/"
+}