Search in sources :

Example 1 with GrantsFilter

use of com.auth0.client.mgmt.filter.GrantsFilter in project auth0-java by auth0.

the class GrantsEntityTest method shouldListGrantsWithPage.

@Test
public void shouldListGrantsWithPage() throws Exception {
    GrantsFilter filter = new GrantsFilter().withPage(23, 5);
    Request<GrantsPage> request = api.grants().list("userId", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_GRANTS_LIST, 200);
    GrantsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/grants"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("user_id", "userId"));
    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) GrantsFilter(com.auth0.client.mgmt.filter.GrantsFilter) GrantsPage(com.auth0.json.mgmt.GrantsPage) Test(org.junit.Test)

Example 2 with GrantsFilter

use of com.auth0.client.mgmt.filter.GrantsFilter in project auth0-java by auth0.

the class GrantsEntityTest method shouldListGrantsWithTotals.

@Test
public void shouldListGrantsWithTotals() throws Exception {
    GrantsFilter filter = new GrantsFilter().withTotals(true);
    Request<GrantsPage> request = api.grants().list("userId", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_GRANTS_PAGED_LIST, 200);
    GrantsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/grants"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("user_id", "userId"));
    assertThat(recordedRequest, hasQueryParameter("include_totals", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
    assertThat(response.getStart(), is(0));
    assertThat(response.getLength(), is(14));
    assertThat(response.getTotal(), is(14));
    assertThat(response.getLimit(), is(50));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) GrantsFilter(com.auth0.client.mgmt.filter.GrantsFilter) GrantsPage(com.auth0.json.mgmt.GrantsPage) Test(org.junit.Test)

Example 3 with GrantsFilter

use of com.auth0.client.mgmt.filter.GrantsFilter in project auth0-java by auth0.

the class GrantsEntityTest method shouldListGrantsWithAdditionalProperties.

@Test
public void shouldListGrantsWithAdditionalProperties() throws Exception {
    GrantsFilter filter = new GrantsFilter().withAudience("https://myapi.auth0.com").withClientId("u9e3hh3e9j2fj9092ked");
    Request<GrantsPage> request = api.grants().list("userId", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_GRANTS_LIST, 200);
    GrantsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/grants"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("user_id", "userId"));
    assertThat(recordedRequest, hasQueryParameter("audience", "https://myapi.auth0.com"));
    assertThat(recordedRequest, hasQueryParameter("client_id", "u9e3hh3e9j2fj9092ked"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) GrantsFilter(com.auth0.client.mgmt.filter.GrantsFilter) GrantsPage(com.auth0.json.mgmt.GrantsPage) Test(org.junit.Test)

Aggregations

GrantsFilter (com.auth0.client.mgmt.filter.GrantsFilter)3 GrantsPage (com.auth0.json.mgmt.GrantsPage)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 Test (org.junit.Test)3