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:
Diffstat (limited to 'test/acceptance/custom_root_folder_test.go')
-rw-r--r--test/acceptance/custom_root_folder_test.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/acceptance/custom_root_folder_test.go b/test/acceptance/custom_root_folder_test.go
new file mode 100644
index 00000000..24ebe2d1
--- /dev/null
+++ b/test/acceptance/custom_root_folder_test.go
@@ -0,0 +1,61 @@
+package acceptance_test
+
+import (
+ "net/http"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "gitlab.com/gitlab-org/gitlab-pages/internal/feature"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers"
+)
+
+func TestCustomRoot(t *testing.T) {
+ t.Setenv(feature.ConfigurableRoot.EnvVariable, "true")
+
+ RunPagesProcess(t)
+
+ tests := []struct {
+ name string
+ requestDomain string
+ requestPath string
+ redirectURL string
+ httpStatus int
+ }{
+ {
+ name: "custom root",
+ requestDomain: "custom-root.gitlab-example.com",
+ httpStatus: http.StatusOK,
+ },
+ {
+ name: "custom root legacy",
+ requestDomain: "custom-root-legacy.gitlab-example.com",
+ httpStatus: http.StatusOK,
+ },
+ {
+ name: "custom root explicitly public",
+ requestDomain: "custom-root-explicit-public.gitlab-example.com",
+ httpStatus: http.StatusOK,
+ },
+ {
+ name: "project does not have pages files inside a subdirectory",
+ requestDomain: "custom-root-no-subdir.gitlab-example.com",
+ httpStatus: http.StatusNotFound,
+ },
+ {
+ name: "used a root dir value that does not exist inside the archive",
+ requestDomain: "custom-root-wrong-dir.gitlab-example.com",
+ httpStatus: http.StatusNotFound,
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ rsp, err := GetRedirectPage(t, httpsListener, test.requestDomain, test.requestPath)
+ require.NoError(t, err)
+ testhelpers.Close(t, rsp.Body)
+
+ require.Equal(t, test.httpStatus, rsp.StatusCode)
+ })
+ }
+}