Search in sources :

Example 6 with PageFilter

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

the class RolesEntityTest method shouldListPermissionsWithPage.

@Test
public void shouldListPermissionsWithPage() throws Exception {
    PageFilter filter = new PageFilter().withPage(23, 5);
    Request<PermissionsPage> request = api.roles().listPermissions("1", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_ROLE_PERMISSIONS_PAGED_LIST, 200);
    PermissionsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles/1/permissions"));
    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) PermissionsPage(com.auth0.json.mgmt.PermissionsPage) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 7 with PageFilter

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

the class UsersEntityTest method shouldListPermissionsWithPage.

@Test
public void shouldListPermissionsWithPage() throws Exception {
    PageFilter filter = new PageFilter().withPage(23, 5);
    Request<PermissionsPage> request = api.users().listPermissions("1", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_USER_PERMISSIONS_PAGED_LIST, 200);
    PermissionsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1/permissions"));
    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) PermissionsPage(com.auth0.json.mgmt.PermissionsPage) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 8 with PageFilter

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

the class UsersEntityTest method shouldListRolesWithTotals.

@Test
public void shouldListRolesWithTotals() throws Exception {
    PageFilter filter = new PageFilter().withTotals(true);
    Request<RolesPage> request = api.users().listRoles("1", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_USER_ROLES_PAGED_LIST, 200);
    RolesPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1/roles"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    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) PageFilter(com.auth0.client.mgmt.filter.PageFilter) RolesPage(com.auth0.json.mgmt.RolesPage) Test(org.junit.Test)

Example 9 with PageFilter

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

the class UsersEntityTest method shouldListPermissionsWithTotal.

@Test
public void shouldListPermissionsWithTotal() throws Exception {
    PageFilter filter = new PageFilter().withTotals(true);
    Request<PermissionsPage> request = api.users().listPermissions("1", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_USER_PERMISSIONS_PAGED_LIST, 200);
    PermissionsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1/permissions"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    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) PermissionsPage(com.auth0.json.mgmt.PermissionsPage) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 10 with PageFilter

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

the class OrganizationEntityTest method shouldGetOrganizationConnectionsWithTotals.

@Test
public void shouldGetOrganizationConnectionsWithTotals() throws Exception {
    PageFilter filter = new PageFilter().withTotals(true);
    Request<EnabledConnectionsPage> request = api.organizations().getConnections("org_abc", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MockServer.ORGANIZATION_CONNECTIONS_PAGED_LIST, 200);
    EnabledConnectionsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/enabled_connections"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("include_totals", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Aggregations

PageFilter (com.auth0.client.mgmt.filter.PageFilter)23 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)23 Test (org.junit.Test)23 PermissionsPage (com.auth0.json.mgmt.PermissionsPage)4 RolesPage (com.auth0.json.mgmt.RolesPage)4 UsersPage (com.auth0.json.mgmt.users.UsersPage)3 OrganizationsPage (com.auth0.json.mgmt.organizations.OrganizationsPage)2