diff options
author | Janis Altherr <jaltherr@gitlab.com> | 2023-06-08 09:54:32 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2023-06-08 09:54:32 +0300 |
commit | 3cbfc605d0ede7e0a79d912fac01d610089f7eef (patch) | |
tree | ab4c8aea756d110ec1e676ee6088327809803b2e /test/acceptance | |
parent | 5a6388a4479dcfbd522a55b525127f9096e79cdc (diff) |
Use pages root directory from API
Diffstat (limited to 'test/acceptance')
-rw-r--r-- | test/acceptance/custom_root_folder_test.go | 61 |
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) + }) + } +} |