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
diff options
context:
space:
mode:
-rw-r--r--shared/pages/group.redirects/custom-domain/public.zipbin0 -> 535 bytes
-rw-r--r--shared/pages/group.redirects/group.redirects.gitlab-example.com/public.zipbin0 -> 535 bytes
-rw-r--r--shared/pages/group.redirects/project-redirects/public.zipbin0 -> 1223 bytes
-rw-r--r--test/acceptance/redirects_test.go16
-rw-r--r--test/acceptance/testdata/api_responses.go16
5 files changed, 25 insertions, 7 deletions
diff --git a/shared/pages/group.redirects/custom-domain/public.zip b/shared/pages/group.redirects/custom-domain/public.zip
new file mode 100644
index 00000000..fb4c60e8
--- /dev/null
+++ b/shared/pages/group.redirects/custom-domain/public.zip
Binary files differ
diff --git a/shared/pages/group.redirects/group.redirects.gitlab-example.com/public.zip b/shared/pages/group.redirects/group.redirects.gitlab-example.com/public.zip
new file mode 100644
index 00000000..fb4c60e8
--- /dev/null
+++ b/shared/pages/group.redirects/group.redirects.gitlab-example.com/public.zip
Binary files differ
diff --git a/shared/pages/group.redirects/project-redirects/public.zip b/shared/pages/group.redirects/project-redirects/public.zip
new file mode 100644
index 00000000..c6421223
--- /dev/null
+++ b/shared/pages/group.redirects/project-redirects/public.zip
Binary files differ
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 + "/"
+}