Search in sources :

Example 1 with HttpAuthenticationException

use of nl.nn.adapterframework.http.authentication.HttpAuthenticationException in project iaf by ibissource.

the class OAuthAccessTokenManagerTest method testRetrieveAccessTokenWrongCredentials.

@Test
public void testRetrieveAccessTokenWrongCredentials() throws Exception {
    String tokenEndpoint = TOKENENDPOINT;
    String scope = "email";
    String clientId = clientClientId;
    String clientSecret = "xxx";
    CredentialFactory client_cf = new CredentialFactory(null, clientId, clientSecret);
    OAuthAccessTokenManager accessTokenManager = new OAuthAccessTokenManager(tokenEndpoint, scope, client_cf, true, httpSender);
    HttpAuthenticationException exception = assertThrows(HttpAuthenticationException.class, () -> accessTokenManager.getAccessToken(null));
    assertThat(exception.getMessage(), containsString("unauthorized_client"));
}
Also used : CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) HttpAuthenticationException(nl.nn.adapterframework.http.authentication.HttpAuthenticationException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) OAuthAccessTokenManager(nl.nn.adapterframework.http.authentication.OAuthAccessTokenManager) Test(org.junit.Test)

Example 2 with HttpAuthenticationException

use of nl.nn.adapterframework.http.authentication.HttpAuthenticationException in project iaf by ibissource.

the class OAuthAccessTokenManagerTest method testRetrieveAccessTokenWrongTokenEndpoint.

@Test
public void testRetrieveAccessTokenWrongTokenEndpoint() throws Exception {
    String tokenEndpoint = TOKENENDPOINT + "x";
    String scope = "email";
    String clientId = clientClientId;
    String clientSecret = clientClientSecret;
    CredentialFactory client_cf = new CredentialFactory(null, clientId, clientSecret);
    OAuthAccessTokenManager accessTokenManager = new OAuthAccessTokenManager(tokenEndpoint, scope, client_cf, true, httpSender);
    HttpAuthenticationException exception = assertThrows(HttpAuthenticationException.class, () -> accessTokenManager.getAccessToken(null));
    assertThat(exception.getMessage(), containsString("404"));
}
Also used : CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) HttpAuthenticationException(nl.nn.adapterframework.http.authentication.HttpAuthenticationException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) OAuthAccessTokenManager(nl.nn.adapterframework.http.authentication.OAuthAccessTokenManager) Test(org.junit.Test)

Aggregations

HttpAuthenticationException (nl.nn.adapterframework.http.authentication.HttpAuthenticationException)2 OAuthAccessTokenManager (nl.nn.adapterframework.http.authentication.OAuthAccessTokenManager)2 CredentialFactory (nl.nn.adapterframework.util.CredentialFactory)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2