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-01-09 14:12:31 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2019-01-09 14:12:31 +0300
commit7ebe62f2f3bb886b24adb8513e78682593a752f2 (patch)
tree56a864903971d4f70a2c6c68e41215a5a7d49e4c
parentf65623e115dfe87521e22fe1afdff3b94ae9012e (diff)
Add acceptance test for deeply nested subgroups
-rw-r--r--acceptance_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/acceptance_test.go b/acceptance_test.go
index cf3c7d09..b6a0451c 100644
--- a/acceptance_test.go
+++ b/acceptance_test.go
@@ -10,6 +10,7 @@ import (
"net/http/httptest"
"net/url"
"os"
+ "path"
"testing"
"time"
@@ -148,6 +149,51 @@ func TestKnownHostReturns200(t *testing.T) {
}
}
+func TestNestedSubgroups(t *testing.T) {
+ skipUnlessEnabled(t)
+
+ maxNestedSubgroup := 21
+
+ pagesRoot, err := ioutil.TempDir("", "pages-root")
+ require.NoError(t, err)
+ defer os.RemoveAll(pagesRoot)
+
+ makeProjectIndex := func(subGroupPath string) {
+ projectPath := path.Join(pagesRoot, "nested", subGroupPath, "project", "public")
+ require.NoError(t, os.MkdirAll(projectPath, 0755))
+
+ projectIndex := path.Join(projectPath, "index.html")
+ require.NoError(t, ioutil.WriteFile(projectIndex, []byte("index"), 0644))
+ }
+ makeProjectIndex("")
+
+ paths := []string{""}
+ for i := 1; i < maxNestedSubgroup*2; i++ {
+ subGroupPath := fmt.Sprintf("%ssub%d/", paths[i-1], i)
+ paths = append(paths, subGroupPath)
+
+ makeProjectIndex(subGroupPath)
+ }
+
+ teardown := RunPagesProcess(t, *pagesBinary, listeners, "", "-pages-root", pagesRoot)
+ defer teardown()
+
+ for nestingLevel, path := range paths {
+ t.Run(fmt.Sprintf("nested level %d", nestingLevel), func(t *testing.T) {
+ for _, spec := range listeners {
+ rsp, err := GetPageFromListener(t, spec, "nested.gitlab-example.com", path+"project/")
+
+ require.NoError(t, err)
+ rsp.Body.Close()
+ if nestingLevel <= maxNestedSubgroup {
+ require.Equal(t, http.StatusOK, rsp.StatusCode)
+ } else {
+ require.Equal(t, http.StatusNotFound, rsp.StatusCode)
+ }
+ }
+ })
+ }
+}
func TestCORSWhenDisabled(t *testing.T) {
skipUnlessEnabled(t)
teardown := RunPagesProcess(t, *pagesBinary, listeners, "", "-disable-cross-origin-requests")