diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-06-07 04:15:05 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-06-09 06:53:23 +0300 |
commit | 9d6dcf0c3cdf1085085a194d0c9061c9ff65de23 (patch) | |
tree | 9a9bce0d5981c8a9ffece0f3ee0cd087f01beba9 /test | |
parent | 74b7f9ddd13ac7d86842d1971f4ed18f5a06c4e7 (diff) |
Add more domains
Diffstat (limited to 'test')
-rw-r--r-- | test/acceptance/serving_test.go | 16 | ||||
-rw-r--r-- | test/acceptance/testdata/api_responses.go | 25 |
2 files changed, 36 insertions, 5 deletions
diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index 0e516618..9c95f1e0 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -15,7 +15,8 @@ import ( func TestUnknownHostReturnsNotFound(t *testing.T) { skipUnlessEnabled(t) - teardown := RunPagesProcess(t, *pagesBinary, supportedListeners(), "") + + _, teardown := RunPagesProcessWithStubGitLabServer(t, true, *pagesBinary, supportedListeners(), []string{}) defer teardown() for _, spec := range supportedListeners() { @@ -30,7 +31,7 @@ func TestUnknownHostReturnsNotFound(t *testing.T) { func TestUnknownProjectReturnsNotFound(t *testing.T) { skipUnlessEnabled(t) - _, teardown := RunPagesProcessWithStubGitLabServer(t, true, *pagesBinary, supportedListeners(), []string{}) + _, teardown := RunPagesProcessWithStubGitLabServer(t, true, *pagesBinary, []ListenSpec{httpListener}, []string{}) defer teardown() rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "/nonexistent/") @@ -117,6 +118,7 @@ func TestKnownHostReturns200(t *testing.T) { } } +// TODO: remove along with https://gitlab.com/gitlab-org/gitlab-pages/-/issues/382 func TestNestedSubgroups(t *testing.T) { skipUnlessEnabled(t) @@ -142,7 +144,7 @@ func TestNestedSubgroups(t *testing.T) { makeProjectIndex(subGroupPath) } - // TODO: what + teardown := RunPagesProcess(t, *pagesBinary, supportedListeners(), "", "-pages-root", pagesRoot) defer teardown() @@ -198,6 +200,7 @@ func TestCustom404(t *testing.T) { content: "Custom 404 group page", }, { + // TODO: custom domains host: "domain.404.com", content: "Custom domain.404 page", }, @@ -345,7 +348,7 @@ func TestHttpsOnlyGroupEnabled(t *testing.T) { teardown := RunPagesProcess(t, *pagesBinary, supportedListeners(), "") defer teardown() - // TODO: what + // TODO: support https too rsp, err := GetRedirectPage(t, httpListener, "group.https-only.gitlab-example.com", "project1/") require.NoError(t, err) defer rsp.Body.Close() @@ -355,7 +358,7 @@ func TestHttpsOnlyGroupEnabled(t *testing.T) { func TestHttpsOnlyGroupDisabled(t *testing.T) { skipUnlessEnabled(t) - // TODO: what + // TODO: support https too teardown := RunPagesProcess(t, *pagesBinary, supportedListeners(), "") defer teardown() @@ -372,6 +375,7 @@ func TestHttpsOnlyProjectEnabled(t *testing.T) { defer teardown() // TODO: how to do custom domains :thinking: + // TODO: support https too rsp, err := GetRedirectPage(t, httpListener, "test.my-domain.com", "/index.html") require.NoError(t, err) defer rsp.Body.Close() @@ -385,6 +389,7 @@ func TestHttpsOnlyProjectDisabled(t *testing.T) { defer teardown() // TODO: how to do custom domains :thinking: + // TODO: support https too rsp, err := GetPageFromListener(t, httpListener, "test2.my-domain.com", "/") require.NoError(t, err) defer rsp.Body.Close() @@ -398,6 +403,7 @@ func TestHttpsOnlyDomainDisabled(t *testing.T) { defer teardown() // TODO: how to do custom domains :thinking: + // TODO: support https too rsp, err := GetPageFromListener(t, httpListener, "no.cert.com", "/") require.NoError(t, err) defer rsp.Body.Close() diff --git a/test/acceptance/testdata/api_responses.go b/test/acceptance/testdata/api_responses.go index 025ddf97..e7a5a93e 100644 --- a/test/acceptance/testdata/api_responses.go +++ b/test/acceptance/testdata/api_responses.go @@ -23,6 +23,8 @@ var DomainResponses = map[string]responseFn{ // test assume the working dir is inside shared/pages/ "group.gitlab-example.com": GenerateVirtualDomainFromDir("group", "group.gitlab-example.com"), "CapitalGroup.gitlab-example.com": GenerateVirtualDomainFromDir("CapitalGroup", "CapitalGroup.gitlab-example.com"), + "group.404.gitlab-example.com": GenerateVirtualDomainFromDir("group.404", "group.404.gitlab-example.com"), + "domain.404.com": domain404, // 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 @@ -157,3 +159,26 @@ func GenerateVirtualDomainFromDir(dir, rootDomain string) responseFn { } } } + +// domain404 hardcoding for now, will implement a better solution in a follow up MR +// TODO: custom domains +func domain404(t *testing.T, wd string) api.VirtualDomain { + t.Helper() + + return api.VirtualDomain{ + Certificate: "", + Key: "", + LookupPaths: []api.LookupPath{ + { + ProjectID: 123, + AccessControl: false, + HTTPSOnly: false, + Prefix: "/", + Source: api.Source{ + Type: "zip", + Path: fmt.Sprintf("file://%s/group.404/domain.404/public.zip", wd), + }, + }, + }, + } +} |