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:
authorKrasimir Angelov <kangelov@gitlab.com>2019-12-12 10:34:13 +0300
committerKrasimir Angelov <kangelov@gitlab.com>2020-01-10 05:38:30 +0300
commite0ba15e77cfe922ece762f487269cb4e626ca290 (patch)
tree75a135ef0f813b21c2a3490a9ee766725c117ce2 /acceptance_test.go
parent86d619069f226d40d3d0ba97a243db384f133d5f (diff)
Watch a file to configure which domains should use new gitlab source
Instead of passing domains once in an ENV variable we now watcn a config file (specified with `GITLAB_SOURCE_CONFIG_FILE`, defaults to `.gitlab-source-config.yml` and update ednabled/broken domains when it's content change. This way we can control this without having to restart Pages. Related to https://gitlab.com/gitlab-org/gitlab-pages/issues/266.
Diffstat (limited to 'acceptance_test.go')
-rw-r--r--acceptance_test.go39
1 files changed, 23 insertions, 16 deletions
diff --git a/acceptance_test.go b/acceptance_test.go
index ae1bf2b6..49d391b1 100644
--- a/acceptance_test.go
+++ b/acceptance_test.go
@@ -432,20 +432,6 @@ func TestPageNotAvailableIfNotLoaded(t *testing.T) {
require.Equal(t, http.StatusServiceUnavailable, rsp.StatusCode)
}
-func TestPageNotAvailableInDomainSource(t *testing.T) {
- skipUnlessEnabled(t)
-
- brokenDomain := "GITLAB_NEW_SOURCE_BROKEN_DOMAIN=pages-broken-poc.gitlab.io"
- teardown := RunPagesProcessWithEnvs(t, false, *pagesBinary, listeners, "", []string{brokenDomain}, "-pages-root=shared/invalid-pages")
- defer teardown()
- waitForRoundtrips(t, listeners, 5*time.Second)
-
- rsp, err := GetPageFromListener(t, httpListener, "pages-broken-poc.gitlab.io", "index.html")
- require.NoError(t, err)
- defer rsp.Body.Close()
- require.Equal(t, http.StatusBadGateway, rsp.StatusCode)
-}
-
func TestObscureMIMEType(t *testing.T) {
skipUnlessEnabled(t)
teardown := RunPagesProcessWithoutWait(t, *pagesBinary, listeners, "")
@@ -1534,10 +1520,22 @@ func TestGitlabDomainsSource(t *testing.T) {
source := NewGitlabDomainsSourceStub(t)
defer source.Close()
- newSourceDomains := "GITLAB_NEW_SOURCE_DOMAINS=new-source-test.gitlab.io,non-existent-domain.gitlab.io"
+ gitlabSourceConfig := `
+domains:
+ enabled:
+ - new-source-test.gitlab.io
+ broken: pages-broken-poc.gitlab.io
+`
+ gitlabSourceConfigFile, cleanupGitlabSourceConfigFile := CreateGitlabSourceConfigFixtureFile(t, gitlabSourceConfig)
+ defer cleanupGitlabSourceConfigFile()
+
+ gitlabSourceConfigFile = "GITLAB_SOURCE_CONFIG_FILE=" + gitlabSourceConfigFile
+
gitLabAPISecretKey := CreateGitLabAPISecretKeyFixtureFile(t)
+
pagesArgs := []string{"-gitlab-server", source.URL, "-api-secret-key", gitLabAPISecretKey}
- teardown := RunPagesProcessWithEnvs(t, true, *pagesBinary, listeners, "", []string{newSourceDomains}, pagesArgs...)
+
+ teardown := RunPagesProcessWithEnvs(t, true, *pagesBinary, listeners, "", []string{gitlabSourceConfigFile}, pagesArgs...)
defer teardown()
t.Run("when a domain exists", func(t *testing.T) {
@@ -1558,4 +1556,13 @@ func TestGitlabDomainsSource(t *testing.T) {
require.Equal(t, http.StatusNotFound, response.StatusCode)
})
+
+ t.Run("broken domain is requested", func(t *testing.T) {
+ response, err := GetPageFromListener(t, httpListener, "pages-broken-poc.gitlab.io", "index.html")
+ require.NoError(t, err)
+
+ defer response.Body.Close()
+
+ require.Equal(t, http.StatusBadGateway, response.StatusCode)
+ })
}