Search in sources :

Example 1 with Profile

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);
}
Also used : IdVerificationListResponse(org.pmiops.workbench.model.IdVerificationListResponse) User(org.pmiops.workbench.db.model.User) ArrayList(java.util.ArrayList) Profile(org.pmiops.workbench.model.Profile) ApiException(org.pmiops.workbench.firecloud.ApiException) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Example 2 with Profile

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);
}
Also used : Profile(org.pmiops.workbench.model.Profile) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 3 with Profile

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());
}
Also used : BillingProjectMembership(org.pmiops.workbench.model.BillingProjectMembership) Profile(org.pmiops.workbench.model.Profile) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 4 with Profile

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());
}
Also used : BillingProjectMembership(org.pmiops.workbench.model.BillingProjectMembership) Profile(org.pmiops.workbench.model.Profile) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 5 with Profile

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);
}
Also used : WorkbenchConfig(org.pmiops.workbench.config.WorkbenchConfig) FireCloudConfig(org.pmiops.workbench.config.WorkbenchConfig.FireCloudConfig) UserService(org.pmiops.workbench.db.dao.UserService) FakeClock(org.pmiops.workbench.test.FakeClock) InvitationVerificationRequest(org.pmiops.workbench.model.InvitationVerificationRequest) Profile(org.pmiops.workbench.model.Profile) CreateAccountRequest(org.pmiops.workbench.model.CreateAccountRequest) ProfileService(org.pmiops.workbench.auth.ProfileService) IdVerificationRequest(org.pmiops.workbench.model.IdVerificationRequest) WorkbenchEnvironment(org.pmiops.workbench.config.WorkbenchEnvironment) Before(org.junit.Before)

Aggregations

Profile (org.pmiops.workbench.model.Profile)17 Test (org.junit.Test)13 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)13 BillingProjectMembership (org.pmiops.workbench.model.BillingProjectMembership)4 ApiException (org.pmiops.workbench.firecloud.ApiException)3 Address (com.blockscore.models.Address)2 WorkbenchConfig (org.pmiops.workbench.config.WorkbenchConfig)2 FireCloudConfig (org.pmiops.workbench.config.WorkbenchConfig.FireCloudConfig)2 User (org.pmiops.workbench.db.model.User)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 AuthorityRequired (org.pmiops.workbench.annotations.AuthorityRequired)1 ProfileService (org.pmiops.workbench.auth.ProfileService)1 UserAuthentication (org.pmiops.workbench.auth.UserAuthentication)1 WorkbenchEnvironment (org.pmiops.workbench.config.WorkbenchEnvironment)1 UserService (org.pmiops.workbench.db.dao.UserService)1 CreateAccountRequest (org.pmiops.workbench.model.CreateAccountRequest)1 EmailVerificationStatus (org.pmiops.workbench.model.EmailVerificationStatus)1 IdVerificationListResponse (org.pmiops.workbench.model.IdVerificationListResponse)1 IdVerificationRequest (org.pmiops.workbench.model.IdVerificationRequest)1