use of org.sagebionetworks.bridge.models.apps.AppAndUsers in project BridgeServer2 by Sage-Bionetworks.
the class AppServiceTest method createAppAndUsersDefaultsPasswordPolicy.
@Test
public void createAppAndUsersDefaultsPasswordPolicy() throws SynapseException {
app.setPasswordPolicy(null);
app.setExternalIdRequiredOnSignup(false);
app.setSynapseDataAccessTeamId(null);
app.setSynapseProjectId(null);
List<StudyParticipant> participants = ImmutableList.of(new StudyParticipant.Builder().withEmail(TEST_USER_EMAIL).withSynapseUserId(TEST_USER_SYNAPSE_ID).withRoles(ImmutableSet.of(DEVELOPER)).build());
IdentifierHolder holder = new IdentifierHolder("user-id");
when(mockParticipantService.createParticipant(any(), any(), anyBoolean())).thenReturn(holder);
AccessControlList acl = new AccessControlList();
acl.setResourceAccess(new HashSet<>());
when(mockSynapseClient.createTeam(any())).thenReturn(team);
when(mockSynapseClient.createEntity(any())).thenReturn(project);
when(mockSynapseClient.getACL(any())).thenReturn(acl);
EntityView view = new EntityView();
view.setScopeIds(new ArrayList<>());
when(mockSynapseClient.getEntity(SYNAPSE_TRACKING_VIEW_ID, EntityView.class)).thenReturn(view);
AppAndUsers mockAppAndUsers = new AppAndUsers(ImmutableList.of("12345678"), app, participants);
service.createAppAndUsers(mockAppAndUsers);
verify(mockAppDao).createApp(appCaptor.capture());
assertNotNull(appCaptor.getValue().getPasswordPolicy());
}
use of org.sagebionetworks.bridge.models.apps.AppAndUsers in project BridgeServer2 by Sage-Bionetworks.
the class AppServiceTest method createAppAndUsersWithEmptyUser.
@Test(expectedExceptions = InvalidEntityException.class, expectedExceptionsMessageRegExp = ".*users are required.*")
public void createAppAndUsersWithEmptyUser() throws SynapseException {
// mock
App app = getTestApp();
app.setSynapseProjectId(null);
app.setSynapseDataAccessTeamId(null);
List<StudyParticipant> mockUsers = new ArrayList<>();
AppAndUsers mockAppAndUsers = new AppAndUsers(TEST_ADMIN_IDS, app, mockUsers);
// execute
service.createAppAndUsers(mockAppAndUsers);
}
use of org.sagebionetworks.bridge.models.apps.AppAndUsers in project BridgeServer2 by Sage-Bionetworks.
the class AppServiceTest method createAppAndUserInWrongRole.
private void createAppAndUserInWrongRole(Set<Roles> roles) throws SynapseException {
app.setExternalIdRequiredOnSignup(false);
app.setSynapseDataAccessTeamId(null);
app.setSynapseProjectId(null);
List<StudyParticipant> participants = ImmutableList.of(new StudyParticipant.Builder().withSynapseUserId(TEST_USER_SYNAPSE_ID).withEmail(TEST_USER_EMAIL).withRoles(roles).build());
AppAndUsers mockAppAndUsers = new AppAndUsers(ImmutableList.of("12345678"), app, participants);
service.createAppAndUsers(mockAppAndUsers);
}
use of org.sagebionetworks.bridge.models.apps.AppAndUsers in project BridgeServer2 by Sage-Bionetworks.
the class AppServiceTest method createAppAndUsersWithEmptyRoles.
@Test(expectedExceptions = InvalidEntityException.class, expectedExceptionsMessageRegExp = ".*adminIds are required.*")
public void createAppAndUsersWithEmptyRoles() throws SynapseException {
// mock
App app = getTestApp();
app.setSynapseProjectId(null);
app.setSynapseDataAccessTeamId(null);
StudyParticipant mockUser1 = new StudyParticipant.Builder().withEmail(TEST_USER_EMAIL).withSynapseUserId(TEST_USER_SYNAPSE_ID).withFirstName(TEST_USER_FIRST_NAME).withLastName(TEST_USER_LAST_NAME).withRoles(ImmutableSet.of()).withPassword(TEST_USER_PASSWORD).build();
List<StudyParticipant> mockUsers = ImmutableList.of(mockUser1);
AppAndUsers mockAppAndUsers = new AppAndUsers(null, app, mockUsers);
// execute
service.createAppAndUsers(mockAppAndUsers);
}
use of org.sagebionetworks.bridge.models.apps.AppAndUsers in project BridgeServer2 by Sage-Bionetworks.
the class AppServiceTest method createAppAndUsersWithNullApp.
@Test(expectedExceptions = InvalidEntityException.class, expectedExceptionsMessageRegExp = ".*app cannot be null.*")
public void createAppAndUsersWithNullApp() throws SynapseException {
// mock
App app = getTestApp();
app.setSynapseProjectId(null);
app.setSynapseDataAccessTeamId(null);
StudyParticipant mockUser1 = new StudyParticipant.Builder().withEmail(TEST_USER_EMAIL).withSynapseUserId(TEST_USER_SYNAPSE_ID).withFirstName(TEST_USER_FIRST_NAME).withLastName(TEST_USER_LAST_NAME).withRoles(ImmutableSet.of(Roles.RESEARCHER, Roles.DEVELOPER)).withPassword(TEST_USER_PASSWORD).build();
StudyParticipant mockUser2 = new StudyParticipant.Builder().withEmail(TEST_USER_EMAIL_2).withSynapseUserId(TEST_USER_SYNAPSE_ID_2).withFirstName(TEST_USER_FIRST_NAME).withLastName(TEST_USER_LAST_NAME).withRoles(ImmutableSet.of(Roles.RESEARCHER)).withPassword(TEST_USER_PASSWORD).build();
List<StudyParticipant> mockUsers = ImmutableList.of(mockUser1, mockUser2);
AppAndUsers mockAppAndUsers = new AppAndUsers(TEST_ADMIN_IDS, null, mockUsers);
// execute
service.createAppAndUsers(mockAppAndUsers);
}
Aggregations