use of com.auth0.json.mgmt.jobs.Job in project engine by Lumeer.
the class UserAuth0Utils method resendVerificationEmail.
public void resendVerificationEmail(final String authId) throws Auth0Exception {
if (!initialized) {
init();
}
if (!skipSecurity) {
refreshManagementApiToken();
final ManagementAPI mApi = new ManagementAPI(domain, managementApiToken);
Job job = mApi.jobs().sendVerificationEmail(authId, backendClientId).execute();
}
}
use of com.auth0.json.mgmt.jobs.Job in project auth0-java by auth0.
the class JobsEntityTest method shouldRequestUsersImportWithOptions.
@Test
public void shouldRequestUsersImportWithOptions() throws Exception {
UsersImportOptions options = new UsersImportOptions();
options.withExternalId("ext_id123");
options.withUpsert(true);
options.withSendCompletionEmail(false);
File usersFile = new File(MGMT_JOB_POST_USERS_IMPORTS_INPUT);
Request<Job> request = api.jobs().importUsers("con_123456789", usersFile, options);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_POST_USERS_IMPORTS, 200);
Job response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/users-imports"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
String ctHeader = recordedRequest.getHeader("Content-Type");
assertThat(ctHeader, startsWith("multipart/form-data"));
String[] ctParts = ctHeader.split("multipart/form-data; boundary=");
RecordedMultipartRequest recordedMultipartRequest = new RecordedMultipartRequest(recordedRequest);
assertThat(recordedMultipartRequest.getPartsCount(), is(5));
assertThat(recordedMultipartRequest.getBoundary(), is(notNullValue()));
assertThat(recordedMultipartRequest.getBoundary(), is(ctParts[1]));
// Connection ID
KeyValuePart connectionIdParam = recordedMultipartRequest.getKeyValuePart("connection_id");
assertThat(connectionIdParam, is(notNullValue()));
assertThat(connectionIdParam.getValue(), is("con_123456789"));
// External ID
KeyValuePart externalIdParam = recordedMultipartRequest.getKeyValuePart("external_id");
assertThat(externalIdParam, is(notNullValue()));
assertThat(externalIdParam.getValue(), is("ext_id123"));
// Upsert
KeyValuePart upsertParam = recordedMultipartRequest.getKeyValuePart("upsert");
assertThat(upsertParam, is(notNullValue()));
assertThat(upsertParam.getValue(), is("true"));
// Send Completion Email
KeyValuePart sendCompletionEmailParam = recordedMultipartRequest.getKeyValuePart("send_completion_email");
assertThat(sendCompletionEmailParam, is(notNullValue()));
assertThat(sendCompletionEmailParam.getValue(), is("false"));
// Users JSON
FilePart jsonFile = recordedMultipartRequest.getFilePart("users");
assertThat(jsonFile, is(notNullValue()));
String utf8Contents = new String(Files.readAllBytes(usersFile.toPath()));
assertThat(jsonFile.getContentType(), is("text/json"));
assertThat(jsonFile.getFilename(), is("job_post_users_imports_input.json"));
assertThat(jsonFile.getValue(), is(utf8Contents));
assertThat(response, is(notNullValue()));
}
use of com.auth0.json.mgmt.jobs.Job in project auth0-java by auth0.
the class JobsEntityTest method shouldSendUserVerificationEmailWithIdentity.
@Test
public void shouldSendUserVerificationEmailWithIdentity() throws Exception {
EmailVerificationIdentity identity = new EmailVerificationIdentity("google-oauth2", "1234");
Request<Job> request = api.jobs().sendVerificationEmail("google-oauth2|1234", "AaiyAPdpYdesoKnqjj8HJqRn4T5titww", identity);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_POST_VERIFICATION_EMAIL, 200);
Job response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/verification-email"));
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", "google-oauth2|1234"));
assertThat(body, hasEntry("client_id", "AaiyAPdpYdesoKnqjj8HJqRn4T5titww"));
Map<String, String> identityMap = new HashMap<>();
identityMap.put("provider", "google-oauth2");
identityMap.put("user_id", "1234");
assertThat(body, hasEntry("identity", identityMap));
assertThat(response, is(notNullValue()));
}
use of com.auth0.json.mgmt.jobs.Job in project auth0-java by auth0.
the class JobsEntityTest method shouldSendUserVerificationEmailWithOrgId.
@Test
public void shouldSendUserVerificationEmailWithOrgId() throws Exception {
Request<Job> request = api.jobs().sendVerificationEmail("google-oauth2|1234", "client_abc", null, "org_abc");
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_POST_VERIFICATION_EMAIL, 200);
Job response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/verification-email"));
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", "google-oauth2|1234"));
assertThat(body, hasEntry("client_id", "client_abc"));
assertThat(body, hasEntry("organization_id", "org_abc"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.json.mgmt.jobs.Job in project auth0-java by auth0.
the class JobsEntityTest method shouldSendUserAVerificationEmailWithNullClientIdAndEmailVerification.
@Test
public void shouldSendUserAVerificationEmailWithNullClientIdAndEmailVerification() throws Exception {
Request<Job> request = api.jobs().sendVerificationEmail("google-oauth2|1234", null, null);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_POST_VERIFICATION_EMAIL, 200);
Job response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/verification-email"));
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("user_id", "google-oauth2|1234"));
assertThat(response, is(notNullValue()));
}
Aggregations