use of com.auth0.json.mgmt.tickets.EmailVerificationTicket in project auth0-java by auth0.
the class EmailVerificationTicketTest method shouldSerializeWithIdentity.
@Test
public void shouldSerializeWithIdentity() throws Exception {
EmailVerificationTicket ticket = new EmailVerificationTicket("usr123");
ticket.setResultUrl("https://page.auth0.com/result");
ticket.setTTLSeconds(36000);
EmailVerificationIdentity identity = new EmailVerificationIdentity("some-provider", "some-user-id");
ticket.setIdentity(identity);
String serialized = toJSON(ticket);
assertThat(serialized, is(notNullValue()));
assertThat(serialized, JsonMatcher.hasEntry("user_id", "usr123"));
assertThat(serialized, JsonMatcher.hasEntry("result_url", "https://page.auth0.com/result"));
assertThat(serialized, JsonMatcher.hasEntry("ttl_sec", 36000));
Map<String, String> identityMap = new HashMap<>();
identityMap.put("provider", "some-provider");
identityMap.put("user_id", "some-user-id");
assertThat(serialized, JsonMatcher.hasEntry("identity", identityMap));
}
use of com.auth0.json.mgmt.tickets.EmailVerificationTicket in project auth0-java by auth0.
the class TicketsEntityTest method shouldCreateEmailVerificationTicket.
@Test
public void shouldCreateEmailVerificationTicket() throws Exception {
EmailVerificationTicket ticket = new EmailVerificationTicket("uid123");
ticket.setIncludeEmailInRedirect(true);
ticket.setTTLSeconds(42);
Request<EmailVerificationTicket> request = api.tickets().requestEmailVerification(ticket);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_EMAIL_VERIFICATION_TICKET, 200);
EmailVerificationTicket response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/tickets/email-verification"));
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("user_id", "uid123"));
assertThat(body, hasEntry("includeEmailInRedirect", true));
assertThat(body, hasEntry("ttl_sec", 42));
assertThat(response, is(notNullValue()));
}
Aggregations