diff options
Diffstat (limited to 'test/acceptance/serving_test.go')
-rw-r--r-- | test/acceptance/serving_test.go | 11 |
1 files changed, 6 insertions, 5 deletions
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) { |