use of com.auth0.net.Request in project auth0-java by auth0.
the class ResourceServerEntityTest method shouldGetResourceServerById.
@Test
public void shouldGetResourceServerById() throws Exception {
Request<ResourceServer> request = api.resourceServers().get("23445566abab");
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_RESOURCE_SERVER, 200);
ResourceServer response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/resource-servers/23445566abab"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(response.getIdentifier(), is("https://api.my-company.com/api/v2/"));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class RolesEntityTest method shouldGetRole.
@Test
public void shouldGetRole() throws Exception {
Request<Role> request = api.roles().get("1");
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLE, 200);
Role response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles/1"));
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 RolesEntityTest method shouldListUsersWithPage.
@Test
public void shouldListUsersWithPage() throws Exception {
PageFilter filter = new PageFilter().withPage(23, 5);
Request<UsersPage> request = api.roles().listUsers("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLE_USERS_PAGED_LIST, 200);
UsersPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles/1/users"));
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));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class RolesEntityTest method shouldListPermissionsWithPage.
@Test
public void shouldListPermissionsWithPage() throws Exception {
PageFilter filter = new PageFilter().withPage(23, 5);
Request<PermissionsPage> request = api.roles().listPermissions("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLE_PERMISSIONS_PAGED_LIST, 200);
PermissionsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles/1/permissions"));
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));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class RulesConfigsEntityTest method shouldUpdateRulesConfig.
@Test
public void shouldUpdateRulesConfig() throws Exception {
Request<RulesConfig> request = api.rulesConfigs().update("1", new RulesConfig("my-value"));
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_CONNECTION, 200);
RulesConfig response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("PUT", "/api/v2/rules-configs/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(body, hasEntry("value", "my-value"));
assertThat(response, is(notNullValue()));
}
Aggregations