Search in sources :

Example 31 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class LogEventsEntityTest method shouldListLogEventsWithCheckpoint.

@Test
public void shouldListLogEventsWithCheckpoint() throws Exception {
    LogEventFilter filter = new LogEventFilter().withCheckpoint("id3", 5);
    Request<LogEventsPage> request = api.logEvents().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_LOG_EVENTS_LIST, 200);
    LogEventsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("from", "id3"));
    assertThat(recordedRequest, hasQueryParameter("take", "5"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) LogEventFilter(com.auth0.client.mgmt.filter.LogEventFilter) Test(org.junit.Test)

Example 32 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class LogEventsEntityTest method shouldListLogEventsWithFields.

@Test
public void shouldListLogEventsWithFields() throws Exception {
    LogEventFilter filter = new LogEventFilter().withFields("some,random,fields", true);
    Request<LogEventsPage> request = api.logEvents().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_LOG_EVENTS_LIST, 200);
    LogEventsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("fields", "some,random,fields"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) LogEventFilter(com.auth0.client.mgmt.filter.LogEventFilter) Test(org.junit.Test)

Example 33 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class LogEventsEntityTest method shouldListLogEventsWithPage.

@Test
public void shouldListLogEventsWithPage() throws Exception {
    LogEventFilter filter = new LogEventFilter().withPage(23, 5);
    Request<LogEventsPage> request = api.logEvents().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_LOG_EVENTS_LIST, 200);
    LogEventsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("page", "23"));
    assertThat(recordedRequest, hasQueryParameter("per_page", "5"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) LogEventFilter(com.auth0.client.mgmt.filter.LogEventFilter) Test(org.junit.Test)

Example 34 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class LogEventsEntityTest method shouldListLogEventsWithQuery.

@Test
public void shouldListLogEventsWithQuery() throws Exception {
    LogEventFilter filter = new LogEventFilter().withQuery("email:\\*@gmail.com");
    Request<LogEventsPage> request = api.logEvents().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_LOG_EVENTS_LIST, 200);
    LogEventsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("q", "email:\\*@gmail.com"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) LogEventFilter(com.auth0.client.mgmt.filter.LogEventFilter) Test(org.junit.Test)

Example 35 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class LogEventsEntityTest method shouldListEventLogs.

@Test
public void shouldListEventLogs() throws Exception {
    Request<LogEventsPage> request = api.logEvents().list(null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_LOG_EVENTS_LIST, 200);
    LogEventsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)193 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)185 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)77 IOException (java.io.IOException)76 List (java.util.List)63 Algorithm (com.auth0.jwt.algorithms.Algorithm)35 VoidRequest (com.auth0.net.VoidRequest)33 Auth0Exception (com.auth0.exception.Auth0Exception)30 APIException (com.auth0.exception.APIException)27 RateLimitException (com.auth0.exception.RateLimitException)25 HashMap (java.util.HashMap)24 PageFilter (com.auth0.client.mgmt.filter.PageFilter)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)23 ServletException (javax.servlet.ServletException)23 TokenHolder (com.auth0.json.auth.TokenHolder)22 JWTVerifier (com.auth0.jwt.JWTVerifier)22 ArrayList (java.util.ArrayList)22 Test (org.junit.jupiter.api.Test)22 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)20 Date (java.util.Date)20