use of org.sagebionetworks.bridge.models.accounts.IdentifierUpdate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantControllerTest method updateIdentifiersWithPhone.
@Test
public void updateIdentifiersWithPhone() throws Exception {
mockRequestBody(mockRequest, PHONE_UPDATE);
when(mockParticipantService.updateIdentifiers(eq(app), any(), any())).thenReturn(participant);
JsonNode result = controller.updateIdentifiers();
assertEquals(result.get("id").textValue(), TEST_USER_ID);
verify(mockParticipantService).updateIdentifiers(eq(app), contextCaptor.capture(), identifierUpdateCaptor.capture());
verify(mockCacheProvider).setUserSession(sessionCaptor.capture());
assertEquals(sessionCaptor.getValue().getId(), participant.getId());
IdentifierUpdate update = identifierUpdateCaptor.getValue();
assertEquals(update.getSignIn().getEmail(), EMAIL_PASSWORD_SIGN_IN_REQUEST.getEmail());
assertEquals(update.getSignIn().getPassword(), EMAIL_PASSWORD_SIGN_IN_REQUEST.getPassword());
assertEquals(update.getPhoneUpdate(), PHONE);
assertNull(update.getEmailUpdate());
}
use of org.sagebionetworks.bridge.models.accounts.IdentifierUpdate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantControllerTest method updateIdentifiersWithSynapseUserId.
@Test
public void updateIdentifiersWithSynapseUserId() throws Exception {
mockRequestBody(mockRequest, SYNAPSE_ID_UPDATE);
when(mockParticipantService.updateIdentifiers(eq(app), any(), any())).thenReturn(participant);
JsonNode result = controller.updateIdentifiers();
assertEquals(result.get("id").textValue(), TEST_USER_ID);
verify(mockParticipantService).updateIdentifiers(eq(app), contextCaptor.capture(), identifierUpdateCaptor.capture());
IdentifierUpdate update = identifierUpdateCaptor.getValue();
assertEquals(update.getSignIn().getEmail(), EMAIL_PASSWORD_SIGN_IN_REQUEST.getEmail());
assertEquals(update.getSignIn().getPassword(), EMAIL_PASSWORD_SIGN_IN_REQUEST.getPassword());
assertEquals(update.getSynapseUserIdUpdate(), SYNAPSE_USER_ID);
assertNull(update.getPhoneUpdate());
}
use of org.sagebionetworks.bridge.models.accounts.IdentifierUpdate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantController method updateIdentifiers.
@PostMapping("/v3/participants/self/identifiers")
public JsonNode updateIdentifiers() {
UserSession session = getAuthenticatedSession();
IdentifierUpdate update = parseJson(IdentifierUpdate.class);
App app = appService.getApp(session.getAppId());
CriteriaContext context = getCriteriaContext(session);
StudyParticipant participant = participantService.updateIdentifiers(app, context, update);
sessionUpdateService.updateParticipant(session, context, participant);
return UserSessionInfo.toJSON(session);
}
use of org.sagebionetworks.bridge.models.accounts.IdentifierUpdate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantServiceTest method updateIdentifiersValidatesWithInvalidPhone.
@Test(expectedExceptions = InvalidEntityException.class)
public void updateIdentifiersValidatesWithInvalidPhone() {
IdentifierUpdate update = new IdentifierUpdate(EMAIL_PASSWORD_SIGN_IN, null, new Phone("US", "1231231234"), null);
participantService.updateIdentifiers(APP, CONTEXT, update);
}
use of org.sagebionetworks.bridge.models.accounts.IdentifierUpdate in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantServiceTest method updateIdentifiersAddsSynapseUserId.
@Test
public void updateIdentifiersAddsSynapseUserId() {
mockAccountNoEmail();
when(accountService.authenticate(APP, EMAIL_PASSWORD_SIGN_IN)).thenReturn(account);
when(accountService.getAccount(any())).thenReturn(Optional.of(account));
IdentifierUpdate update = new IdentifierUpdate(EMAIL_PASSWORD_SIGN_IN, EMAIL, null, SYNAPSE_USER_ID);
participantService.updateIdentifiers(APP, CONTEXT, update);
assertEquals(account.getSynapseUserId(), SYNAPSE_USER_ID);
}
Aggregations