Search in sources :

Example 1 with OAuth2TokenFormat

use of org.springframework.security.oauth2.core.OAuth2TokenFormat in project spring-authorization-server by spring-projects.

the class JwtGeneratorTests method generateWhenUnsupportedTokenFormatThenReturnNull.

@Test
public void generateWhenUnsupportedTokenFormatThenReturnNull() {
    // @formatter:off
    TokenSettings tokenSettings = TokenSettings.builder().accessTokenFormat(new OAuth2TokenFormat("unsupported_token_format")).build();
    RegisteredClient registeredClient = TestRegisteredClients.registeredClient().tokenSettings(tokenSettings).build();
    OAuth2TokenContext tokenContext = DefaultOAuth2TokenContext.builder().registeredClient(registeredClient).tokenType(OAuth2TokenType.ACCESS_TOKEN).build();
    // @formatter:on
    assertThat(this.jwtGenerator.generate(tokenContext)).isNull();
}
Also used : TokenSettings(org.springframework.security.oauth2.server.authorization.config.TokenSettings) OAuth2TokenFormat(org.springframework.security.oauth2.core.OAuth2TokenFormat) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) Test(org.junit.Test)

Example 2 with OAuth2TokenFormat

use of org.springframework.security.oauth2.core.OAuth2TokenFormat in project spring-authorization-server by spring-projects.

the class OAuth2AccessTokenGeneratorTests method generateWhenUnsupportedTokenFormatThenReturnNull.

@Test
public void generateWhenUnsupportedTokenFormatThenReturnNull() {
    // @formatter:off
    TokenSettings tokenSettings = TokenSettings.builder().accessTokenFormat(new OAuth2TokenFormat("unsupported_token_format")).build();
    RegisteredClient registeredClient = TestRegisteredClients.registeredClient().tokenSettings(tokenSettings).build();
    OAuth2TokenContext tokenContext = DefaultOAuth2TokenContext.builder().registeredClient(registeredClient).tokenType(OAuth2TokenType.ACCESS_TOKEN).build();
    // @formatter:on
    assertThat(this.accessTokenGenerator.generate(tokenContext)).isNull();
}
Also used : TokenSettings(org.springframework.security.oauth2.server.authorization.config.TokenSettings) OAuth2TokenFormat(org.springframework.security.oauth2.core.OAuth2TokenFormat) RegisteredClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 OAuth2TokenFormat (org.springframework.security.oauth2.core.OAuth2TokenFormat)2 RegisteredClient (org.springframework.security.oauth2.server.authorization.client.RegisteredClient)2 TokenSettings (org.springframework.security.oauth2.server.authorization.config.TokenSettings)2