diff options
Diffstat (limited to 'test/acceptance/stub_test.go')
-rw-r--r-- | test/acceptance/stub_test.go | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/test/acceptance/stub_test.go b/test/acceptance/stub_test.go index 7fc733a1..9e271f37 100644 --- a/test/acceptance/stub_test.go +++ b/test/acceptance/stub_test.go @@ -3,7 +3,6 @@ package acceptance_test import ( "fmt" "net/http" - "net/http/httptest" "os" "regexp" "testing" @@ -67,46 +66,6 @@ func withStubOptions(opts *stubOpts) processOption { } } -// makeGitLabPagesAccessStub provides a stub *httptest.Server to check pages_access API call. -// the result is based on the project id. -// -// Project IDs must be 4 digit long and the following rules applies: -// 1000-1999: Ok -// 2000-2999: Unauthorized -// 3000-3999: Invalid token -func makeGitLabPagesAccessStub(t *testing.T) *httptest.Server { - t.Helper() - - return httptest.NewUnstartedServer(apiHandler(t)) -} - -func apiHandler(t *testing.T) http.HandlerFunc { - t.Helper() - - return func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - // TODO: move OAuth and user endpoints to NewGitlabDomainsSourceStub - case "/oauth/token": - require.Equal(t, "POST", r.Method) - w.WriteHeader(http.StatusOK) - fmt.Fprint(w, "{\"access_token\":\"abc\"}") - case "/api/v4/user": - require.Equal(t, "Bearer abc", r.Header.Get("Authorization")) - w.WriteHeader(http.StatusOK) - case "/api/v4/internal/pages/status": - // Temporarily adding these handlers to this stub. - w.WriteHeader(http.StatusNoContent) - case "/api/v4/internal/pages": - defaultAPIHandler(t, &stubOpts{})(w, r) - default: - if handleAccessControlArtifactRequests(t, w, r) { - return - } - handleAccessControlRequests(t, w, r) - } - } -} - func CreateHTTPSFixtureFiles(t *testing.T) (key string, cert string) { t.Helper() |