Search in sources :

Example 51 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class ClientGrantsEntityTest method shouldListClientGrantsWithPage.

@Test
public void shouldListClientGrantsWithPage() throws Exception {
    ClientGrantsFilter filter = new ClientGrantsFilter().withPage(23, 5);
    Request<ClientGrantsPage> request = api.clientGrants().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CLIENT_GRANTS_LIST, 200);
    ClientGrantsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/client-grants"));
    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 : ClientGrantsPage(com.auth0.json.mgmt.ClientGrantsPage) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ClientGrantsFilter(com.auth0.client.mgmt.filter.ClientGrantsFilter) Test(org.junit.Test)

Example 52 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class ClientGrantsEntityTest method shouldListClientGrantsWithoutFilter.

@Test
public void shouldListClientGrantsWithoutFilter() throws Exception {
    Request<ClientGrantsPage> request = api.clientGrants().list(null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CLIENT_GRANTS_LIST, 200);
    ClientGrantsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/client-grants"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : ClientGrantsPage(com.auth0.json.mgmt.ClientGrantsPage) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Test(org.junit.Test)

Example 53 with Request

use of com.auth0.net.Request 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 54 with Request

use of com.auth0.net.Request 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 55 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class ClientsEntityTest method shouldGetClient.

@Test
public void shouldGetClient() throws Exception {
    Request<Client> request = api.clients().get("1");
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_CLIENT, 200);
    Client response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/clients/1"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Client(com.auth0.json.mgmt.client.Client) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)193 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)185 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)77 IOException (java.io.IOException)76 List (java.util.List)63 Algorithm (com.auth0.jwt.algorithms.Algorithm)35 VoidRequest (com.auth0.net.VoidRequest)33 Auth0Exception (com.auth0.exception.Auth0Exception)30 APIException (com.auth0.exception.APIException)27 RateLimitException (com.auth0.exception.RateLimitException)25 HashMap (java.util.HashMap)24 PageFilter (com.auth0.client.mgmt.filter.PageFilter)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)23 ServletException (javax.servlet.ServletException)23 TokenHolder (com.auth0.json.auth.TokenHolder)22 JWTVerifier (com.auth0.jwt.JWTVerifier)22 ArrayList (java.util.ArrayList)22 Test (org.junit.jupiter.api.Test)22 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)20 Date (java.util.Date)20