diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-26 03:08:30 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-08-26 03:08:30 +0300 |
commit | 0ef975db7aaa3595ebf56fde4a91351aa0174f11 (patch) | |
tree | fffa9bffca13d109d8508a3fa57d3171e0332bf3 /test | |
parent | c27027696e0745654d38fac79ab3adff12a8f72e (diff) | |
parent | 33985bb325b4b21c84d47c644c6d4616b9c3e8ed (diff) |
Merge branch 'remove/disk-source' into 'master'
refactor: remove support for disk configuration source
Closes #103, #158, #68, and #382
See merge request gitlab-org/gitlab-pages!541
Diffstat (limited to 'test')
-rw-r--r-- | test/acceptance/config_test.go | 27 | ||||
-rw-r--r-- | test/acceptance/helpers_test.go | 11 | ||||
-rw-r--r-- | test/acceptance/serving_test.go | 85 |
3 files changed, 1 insertions, 122 deletions
diff --git a/test/acceptance/config_test.go b/test/acceptance/config_test.go index 82b7fbb1..07697c48 100644 --- a/test/acceptance/config_test.go +++ b/test/acceptance/config_test.go @@ -5,7 +5,6 @@ import ( "net" "net/http" "testing" - "time" "github.com/stretchr/testify/require" ) @@ -65,29 +64,3 @@ func TestMultipleListenersFromEnvironmentVariables(t *testing.T) { require.Equal(t, http.StatusOK, rsp.StatusCode) } } - -// TODO: remove along chroot https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561 -func TestEnableJailFromEnvironment(t *testing.T) { - out, teardown := runPagesProcess(t, - true, - *pagesBinary, - []ListenSpec{httpListener}, - "", - []string{ - "DAEMON_ENABLE_JAIL=true", - }, - "-domain-config-source", "disk", - ) - t.Cleanup(teardown) - - require.Eventually(t, func() bool { - require.Contains(t, out.String(), "\"daemon-enable-jail\":true") - return true - }, time.Second, 10*time.Millisecond) - - rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "project/") - - require.NoError(t, err) - rsp.Body.Close() - require.Equal(t, http.StatusOK, rsp.StatusCode) -} diff --git a/test/acceptance/helpers_test.go b/test/acceptance/helpers_test.go index c1074230..c8852976 100644 --- a/test/acceptance/helpers_test.go +++ b/test/acceptance/helpers_test.go @@ -242,7 +242,6 @@ func RunPagesProcess(t *testing.T, opts ...processOption) *LogCaptureBuffer { "-pages-root", wd, "-internal-gitlab-server", source.URL, "-api-secret-key", gitLabAPISecretKey, - "-domain-config-source", "gitlab", ) logBuf, cleanup := runPagesProcess(t, processCfg.wait, processCfg.pagesBinary, processCfg.listeners, "", processCfg.envs, processCfg.extraArgs...) @@ -352,16 +351,6 @@ func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string, extraAr args = append(args, "-metrics-address", promPort) } - // most of our acceptance tests still work only with disk source - // TODO: remove this with -domain-config-source flag itself along with daemon-enable-jail: - // https://gitlab.com/gitlab-org/gitlab-pages/-/issues/382 - // https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561 - if !contains(extraArgs, "-domain-config-source") { - args = append(args, - "-domain-config-source", "disk", - ) - } - args = append(args, getPagesDaemonArgs(t)...) args = append(args, extraArgs...) diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index c42866ee..8c4ab461 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -4,8 +4,6 @@ import ( "fmt" "io/ioutil" "net/http" - "os" - "path" "strings" "testing" "time" @@ -106,51 +104,6 @@ func TestKnownHostReturns200(t *testing.T) { } } -// TODO: remove along with support for disk configuration https://gitlab.com/gitlab-org/gitlab-pages/-/issues/382 -func TestNestedSubgroups(t *testing.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 := RunPagesProcessWithoutGitLabStub(t, *pagesBinary, supportedListeners(), "", "-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 supportedListeners() { - 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 TestCustom404(t *testing.T) { RunPagesProcess(t) @@ -425,42 +378,6 @@ func TestDomainsSource(t *testing.T) { apiCalled: true, }, }, - { - name: "disk_source_domain_exists", - args: args{ - configSource: "disk", - // test.domain.com sourced from disk configuration - domain: "test.domain.com", - urlSuffix: "/", - }, - want: want{ - statusCode: http.StatusOK, - content: "main-dir\n", - apiCalled: false, - }, - }, - { - name: "disk_source_domain_does_not_exist", - args: args{ - configSource: "disk", - domain: "non-existent-domain.gitlab.io", - }, - want: want{ - statusCode: http.StatusNotFound, - apiCalled: false, - }, - }, - { - name: "disk_source_domain_should_not_exist_under_hashed_dir", - args: args{ - configSource: "disk", - domain: "hashed.com", - }, - want: want{ - statusCode: http.StatusNotFound, - apiCalled: false, - }, - }, } for _, tt := range tests { @@ -474,7 +391,7 @@ func TestDomainsSource(t *testing.T) { gitLabAPISecretKey := CreateGitLabAPISecretKeyFixtureFile(t) - pagesArgs := []string{"-gitlab-server", source.URL, "-api-secret-key", gitLabAPISecretKey, "-domain-config-source", tt.args.configSource} + pagesArgs := []string{"-gitlab-server", source.URL, "-api-secret-key", gitLabAPISecretKey} teardown := RunPagesProcessWithEnvs(t, true, *pagesBinary, []ListenSpec{httpListener}, "", []string{}, pagesArgs...) defer teardown() |