diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2019-02-25 16:42:35 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-07-06 02:13:51 +0300 |
commit | f204fde955e305122467ed70f38edd342a8776ce (patch) | |
tree | 76c4432ffc99b62287603d6494e5e0b91738fafe /acceptance_test.go | |
parent | 11b5932d1f41d6b9f46331ef97d427948ed00712 (diff) |
Add custom 404 acceptance test
Diffstat (limited to 'acceptance_test.go')
-rw-r--r-- | acceptance_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index 67558964..b8389118 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -197,6 +197,69 @@ func TestNestedSubgroups(t *testing.T) { }) } } + +func TestCustom404(t *testing.T) { + skipUnlessEnabled(t) + teardown := RunPagesProcess(t, *pagesBinary, listeners, "") + defer teardown() + + tests := []struct { + host string + path string + content string + }{ + { + host: "group.404.gitlab-example.com", + path: "project.404/not/existing-file", + content: "Custom 404 project page", + }, + { + host: "group.404.gitlab-example.com", + path: "project.404/", + content: "Custom 404 project page", + }, + { + host: "group.404.gitlab-example.com", + path: "not/existing-file", + content: "Custom 404 group page", + }, + { + host: "group.404.gitlab-example.com", + path: "not-existing-file", + content: "Custom 404 group page", + }, + { + host: "group.404.gitlab-example.com", + content: "Custom 404 group page", + }, + { + host: "domain.404.com", + content: "Custom 404 group page", + }, + { + host: "group.404.gitlab-example.com", + path: "project.no.404/not/existing-file", + content: "The page you're looking for could not be found.", + }, + } + + for _, test := range tests { + t.Run(fmt.Sprintf("%s/%s", test.host, test.path), func(t *testing.T) { + for _, spec := range listeners { + rsp, err := GetPageFromListener(t, spec, test.host, test.path) + + require.NoError(t, err) + defer rsp.Body.Close() + assert.Equal(t, http.StatusNotFound, rsp.StatusCode) + + page, err := ioutil.ReadAll(rsp.Body) + require.NoError(t, err) + require.Contains(t, string(page), test.content) + } + }) + } +} + func TestCORSWhenDisabled(t *testing.T) { skipUnlessEnabled(t) teardown := RunPagesProcess(t, *pagesBinary, listeners, "", "-disable-cross-origin-requests") |