-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support deprecated config micronaut.security.oauth2.clients.*.to…
…ken.auth-method (#1818) support deprecated config `micronaut.security.oauth2.clients.*.token.auth-method` and new `micronaut.security.oauth2.clients.*.token.authentication-method` options. Close: #1808
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...rc/test/java/io/micronaut/security/oauth2/configuration/OauthClientConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.micronaut.security.oauth2.configuration; | ||
|
||
import io.micronaut.context.annotation.Property; | ||
import io.micronaut.security.oauth2.configuration.endpoints.SecureEndpointConfiguration; | ||
import io.micronaut.security.oauth2.endpoint.AuthenticationMethod; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@Property(name = "micronaut.security.oauth2.clients.stravaold.scopes", value = "read") | ||
@Property(name = "micronaut.security.oauth2.clients.stravaold.authorization.url", value = "https://www.strava.com/oauth/authorize") | ||
@Property(name = "micronaut.security.oauth2.clients.stravaold.token.url", value = "https://www.strava.com/oauth/token") | ||
@Property(name = "micronaut.security.oauth2.clients.stravaold.token.auth-method", value = "client_secret_post") | ||
@Property(name = "micronaut.security.oauth2.clients.stravaold.client-id", value = "xxx") | ||
@Property(name = "micronaut.security.oauth2.clients.stravaold.client-secret", value = "yyy") | ||
@Property(name = "micronaut.security.oauth2.clients.stravanew.scopes", value = "read") | ||
@Property(name = "micronaut.security.oauth2.clients.stravanew.authorization.url", value = "https://www.strava.com/oauth/authorize") | ||
@Property(name = "micronaut.security.oauth2.clients.stravanew.token.url", value = "https://www.strava.com/oauth/token") | ||
@Property(name = "micronaut.security.oauth2.clients.stravanew.token.authentication-method", value = "client_secret_post") | ||
@Property(name = "micronaut.security.oauth2.clients.stravanew.client-id", value = "xxx") | ||
@Property(name = "micronaut.security.oauth2.clients.stravanew.client-secret", value = "yyy") | ||
@MicronautTest(startApplication = false) | ||
class OauthClientConfigurationTest { | ||
|
||
@Inject | ||
@Named("stravaold") | ||
OauthClientConfiguration stravaOldConfiguration; | ||
|
||
@Inject | ||
@Named("stravanew") | ||
OauthClientConfiguration stravaNewConfiguration; | ||
|
||
|
||
@Test | ||
void deprecatedAuthMethodConfigurationIsStillSupported() { | ||
assertTrue(stravaOldConfiguration.getToken().isPresent()); | ||
SecureEndpointConfiguration tokenEndpoint = stravaOldConfiguration.getToken().get(); | ||
assertTrue(tokenEndpoint.getAuthenticationMethod().isPresent()); | ||
assertEquals("client_secret_post", tokenEndpoint.getAuthenticationMethod().get()); | ||
assertTrue(tokenEndpoint.getAuthMethod().isPresent()); | ||
assertEquals(AuthenticationMethod.CLIENT_SECRET_POST, tokenEndpoint.getAuthMethod().get()); | ||
|
||
assertTrue(stravaNewConfiguration.getToken().isPresent()); | ||
SecureEndpointConfiguration tokenNewEndpoint = stravaNewConfiguration.getToken().get(); | ||
assertTrue(tokenNewEndpoint.getAuthenticationMethod().isPresent()); | ||
assertEquals("client_secret_post", tokenNewEndpoint.getAuthenticationMethod().get()); | ||
assertTrue(tokenNewEndpoint.getAuthMethod().isPresent()); | ||
assertEquals(AuthenticationMethod.CLIENT_SECRET_POST, tokenNewEndpoint.getAuthMethod().get()); | ||
|
||
} | ||
|
||
} |