Search in sources :

Example 1 with RolesPage

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

the class OrganizationEntityTest method shouldGetOrgRolesWithPaging.

@Test
public void shouldGetOrgRolesWithPaging() throws Exception {
    Request<RolesPage> request = api.organizations().getRoles("org_abc", "user_123", new PageFilter().withPage(0, 20));
    assertThat(request, is(notNullValue()));
    server.jsonResponse(ORGANIZATION_MEMBER_ROLES_LIST, 200);
    RolesPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/members/user_123/roles"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("page", "0"));
    assertThat(recordedRequest, hasQueryParameter("per_page", "20"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(1));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) RolesPage(com.auth0.json.mgmt.RolesPage) Test(org.junit.Test)

Example 2 with RolesPage

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

the class OrganizationEntityTest method shouldGetOrgRolesWithIncludeTotals.

@Test
public void shouldGetOrgRolesWithIncludeTotals() throws Exception {
    Request<RolesPage> request = api.organizations().getRoles("org_abc", "user_123", new PageFilter().withTotals(true));
    assertThat(request, is(notNullValue()));
    server.jsonResponse(ORGANIZATION_MEMBER_ROLES_PAGED_LIST, 200);
    RolesPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/members/user_123/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(1));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) RolesPage(com.auth0.json.mgmt.RolesPage) Test(org.junit.Test)

Example 3 with RolesPage

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

the class OrganizationEntityTest method shouldGetOrgRolesWithoutPaging.

@Test
public void shouldGetOrgRolesWithoutPaging() throws Exception {
    Request<RolesPage> request = api.organizations().getRoles("org_abc", "user_123", null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(ORGANIZATION_MEMBER_ROLES_LIST, 200);
    RolesPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/members/user_123/roles"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(1));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) RolesPage(com.auth0.json.mgmt.RolesPage) Test(org.junit.Test)

Example 4 with RolesPage

use of com.auth0.json.mgmt.RolesPage 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 5 with RolesPage

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

the class RolesEntityTest method shouldListRolesWithPage.

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

Aggregations

RolesPage (com.auth0.json.mgmt.RolesPage)9 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)9 Test (org.junit.Test)9 PageFilter (com.auth0.client.mgmt.filter.PageFilter)4 RolesFilter (com.auth0.client.mgmt.filter.RolesFilter)2