Search in sources :

Example 1 with AudienceValidator

use of org.springframework.cloud.gcp.security.iap.AudienceValidator in project spring-cloud-gcp by spring-cloud.

the class IapAuthenticationAutoConfigurationTests method testIapBeansReturnedWhenBothIapWithMultipleAudiencesAndSpringSecurityConfigPresent.

@Test
public void testIapBeansReturnedWhenBothIapWithMultipleAudiencesAndSpringSecurityConfigPresent() {
    when(mockJwt.getAudience()).thenReturn(Collections.singletonList("aud1"));
    this.contextRunner.withPropertyValues("spring.cloud.gcp.security.iap.audience=aud1, aud2").run((context) -> {
        AudienceValidator validator = context.getBean(AudienceValidator.class);
        OAuth2TokenValidatorResult result = validator.validate(mockJwt);
        assertThat(result.hasErrors()).isFalse();
    });
}
Also used : AudienceValidator(org.springframework.cloud.gcp.security.iap.AudienceValidator) OAuth2TokenValidatorResult(org.springframework.security.oauth2.core.OAuth2TokenValidatorResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AudienceValidator (org.springframework.cloud.gcp.security.iap.AudienceValidator)1 OAuth2TokenValidatorResult (org.springframework.security.oauth2.core.OAuth2TokenValidatorResult)1