use of com.auth0.client.auth.AuthAPI in project auth0-java by auth0.
the class AuthAPITest method shouldConfigureHeaderLoggingFromOptions.
@Test
public void shouldConfigureHeaderLoggingFromOptions() {
LoggingOptions loggingOptions = new LoggingOptions(LoggingOptions.LogLevel.HEADERS);
Set<String> headersToRedact = new HashSet<>();
headersToRedact.add("Authorization");
headersToRedact.add("Cookie");
loggingOptions.setHeadersToRedact(headersToRedact);
HttpOptions options = new HttpOptions();
options.setLoggingOptions(loggingOptions);
AuthAPI api = new AuthAPI(DOMAIN, CLIENT_ID, CLIENT_SECRET, options);
assertThat(api.getClient().interceptors(), hasItem(isA(HttpLoggingInterceptor.class)));
for (Interceptor i : api.getClient().interceptors()) {
if (i instanceof HttpLoggingInterceptor) {
HttpLoggingInterceptor logging = (HttpLoggingInterceptor) i;
assertThat(logging.getLevel(), is(Level.HEADERS));
}
}
}
use of com.auth0.client.auth.AuthAPI in project auth0-java-mvc-common by auth0.
the class AuthorizeUrlTest method setUp.
@BeforeEach
public void setUp() {
client = new AuthAPI("domain.auth0.com", "clientId", "clientSecret");
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
}
use of com.auth0.client.auth.AuthAPI in project auth0-java-mvc-common by auth0.
the class RequestProcessorTest method shouldBuildAuthorizeUrlWithFormPostIfResponseTypeIsToken.
@Test
public void shouldBuildAuthorizeUrlWithFormPostIfResponseTypeIsToken() {
AuthAPI client = new AuthAPI("me.auth0.com", "clientId", "clientSecret");
RequestProcessor handler = new RequestProcessor.Builder(client, "token", verifyOptions).build();
HttpServletRequest request = new MockHttpServletRequest();
AuthorizeUrl builder = handler.buildAuthorizeUrl(request, response, "https://redirect.uri/here", "state", "nonce");
String authorizeUrl = builder.build();
assertThat(authorizeUrl, is(notNullValue()));
assertThat(authorizeUrl, CoreMatchers.startsWith("https://me.auth0.com/authorize?"));
assertThat(authorizeUrl, containsString("client_id=clientId"));
assertThat(authorizeUrl, containsString("redirect_uri=https://redirect.uri/here"));
assertThat(authorizeUrl, containsString("response_type=token"));
assertThat(authorizeUrl, containsString("scope=openid"));
assertThat(authorizeUrl, containsString("state=state"));
assertThat(authorizeUrl, containsString("response_mode=form_post"));
}
use of com.auth0.client.auth.AuthAPI in project auth0-java-mvc-common by auth0.
the class RequestProcessorTest method shouldNotSetNullNonceIfRequestTypeIsIdToken.
@Test
public void shouldNotSetNullNonceIfRequestTypeIsIdToken() {
AuthAPI client = new AuthAPI("me.auth0.com", "clientId", "clientSecret");
RequestProcessor handler = new RequestProcessor.Builder(client, "id_token", verifyOptions).build();
HttpServletRequest request = new MockHttpServletRequest();
AuthorizeUrl builder = handler.buildAuthorizeUrl(request, response, "https://redirect.uri/here", "state", null);
String authorizeUrl = builder.build();
assertThat(authorizeUrl, is(notNullValue()));
assertThat(authorizeUrl, not(containsString("nonce=nonce")));
}
Aggregations