Search in sources :

Example 1 with ClientsPage

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

the class ClientsEntityTest method shouldListClientsWithoutFilter.

@Test
public void shouldListClientsWithoutFilter() throws Exception {
    Request<ClientsPage> request = api.clients().list(null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CLIENTS_LIST, 200);
    ClientsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/clients"));
    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) ClientsPage(com.auth0.json.mgmt.client.ClientsPage) Test(org.junit.Test)

Example 2 with ClientsPage

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

the class ClientsEntityTest method shouldListClientsWithFields.

@Test
public void shouldListClientsWithFields() throws Exception {
    ClientFilter filter = new ClientFilter().withFields("some,random,fields", true);
    Request<ClientsPage> request = api.clients().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CLIENTS_PAGED_LIST, 200);
    ClientsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/clients"));
    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) ClientFilter(com.auth0.client.mgmt.filter.ClientFilter) ClientsPage(com.auth0.json.mgmt.client.ClientsPage) Test(org.junit.Test)

Example 3 with ClientsPage

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

the class ClientsEntityTest method shouldListClientsWithTotals.

@Test
public void shouldListClientsWithTotals() throws Exception {
    ClientFilter filter = new ClientFilter().withTotals(true);
    Request<ClientsPage> request = api.clients().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CLIENTS_PAGED_LIST, 200);
    ClientsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/clients"));
    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) ClientFilter(com.auth0.client.mgmt.filter.ClientFilter) ClientsPage(com.auth0.json.mgmt.client.ClientsPage) Test(org.junit.Test)

Example 4 with ClientsPage

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

the class ClientsEntityTest method shouldListClientsWithPage.

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

Example 5 with ClientsPage

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

the class ClientsEntityTest method shouldListClientsWithAdditionalProperties.

@Test
public void shouldListClientsWithAdditionalProperties() throws Exception {
    ClientFilter filter = new ClientFilter().withAppType("regular_web,native").withIsFirstParty(true).withIsGlobal(true);
    Request<ClientsPage> request = api.clients().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CLIENTS_LIST, 200);
    ClientsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/clients"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("app_type", "regular_web,native"));
    assertThat(recordedRequest, hasQueryParameter("is_first_party", "true"));
    assertThat(recordedRequest, hasQueryParameter("is_global", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ClientFilter(com.auth0.client.mgmt.filter.ClientFilter) ClientsPage(com.auth0.json.mgmt.client.ClientsPage) Test(org.junit.Test)

Aggregations

ClientsPage (com.auth0.json.mgmt.client.ClientsPage)5 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)5 Test (org.junit.Test)5 ClientFilter (com.auth0.client.mgmt.filter.ClientFilter)4