use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileController method getIdVerificationsForReview.
@Override
@AuthorityRequired({ Authority.REVIEW_ID_VERIFICATION })
public ResponseEntity<IdVerificationListResponse> getIdVerificationsForReview() {
IdVerificationListResponse response = new IdVerificationListResponse();
List<Profile> responseList = new ArrayList<Profile>();
try {
for (User user : userService.getNonVerifiedUsers()) {
responseList.add(profileService.getProfile(user));
}
} catch (ApiException e) {
log.log(Level.INFO, "Error calling FireCloud", e);
return ResponseEntity.status(e.getCode()).build();
}
response.setProfileList(responseList);
return ResponseEntity.ok(response);
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testMe_userBeforeNotLoggedInSuccess.
@Test
public void testMe_userBeforeNotLoggedInSuccess() throws Exception {
createUser();
when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
Profile profile = profileController.getMe().getBody();
String projectName = BILLING_PROJECT_PREFIX + PRIMARY_EMAIL.hashCode();
assertProfile(profile, PRIMARY_EMAIL, CONTACT_EMAIL, FAMILY_NAME, GIVEN_NAME, DataAccessLevel.UNREGISTERED, TIMESTAMP, projectName, true);
verify(fireCloudService).registerUser(CONTACT_EMAIL, GIVEN_NAME, FAMILY_NAME);
verify(fireCloudService).createAllOfUsBillingProject(projectName);
verify(fireCloudService).addUserToBillingProject(PRIMARY_EMAIL, projectName);
// An additional call to getMe() should have no effect.
clock.increment(1);
profile = profileController.getMe().getBody();
assertProfile(profile, PRIMARY_EMAIL, CONTACT_EMAIL, FAMILY_NAME, GIVEN_NAME, DataAccessLevel.UNREGISTERED, TIMESTAMP, projectName, true);
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testMe_secondCallStillPendingProject.
@Test
public void testMe_secondCallStillPendingProject() throws Exception {
createUser();
when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
Profile profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.PENDING);
// Simulate FC "Creating".
org.pmiops.workbench.firecloud.model.BillingProjectMembership membership = new org.pmiops.workbench.firecloud.model.BillingProjectMembership();
membership.setCreationStatus(CreationStatusEnum.CREATING);
membership.setProjectName(BILLING_PROJECT_NAME);
when(fireCloudService.getBillingProjectMemberships()).thenReturn(ImmutableList.of(membership));
profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.PENDING);
verify(fireCloudService, never()).grantGoogleRoleToUser(any(), any(), any());
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method testMe_secondCallProjectNotReturned.
@Test
public void testMe_secondCallProjectNotReturned() throws Exception {
createUser();
when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
Profile profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.PENDING);
org.pmiops.workbench.firecloud.model.BillingProjectMembership membership = new org.pmiops.workbench.firecloud.model.BillingProjectMembership();
membership.setCreationStatus(CreationStatusEnum.READY);
membership.setProjectName("unrelated-project");
when(fireCloudService.getBillingProjectMemberships()).thenReturn(ImmutableList.of(membership));
profile = profileController.getMe().getBody();
assertThat(profile.getFreeTierBillingProjectStatus()).isEqualTo(BillingProjectStatus.PENDING);
verify(fireCloudService, never()).grantGoogleRoleToUser(any(), any(), any());
}
use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.
the class ProfileControllerTest method setUp.
@Before
public void setUp() {
WorkbenchConfig config = new WorkbenchConfig();
config.firecloud = new FireCloudConfig();
config.firecloud.billingProjectPrefix = BILLING_PROJECT_PREFIX;
WorkbenchEnvironment environment = new WorkbenchEnvironment(true, "appId");
WorkbenchEnvironment cloudEnvironment = new WorkbenchEnvironment(false, "appId");
createAccountRequest = new CreateAccountRequest();
invitationVerificationRequest = new InvitationVerificationRequest();
Profile profile = new Profile();
profile.setContactEmail(CONTACT_EMAIL);
profile.setFamilyName(FAMILY_NAME);
profile.setGivenName(GIVEN_NAME);
profile.setUsername(USERNAME);
createAccountRequest.setProfile(profile);
createAccountRequest.setInvitationKey(INVITATION_KEY);
createAccountRequest.setPassword(PASSWORD);
invitationVerificationRequest.setInvitationKey(INVITATION_KEY);
googleUser = new com.google.api.services.admin.directory.model.User();
googleUser.setPrimaryEmail(PRIMARY_EMAIL);
clock = new FakeClock(NOW);
idVerificationRequest = new IdVerificationRequest();
idVerificationRequest.setFirstName("Bob");
UserService userService = new UserService(userProvider, userDao, adminActionHistoryDao, clock, fireCloudService, configProvider);
ProfileService profileService = new ProfileService(fireCloudService, mailChimpService, userDao);
this.profileController = new ProfileController(profileService, userProvider, userAuthenticationProvider, userDao, clock, userService, fireCloudService, directoryService, cloudStorageService, blockscoreService, mailChimpService, Providers.of(config), environment);
this.cloudProfileController = new ProfileController(profileService, userProvider, userAuthenticationProvider, userDao, clock, userService, fireCloudService, directoryService, cloudStorageService, blockscoreService, mailChimpService, Providers.of(config), cloudEnvironment);
}
Aggregations