Class OidcScenarios

java.lang.Object
org.pac4j.testkit.OidcScenarios

public final class OidcScenarios extends Object
Pre-assembled HTTP test scenarios for OAuth2/OIDC authorization code flow. Requires mock-oauth2-server running. The consumer starts it before tests, passes its URL, and stops it after.
  • Method Details

    • runAuthorizationCodeFlow

      public static void runAuthorizationCodeFlow(String serverUrl, no.nav.security.mock.oauth2.MockOAuth2Server mockServer) throws IOException
      Full authorization code flow: GET /protected -> redirect to IdP -> follow redirects through authorize -> callback -> /protected -> 200
      Throws:
      IOException
    • runLogout

      public static void runLogout(String serverUrl, no.nav.security.mock.oauth2.MockOAuth2Server mockServer) throws IOException
      RP-initiated logout: 1. Authenticate via OAuth2 flow 2. POST /logout -> framework handles logout (expects redirect) 3. After logout, GET /protected should redirect to authorize (session cleared)
      Throws:
      IOException
    • runUnauthenticatedRedirect

      public static void runUnauthenticatedRedirect(String serverUrl, String mockOAuthServerUrl) throws IOException
      Verify unauthenticated access redirects to the IdP's authorize endpoint.
      Throws:
      IOException
    • runCallbackError

      public static void runCallbackError(String serverUrl) throws IOException
      Verify that OAuth callback errors are handled gracefully (not 200). GET /callback?error=access_deniedinvalid input: '&error_description'=user+denied
      Throws:
      IOException