Search in sources :

Example 11 with Profile

use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.

the class ProfileControllerTest method testSubmitEverything_success.

@Test
public void testSubmitEverything_success() throws Exception {
    createUser();
    when(blockscoreService.createPerson(eq("Bob"), eq(null), any(Address.class), eq(null), eq(null), eq(null))).thenReturn(person);
    when(mailChimpService.getMember(CONTACT_EMAIL)).thenReturn("subscribed");
    when(person.getId()).thenReturn("id");
    when(person.isValid()).thenReturn(true);
    WorkbenchConfig testConfig = new WorkbenchConfig();
    testConfig.firecloud = new FireCloudConfig();
    testConfig.firecloud.registeredDomainName = "";
    when(configProvider.get()).thenReturn(testConfig);
    Profile profile = profileController.completeEthicsTraining().getBody();
    assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.UNREGISTERED);
    profile = profileController.submitDemographicsSurvey().getBody();
    assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.UNREGISTERED);
    profile = profileController.submitTermsOfService().getBody();
    assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.UNREGISTERED);
    profile = profileController.submitIdVerification(idVerificationRequest).getBody();
    assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.REGISTERED);
    verify(fireCloudService).addUserToGroup("bob@researchallofus.org", "");
    assertThat(profile.getBlockscoreIdVerificationStatus()).isEqualTo(BlockscoreIdVerificationStatus.VERIFIED);
    assertThat(profile.getDemographicSurveyCompletionTime()).isEqualTo(NOW.toEpochMilli());
    assertThat(profile.getTermsOfServiceCompletionTime()).isEqualTo(NOW.toEpochMilli());
    assertThat(profile.getEthicsTrainingCompletionTime()).isEqualTo(NOW.toEpochMilli());
}
Also used : WorkbenchConfig(org.pmiops.workbench.config.WorkbenchConfig) Address(com.blockscore.models.Address) FireCloudConfig(org.pmiops.workbench.config.WorkbenchConfig.FireCloudConfig) Profile(org.pmiops.workbench.model.Profile) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 12 with Profile

use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.

the class ProfileControllerTest method testMe_userBeforeSuccessCloudProjectConflict.

@Test
public void testMe_userBeforeSuccessCloudProjectConflict() throws Exception {
    createUser();
    when(fireCloudService.isRequesterEnabledInFirecloud()).thenReturn(true);
    String projectName = BILLING_PROJECT_PREFIX + user.getUserId();
    doThrow(new ApiException(HttpStatus.CONFLICT.value(), "conflict")).when(fireCloudService).createAllOfUsBillingProject(projectName);
    doThrow(new ApiException(HttpStatus.CONFLICT.value(), "conflict")).when(fireCloudService).createAllOfUsBillingProject(projectName + "-1");
    Profile profile = cloudProfileController.getMe().getBody();
    // When a conflict occurs in dev, log the exception but continue.
    assertProfile(profile, PRIMARY_EMAIL, CONTACT_EMAIL, FAMILY_NAME, GIVEN_NAME, DataAccessLevel.UNREGISTERED, TIMESTAMP, projectName + "-2", true);
    verify(fireCloudService).registerUser(CONTACT_EMAIL, GIVEN_NAME, FAMILY_NAME);
    verify(fireCloudService).createAllOfUsBillingProject(projectName);
    verify(fireCloudService).createAllOfUsBillingProject(projectName + "-1");
    verify(fireCloudService).createAllOfUsBillingProject(projectName + "-2");
    verify(fireCloudService).addUserToBillingProject(PRIMARY_EMAIL, projectName + "-2");
}
Also used : Profile(org.pmiops.workbench.model.Profile) ApiException(org.pmiops.workbench.firecloud.ApiException) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 13 with Profile

use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.

the class ProfileControllerTest method testSubmitDemographicSurvey_success.

@Test
public void testSubmitDemographicSurvey_success() throws Exception {
    createUser();
    Profile profile = profileController.submitDemographicsSurvey().getBody();
    assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.UNREGISTERED);
    assertThat(profile.getBlockscoreIdVerificationStatus()).isEqualTo(BlockscoreIdVerificationStatus.UNVERIFIED);
    assertThat(profile.getDemographicSurveyCompletionTime()).isEqualTo(NOW.toEpochMilli());
    assertThat(profile.getTermsOfServiceCompletionTime()).isNull();
    assertThat(profile.getEthicsTrainingCompletionTime()).isNull();
}
Also used : Profile(org.pmiops.workbench.model.Profile) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 14 with Profile

use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.

the class ProfileControllerTest method testSubmitTermsOfService_success.

@Test
public void testSubmitTermsOfService_success() throws Exception {
    createUser();
    Profile profile = profileController.submitTermsOfService().getBody();
    assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.UNREGISTERED);
    assertThat(profile.getBlockscoreIdVerificationStatus()).isEqualTo(BlockscoreIdVerificationStatus.UNVERIFIED);
    assertThat(profile.getDemographicSurveyCompletionTime()).isNull();
    assertThat(profile.getTermsOfServiceCompletionTime()).isEqualTo(NOW.toEpochMilli());
    assertThat(profile.getEthicsTrainingCompletionTime()).isNull();
}
Also used : Profile(org.pmiops.workbench.model.Profile) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 15 with Profile

use of org.pmiops.workbench.model.Profile in project workbench by all-of-us.

the class ProfileControllerTest method testSubmitIdVerification_success.

@Test
public void testSubmitIdVerification_success() throws Exception {
    createUser();
    when(blockscoreService.createPerson(eq("Bob"), eq(null), any(Address.class), eq(null), eq(null), eq(null))).thenReturn(person);
    when(person.getId()).thenReturn("id");
    when(person.isValid()).thenReturn(true);
    Profile profile = profileController.submitIdVerification(idVerificationRequest).getBody();
    assertThat(profile.getDataAccessLevel()).isEqualTo(DataAccessLevel.UNREGISTERED);
    assertThat(profile.getBlockscoreIdVerificationStatus()).isEqualTo(BlockscoreIdVerificationStatus.VERIFIED);
    assertThat(profile.getDemographicSurveyCompletionTime()).isNull();
    assertThat(profile.getTermsOfServiceCompletionTime()).isNull();
    assertThat(profile.getEthicsTrainingCompletionTime()).isNull();
}
Also used : Address(com.blockscore.models.Address) Profile(org.pmiops.workbench.model.Profile) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

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