MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestOpenIDConnectAuthCodeFlow

Function TestOpenIDConnectAuthCodeFlow

rest/oidc_api_test.go:535–944  ·  view source on GitHub ↗

E2E test that checks OpenID Connect Authorization Code Flow.

(t *testing.T)

Source from the content-addressed store, hash-verified

533
534// E2E test that checks OpenID Connect Authorization Code Flow.
535func TestOpenIDConnectAuthCodeFlow(t *testing.T) {
536
537 base.LongRunningTest(t)
538 type test struct {
539 name string
540 providers auth.OIDCProviderMap
541 defaultProvider string
542 authURL string
543 forceAuthError forceError
544 forceRefreshError forceError
545 requireExistingUser bool
546 }
547 tests := []test{
548 {
549 // Successful new user authentication against single provider
550 // with auto registration and access token enabled.
551 name: "successful user registration against single provider",
552 providers: auth.OIDCProviderMap{
553 "foo": mockProviderWith("foo", mockProviderRegister{}, mockProviderIncludeAccessToken{}, mockProviderUserPrefix{"foo"}),
554 },
555 defaultProvider: "foo",
556 authURL: "/db/_oidc?provider=foo&offline=true",
557 }, {
558 // Unsuccessful new user authentication against single provider with
559 // auto registration disabled.
560 name: "unsuccessful user registration against single provider",
561 providers: auth.OIDCProviderMap{
562 "foo": mockProvider("foo"),
563 },
564 defaultProvider: "foo",
565 authURL: "/db/_oidc?provider=foo&offline=true",
566 forceAuthError: forceError{
567 errorType: noAutoRegistrationErr,
568 expectedErrorCode: http.StatusUnauthorized,
569 expectedErrorMessage: ErrInvalidLogin.Message,
570 },
571 }, {
572 // Successful new user authentication against single provider with auto
573 // registration enabled but access token NOT.
574 name: "successful user registration against single provider without access token",
575 providers: auth.OIDCProviderMap{
576 "foo": mockProviderWith("foo", mockProviderRegister{}, mockProviderUserPrefix{"foo"}),
577 },
578 defaultProvider: "foo",
579 authURL: "/db/_oidc?provider=foo&offline=true",
580 }, {
581 // Successful new user authentication against multiple providers
582 // with auto registration and access token enabled.
583 name: "successful user registration against multiple providers",
584 providers: auth.OIDCProviderMap{
585 "foo": mockProviderWith("foo", mockProviderRegister{}, mockProviderIncludeAccessToken{}, mockProviderUserPrefix{"foo"}),
586 "bar": mockProviderWith("bar", mockProviderRegister{}, mockProviderIncludeAccessToken{}, mockProviderUserPrefix{"bar"}),
587 },
588 defaultProvider: "foo",
589 authURL: "/db/_oidc?provider=foo&offline=true",
590 }, {
591 // Unsuccessful new user authentication against multiple providers with
592 // auto registration disabled.

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
TestPublicHandlerMethod · 0.95
GetSingleKeyspaceMethod · 0.95
LongRunningTestFunction · 0.92
mockProviderWithFunction · 0.85
mockProviderFunction · 0.85
newMockAuthServerFunction · 0.85
refreshProviderConfigFunction · 0.85
NewRestTesterFunction · 0.85
assertHttpResponseFunction · 0.85
ShutdownMethod · 0.80
createUserFunction · 0.70

Tested by

no test coverage detected