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:
authorJaime Martinez <jmartinez@gitlab.com>2021-01-29 03:50:08 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-01-29 03:51:07 +0300
commitf3ddb8306f424bd805643826f6ee33da40ea8f27 (patch)
treef68675f4d6a4eb6eb07bc8a0d3c8b445e438b444
parent19e8f5c98625a9fbf648dccfc2f52da08346d7ec (diff)
Update notes and test
-rw-r--r--internal/source/gitlab/client/client.go6
-rw-r--r--test/acceptance/serving_test.go11
2 files changed, 9 insertions, 8 deletions
diff --git a/internal/source/gitlab/client/client.go b/internal/source/gitlab/client/client.go
index c4e6ebf2..98939641 100644
--- a/internal/source/gitlab/client/client.go
+++ b/internal/source/gitlab/client/client.go
@@ -25,9 +25,9 @@ import (
const ConnectionErrorMsg = "failed to connect to internal Pages API"
// ErrUnauthorizedAPI is returned when resolving a domain with the GitLab API
-// returns a http.StatusUnauthorized. This is an edge case when `domain-config-source=auto`
-// and there are multiple instances of GitLab Rails and GitLab Pages running.
-// See https://gitlab.com/gitlab-org/gitlab-pages/-/issues/535 for more info
+// returns a http.StatusUnauthorized. This happens if the common secret file
+// is not synced between gitlab-pages and gitlab-rails servers.
+// See https://gitlab.com/gitlab-org/gitlab-pages/-/issues/535 for more details.
var ErrUnauthorizedAPI = errors.New("pages endpoint unauthorized")
// Client is a HTTP client to access Pages internal API
diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go
index 1c898085..eb9a8023 100644
--- a/test/acceptance/serving_test.go
+++ b/test/acceptance/serving_test.go
@@ -520,11 +520,11 @@ func TestDomainsSource(t *testing.T) {
// The first request will fail and display an error but subsequent requests will
// serve from disk source when `domain-config-source=auto`
func TestGitLabSourceBecomesUnauthorized(t *testing.T) {
- opts := stubOpts{
+ opts := &stubOpts{
// edge case https://gitlab.com/gitlab-org/gitlab-pages/-/issues/535
pagesStatusResponse: http.StatusUnauthorized,
}
- source := NewGitlabDomainsSourceStub(t, &opts)
+ source := NewGitlabDomainsSourceStub(t, opts)
defer source.Close()
gitLabAPISecretKey := CreateGitLabAPISecretKeyFixtureFile(t)
@@ -537,21 +537,22 @@ func TestGitLabSourceBecomesUnauthorized(t *testing.T) {
failedResponse, err := GetPageFromListener(t, httpListener, domain, "/")
require.NoError(t, err)
+ require.True(t, opts.apiCalled, "API should be called")
require.Equal(t, http.StatusBadGateway, failedResponse.StatusCode, "first response should fail with 502")
// make request again
+ opts.apiCalled = false
+
response, err := GetPageFromListener(t, httpListener, domain, "/")
require.NoError(t, err)
defer response.Body.Close()
+ require.False(t, opts.apiCalled, "API should not be called after the first failure")
require.Equal(t, http.StatusOK, response.StatusCode, "second response should succeed")
- require.True(t, opts.apiCalled, "api called mismatch")
body, err := ioutil.ReadAll(response.Body)
require.NoError(t, err)
require.Equal(t, "main-dir\n", string(body), "content mismatch")
-
- require.True(t, opts.apiCalled, "api called mismatch")
}
func TestKnownHostInReverseProxySetupReturns200(t *testing.T) {