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:
authorAlessio Caiazza <acaiazza@gitlab.com>2019-02-25 16:42:35 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-07-06 02:13:51 +0300
commitf204fde955e305122467ed70f38edd342a8776ce (patch)
tree76c4432ffc99b62287603d6494e5e0b91738fafe /acceptance_test.go
parent11b5932d1f41d6b9f46331ef97d427948ed00712 (diff)
Add custom 404 acceptance test
Diffstat (limited to 'acceptance_test.go')
-rw-r--r--acceptance_test.go63
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")