-
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.
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
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
26 changes: 26 additions & 0 deletions
26
...th2/src/test/groovy/io/micronaut/security/oauth2/client/IdTokenClaimsValidatorSpec.groovy
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 |
---|---|---|
@@ -1,11 +1,37 @@ | ||
package io.micronaut.security.oauth2.client | ||
|
||
import io.micronaut.security.oauth2.configuration.OauthClientConfiguration | ||
import io.micronaut.security.oauth2.configuration.OauthClientConfigurationProperties | ||
import io.micronaut.security.testutils.ApplicationContextSpecification | ||
import spock.lang.Unroll | ||
|
||
class IdTokenClaimsValidatorSpec extends ApplicationContextSpecification { | ||
|
||
void "by default no bean of type IdTokenClaimsValidator exists"() { | ||
expect: | ||
!applicationContext.containsBean(IdTokenClaimsValidator) | ||
} | ||
|
||
@Unroll | ||
void "issuer IdTokenClaimsValidator"(String configIss, String iss) { | ||
given: | ||
def oauthClientConfiguration = new OauthClientConfigurationProperties("oci"); | ||
def openId = new OauthClientConfigurationProperties.OpenIdClientConfigurationProperties("oci"); | ||
openId.setIssuer(new URL(configIss)) | ||
oauthClientConfiguration.setOpenid(openId) | ||
List<OauthClientConfiguration> l = List.of(oauthClientConfiguration) | ||
IdTokenClaimsValidator claimsValidator = new IdTokenClaimsValidator(List.of(l)) | ||
|
||
when: | ||
Optional<Boolean> validation = claimsValidator.matchesIssuer(openId, iss) | ||
|
||
then: | ||
validation.isPresent() | ||
validation.get() == true | ||
|
||
where: | ||
configIss | iss | ||
"https://idcs-227ebfb7094445cc5a3fbc0faa1fe87b.identity.oraclecloud.com" | "https://identity.oraclecloud.com" | ||
"https://identity.oraclecloud.com" | "https://identity.oraclecloud.com" | ||
} | ||
} |