use of com.auth0.json.mgmt.GrantsPage 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));
}
use of com.auth0.json.mgmt.GrantsPage 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));
}
use of com.auth0.json.mgmt.GrantsPage 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));
}
use of com.auth0.json.mgmt.GrantsPage in project auth0-java by auth0.
the class GrantsEntityTest method shouldListGrantsWithoutFilter.
@Test
public void shouldListGrantsWithoutFilter() throws Exception {
Request<GrantsPage> request = api.grants().list("userId", null);
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(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
}
Aggregations