use of com.auth0.net.Request in project auth0-java by auth0.
the class EmailProviderEntityTest method shouldGetEmailProvider.
@Test
public void shouldGetEmailProvider() throws Exception {
Request<EmailProvider> request = api.emailProvider().get(null);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_EMAIL_PROVIDER, 200);
EmailProvider response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/emails/provider"));
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 EmailTemplatesEntityTest method shouldGetEmailTemplate.
@Test
public void shouldGetEmailTemplate() throws Exception {
Request<EmailTemplate> request = api.emailTemplates().get("welcome_email");
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_EMAIL_TEMPLATE, 200);
EmailTemplate response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/email-templates/welcome_email"));
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 GrantsEntityTest method shouldListGrantsWithPage.
@Test
public void shouldListGrantsWithPage() throws Exception {
GrantsFilter filter = new GrantsFilter().withPage(23, 5);
Request<GrantsPage> request = api.grants().list("userId", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_GRANTS_LIST, 200);
GrantsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/grants"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("user_id", "userId"));
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 GrantsEntityTest method shouldListGrants.
@Test
public void shouldListGrants() throws Exception {
@SuppressWarnings("deprecation") Request<List<Grant>> request = api.grants().list("userId");
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_GRANTS_LIST, 200);
List<Grant> response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/grants"));
assertThat(recordedRequest, hasQueryParameter("user_id", "userId"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(response, is(notNullValue()));
assertThat(response, hasSize(2));
for (Grant grant : response) {
assertThat(grant.getAudience(), notNullValue());
assertThat(grant.getClientId(), notNullValue());
assertThat(grant.getId(), notNullValue());
assertThat(grant.getScope(), notNullValue());
assertThat(grant.getScope(), hasSize(2));
assertThat(grant.getUserId(), equalTo("userId"));
}
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class GrantsEntityTest method shouldListGrantsWithTotals.
@Test
public void shouldListGrantsWithTotals() throws Exception {
GrantsFilter filter = new GrantsFilter().withTotals(true);
Request<GrantsPage> request = api.grants().list("userId", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_GRANTS_PAGED_LIST, 200);
GrantsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/grants"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("user_id", "userId"));
assertThat(recordedRequest, hasQueryParameter("include_totals", "true"));
assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
assertThat(response.getStart(), is(0));
assertThat(response.getLength(), is(14));
assertThat(response.getTotal(), is(14));
assertThat(response.getLimit(), is(50));
}
Aggregations