use of com.auth0.json.mgmt.ClientGrant 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.json.mgmt.ClientGrant 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.json.mgmt.ClientGrant in project auth0-java by auth0.
the class ClientGrantsEntityTest method shouldListClientGrants.
@Test
public void shouldListClientGrants() throws Exception {
@SuppressWarnings("deprecation") Request<List<ClientGrant>> request = api.clientGrants().list();
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_CLIENT_GRANTS_LIST, 200);
List<ClientGrant> 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, hasSize(2));
}
Aggregations