use of com.auth0.net.Request in project auth0-java by auth0.
the class OrganizationEntityTest method shouldGetInvitationsWithFilter.
@Test
public void shouldGetInvitationsWithFilter() throws Exception {
InvitationsFilter filter = new InvitationsFilter().withSort("created_at:1").withFields("invitee,inviter,created_at", true);
Request<InvitationsPage> request = api.organizations().getInvitations("org_123", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(INVITATIONS_LIST, 200);
InvitationsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_123/invitations"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("fields", "invitee,inviter,created_at"));
assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
assertThat(recordedRequest, hasQueryParameter("sort", "created_at:1"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class OrganizationEntityTest method shouldGetInvitationsWithTotals.
@Test
public void shouldGetInvitationsWithTotals() throws Exception {
InvitationsFilter filter = new InvitationsFilter().withTotals(true);
Request<InvitationsPage> request = api.organizations().getInvitations("org_123", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(INVITATIONS_PAGED_LIST, 200);
InvitationsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_123/invitations"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("include_totals", "true"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class OrganizationEntityTest method shouldListOrgsWithPage.
@Test
public void shouldListOrgsWithPage() throws Exception {
PageFilter filter = new PageFilter().withPage(2, 30);
Request<OrganizationsPage> request = api.organizations().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MockServer.ORGANIZATIONS_PAGED_LIST, 200);
OrganizationsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("page", "2"));
assertThat(recordedRequest, hasQueryParameter("per_page", "30"));
assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class ResourceServerEntityTest method shouldListResourceServerWithPage.
@Test
public void shouldListResourceServerWithPage() throws Exception {
ResourceServersFilter filter = new ResourceServersFilter().withPage(23, 5);
Request<ResourceServersPage> request = api.resourceServers().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_RESOURCE_SERVERS_LIST, 200);
ResourceServersPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/resource-servers"));
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 ResourceServerEntityTest method shouldUpdateResourceServer.
@Test
public void shouldUpdateResourceServer() throws Exception {
ResourceServer resourceServer = new ResourceServer("https://api.my-company.com/api/v2/");
resourceServer.setId("23445566abab");
resourceServer.setName("Some API");
resourceServer.setScopes(Collections.singletonList(new Scope("update:something")));
resourceServer.setSigningAlgorithm("RS256");
resourceServer.setSigningSecret("secret");
resourceServer.setAllowOfflineAccess(false);
resourceServer.setEnforcePolicies(true);
resourceServer.setSkipConsentForVerifiableFirstPartyClients(false);
resourceServer.setTokenDialect("access_token");
resourceServer.setTokenLifetime(0);
resourceServer.setVerificationLocation("verification_location");
Request<ResourceServer> request = api.resourceServers().update("23445566abab", resourceServer);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_RESOURCE_SERVER, 200);
ResourceServer response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("PATCH", "/api/v2/resource-servers/23445566abab"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(12));
assertThat(body, hasEntry("identifier", "https://api.my-company.com/api/v2/"));
assertThat(response.getIdentifier(), is("https://api.my-company.com/api/v2/"));
}
Aggregations