E2E test that checks OpenID Connect Authorization Code Flow.
(t *testing.T)
| 533 | |
| 534 | // E2E test that checks OpenID Connect Authorization Code Flow. |
| 535 | func 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. |
nothing calls this directly
no test coverage detected