Search in sources :

Example 6 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage 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)

Example 7 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class UsersEntityTest method shouldGetUserLogEvents.

@Test
public void shouldGetUserLogEvents() throws Exception {
    Request<LogEventsPage> request = api.users().getLogEvents("1", 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/users/1/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) Test(org.junit.Test)

Example 8 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class UsersEntityTest method shouldGetUserLogEventsWithPage.

@Test
public void shouldGetUserLogEventsWithPage() throws Exception {
    LogEventFilter filter = new LogEventFilter().withPage(23, 5);
    Request<LogEventsPage> request = api.users().getLogEvents("1", 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/users/1/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 9 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class UsersEntityTest method shouldGetUserLogEventsWithFields.

@Test
public void shouldGetUserLogEventsWithFields() throws Exception {
    LogEventFilter filter = new LogEventFilter().withFields("some,random,fields", true);
    Request<LogEventsPage> request = api.users().getLogEvents("1", 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/users/1/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 10 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class UsersEntityTest method shouldGetUserLogEventsWithSort.

@Test
public void shouldGetUserLogEventsWithSort() throws Exception {
    LogEventFilter filter = new LogEventFilter().withSort("date:1");
    Request<LogEventsPage> request = api.users().getLogEvents("1", 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/users/1/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("sort", "date:1"));
    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)

Aggregations

LogEventsPage (com.auth0.json.mgmt.logevents.LogEventsPage)14 Test (org.junit.Test)14 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)12 LogEventFilter (com.auth0.client.mgmt.filter.LogEventFilter)10