Class MockOAuth2Server

    • Constructor Detail

      • MockOAuth2Server

        MockOAuth2Server(Route additionalRoutes)
    • Method Detail

      • start

        @JvmOverloads() final Unit start(Integer port)

        Starts the MockOAuth2Server on the localhost interface.

        Parameters:
        port - The port the server should listen on, a value of 0 (which is the default) selects any available port.
      • start

         final Unit start(InetAddress inetAddress, Integer port)

        Starts the MockOAuth2Server on the given inetAddress IP address at the given port.

        Parameters:
        inetAddress - The IP address that the server should bind to.
        port - The port that the server should listen on, a value of 0 selects any available port.
      • url

         final HttpUrl url(String path)

        Returns the authorization server's issuer identifier for the given path. The identifier is a URL without query or fragment components, e.g. http://localhost:8080/some-issuer.

        Parameters:
        path - The path or identifier for the issuer.
      • enqueueResponse

        @Deprecated(message = "Use MockWebServer method/function instead", replaceWith = @ReplaceWith(imports = {}, expression = "MockWebServer.enqueue()")) final Unit enqueueResponse(MockResponse response)
      • takeRequest

        @JvmOverloads() final RecordedRequest takeRequest(Long timeout, TimeUnit unit)

        Awaits the next HTTP request (waiting up to the specified wait time if necessary), removes it from the queue, and returns it. Callers should use this to verify the request was sent as intended within the given time.

        Parameters:
        timeout - How long to wait before giving up, in units of unit
        unit - A TimeUnit determining how to interpret the timeout parameter
      • takeRequest

        @JvmOverloads() final RecordedRequest takeRequest(Long timeout)

        Awaits the next HTTP request (waiting up to the specified wait time if necessary), removes it from the queue, and returns it. Callers should use this to verify the request was sent as intended within the given time.

        Parameters:
        timeout - How long to wait before giving up, in units of unit
      • takeRequest

        @JvmOverloads() final RecordedRequest takeRequest()

        Awaits the next HTTP request (waiting up to the specified wait time if necessary), removes it from the queue, and returns it. Callers should use this to verify the request was sent as intended within the given time.

      • wellKnownUrl

         final HttpUrl wellKnownUrl(String issuerId)

        Returns the authorization server's well-known OpenID Connect metadata discovery URL for the given issuerId.

        E.g. http://localhost:8080/some-issuer/.well-known/openid-configuration.

        See also OpenID Provider metadata.

        Parameters:
        issuerId - The path or identifier for the issuer.
      • tokenEndpointUrl

         final HttpUrl tokenEndpointUrl(String issuerId)

        Returns the authorization server's token_endpoint for the given issuerId.

        E.g. http://localhost:8080/some-issuer/token.

        Parameters:
        issuerId - The path or identifier for the issuer.
      • jwksUrl

         final HttpUrl jwksUrl(String issuerId)

        Returns the authorization server's jwks_uri for the given issuerId.

        E.g. http://localhost:8080/some-issuer/jwks.

        Parameters:
        issuerId - The path or identifier for the issuer.
      • authorizationEndpointUrl

         final HttpUrl authorizationEndpointUrl(String issuerId)

        Returns the authorization server's authorization_endpoint for the given issuerId.

        E.g. http://localhost:8080/some-issuer/authorize.

        Parameters:
        issuerId - The path or identifier for the issuer.
      • endSessionEndpointUrl

         final HttpUrl endSessionEndpointUrl(String issuerId)

        Returns the authorization server's end_session_endpoint for the given issuerId.

        E.g. http://localhost:8080/some-issuer/endsession.

        Parameters:
        issuerId - The path or identifier for the issuer.
      • revocationEndpointUrl

         final HttpUrl revocationEndpointUrl(String issuerId)

        Returns the authorization server's revocation_endpoint for the given issuerId.

        E.g. http://localhost:8080/some-issuer/revoke.

        Parameters:
        issuerId - The path or identifier for the issuer.
      • userInfoUrl

         final HttpUrl userInfoUrl(String issuerId)

        Returns the authorization server's userinfo_endpoint for the given issuerId.

        E.g. http://localhost:8080/some-issuer/userinfo.

        Parameters:
        issuerId - The path or identifier for the issuer.
      • baseUrl

         final HttpUrl baseUrl()

        Returns the base URL for this server.

      • issueToken

         final SignedJWT issueToken(String issuerId, String clientId, OAuth2TokenCallback tokenCallback)

        Issues a signed JWT as part of the authorization code grant.

        Parameters:
        issuerId - The path or identifier for the issuer.
        clientId - The identifier for the client or Relying Party that requests the token.
        tokenCallback - A callback that implements the OAuth2TokenCallback interface for token customization.