use of com.auth0.net.Request in project auth0-java by auth0.
the class ActionsEntityTest method shouldListActionsWithFilter.
@Test
public void shouldListActionsWithFilter() throws Exception {
ActionsFilter filter = new ActionsFilter().withActionName("action-name").withDeployed(true).withInstalled(false).withTriggerId("post-login").withPage(1, 10);
Request<ActionsPage> request = api.actions().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MockServer.ACTIONS_LIST, 200);
ActionsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/actions/actions"));
assertThat(recordedRequest, hasQueryParameter("actionName", "action-name"));
assertThat(recordedRequest, hasQueryParameter("deployed", "true"));
assertThat(recordedRequest, hasQueryParameter("installed", "false"));
assertThat(recordedRequest, hasQueryParameter("triggerId", "post-login"));
assertThat(recordedRequest, hasQueryParameter("page", "1"));
assertThat(recordedRequest, hasQueryParameter("per_page", "10"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class BlacklistsEntityTest method shouldBlacklistToken.
@Test
public void shouldBlacklistToken() throws Exception {
Request<Void> request = api.blacklists().blacklistToken(new Token("id"));
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_BLACKLISTED_TOKENS_LIST, 200);
request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/blacklists/tokens"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(1));
assertThat(body, hasEntry("jti", "id"));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class ClientGrantsEntityTest method shouldCreateClientGrant.
@Test
public void shouldCreateClientGrant() throws Exception {
Request<ClientGrant> request = api.clientGrants().create("clientId", "audience", new String[] { "openid" });
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_CLIENT_GRANT, 200);
ClientGrant response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/client-grants"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(3));
assertThat(body, hasEntry("client_id", "clientId"));
assertThat(body, hasEntry("audience", "audience"));
assertThat(body, hasKey("scope"));
assertThat((Iterable<?>) body.get("scope"), contains("openid"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class ClientGrantsEntityTest method shouldUpdateClientGrant.
@Test
public void shouldUpdateClientGrant() throws Exception {
Request<ClientGrant> request = api.clientGrants().update("1", new String[] { "openid", "profile" });
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_CLIENT_GRANT, 200);
ClientGrant response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("PATCH", "/api/v2/client-grants/1"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(1));
assertThat((ArrayList<?>) body.get("scope"), contains("openid", "profile"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class ClientGrantsEntityTest method shouldListClientGrantsWithAdditionalProperties.
@Test
public void shouldListClientGrantsWithAdditionalProperties() throws Exception {
ClientGrantsFilter filter = new ClientGrantsFilter().withAudience("https://myapi.auth0.com").withClientId("u9e3hh3e9j2fj9092ked");
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("audience", "https://myapi.auth0.com"));
assertThat(recordedRequest, hasQueryParameter("client_id", "u9e3hh3e9j2fj9092ked"));
assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
}
Aggregations