List of usage examples for org.springframework.boot.autoconfigure.security.oauth2.resource ResourceServerProperties ResourceServerProperties
public ResourceServerProperties(String clientId, String clientSecret)
From source file:com.netflix.genie.web.security.oauth2.pingfederate.PingFederateRemoteTokenServicesUnitTests.java
/** * Setup for the tests.//from w ww . j a va2 s.c om */ @Before public void setup() { this.resourceServerProperties = new ResourceServerProperties(CLIENT_ID, CLIENT_SECRET); this.resourceServerProperties.setTokenInfoUri(CHECK_TOKEN_ENDPOINT_URL); this.registry = Mockito.mock(Registry.class); this.validationError = Mockito.mock(Id.class); this.authenticationTimer = Mockito.mock(Timer.class); final Timer pingFederateAPITimer = Mockito.mock(Timer.class); Mockito.when(this.registry.createId(Mockito.anyString())).thenReturn(this.validationError); Mockito.when(this.registry.timer(PingFederateRemoteTokenServices.AUTHENTICATION_TIMER_NAME)) .thenReturn(this.authenticationTimer); Mockito.when(this.registry.timer(PingFederateRemoteTokenServices.API_TIMER_NAME)) .thenReturn(pingFederateAPITimer); }
From source file:com.netflix.genie.web.security.oauth2.pingfederate.PingFederateRemoteTokenServicesUnitTests.java
/** * Make sure we can't construct without a client id. *///from w w w . j ava 2 s . c om @Test(expected = IllegalStateException.class) public void cantConstructWithoutClientId() { final ResourceServerProperties properties = new ResourceServerProperties(null, null); final AccessTokenConverter converter = new DefaultAccessTokenConverter(); new PingFederateRemoteTokenServices(properties, converter, this.registry); }
From source file:com.netflix.genie.web.security.oauth2.pingfederate.PingFederateRemoteTokenServicesUnitTests.java
/** * Make sure we can't construct without a client secret. */// w ww .j a v a 2 s. co m @Test(expected = IllegalStateException.class) public void cantConstructWithoutClientSecret() { final ResourceServerProperties properties = new ResourceServerProperties("AnID", null); final AccessTokenConverter converter = new DefaultAccessTokenConverter(); new PingFederateRemoteTokenServices(properties, converter, this.registry); }
From source file:com.netflix.genie.web.security.oauth2.pingfederate.PingFederateRemoteTokenServicesUnitTests.java
/** * Make sure rest call failures are handled. *//*from ww w .ja v a 2s .c o m*/ @Test public void cantLoadAuthenticationOnRestError() { final String path = UUID.randomUUID().toString(); final String uri = "http://localhost:" + this.wireMockRule.port() + "/" + path; final int status = HttpStatus.NOT_FOUND.value(); WireMock.post(WireMock.urlEqualTo(uri)).willReturn(WireMock.aResponse().withStatus(status)); final AccessTokenConverter converter = Mockito.mock(AccessTokenConverter.class); this.resourceServerProperties = new ResourceServerProperties(CLIENT_ID, CLIENT_SECRET); // Some resource no one should ever have this.resourceServerProperties.setTokenInfoUri(uri); final PingFederateRemoteTokenServices services = new PingFederateRemoteTokenServices( this.resourceServerProperties, converter, this.registry); final String accessToken = UUID.randomUUID().toString(); final Counter restErrorCounter = Mockito.mock(Counter.class); final Id finalValidationId = Mockito.mock(Id.class); Mockito.when(this.validationError.withTag(Mockito.anyString(), Mockito.eq(Integer.toString(status)))) .thenReturn(finalValidationId); Mockito.when(this.registry.counter(finalValidationId)).thenReturn(restErrorCounter); // Should throw exception based on error key being present try { services.loadAuthentication(accessToken); Assert.fail(); } catch (final HttpClientErrorException | HttpServerErrorException e) { Mockito.verify(restErrorCounter, Mockito.times(1)).increment(); } }