Search in sources :

Example 1 with ApiException

use of org.pmiops.workbench.captcha.ApiException in project workbench by all-of-us.

the class ProfileControllerTest method setUp.

@BeforeEach
@Override
public void setUp() throws IOException {
    super.setUp();
    config.googleDirectoryService.gSuiteDomain = GSUITE_DOMAIN;
    // key UserService logic depends on the existence of the Registered Tier
    registeredTier = TestMockFactory.createRegisteredTierForTests(accessTierDao);
    rtAddressesConfig = new InstitutionTierConfig().membershipRequirement(InstitutionMembershipRequirement.ADDRESSES).eraRequired(false).accessTierShortName(registeredTier.getShortName());
    rtDomainsConfig = new InstitutionTierConfig().membershipRequirement(InstitutionMembershipRequirement.DOMAINS).eraRequired(false).accessTierShortName(registeredTier.getShortName());
    Profile profile = new Profile();
    profile.setContactEmail(CONTACT_EMAIL);
    profile.setFamilyName(FAMILY_NAME);
    profile.setGivenName(GIVEN_NAME);
    profile.setUsername(USER_PREFIX);
    profile.setAreaOfResearch(RESEARCH_PURPOSE);
    profile.setAddress(new Address().streetAddress1(STREET_ADDRESS).city(CITY).state(STATE).country(COUNTRY).zipCode(ZIP_CODE));
    createAccountRequest = new CreateAccountRequest();
    createAccountRequest.setTermsOfServiceVersion(LATEST_AOU_TOS_VERSION);
    createAccountRequest.setProfile(profile);
    createAccountRequest.setCaptchaVerificationToken(CAPTCHA_TOKEN);
    googleUser = new User();
    googleUser.setPrimaryEmail(FULL_USER_NAME);
    googleUser.setChangePasswordAtNextLogin(true);
    googleUser.setPassword("testPassword");
    googleUser.setIsEnrolledIn2Sv(true);
    config.access.currentDuccVersions = ImmutableList.of(CURRENT_DUCC_VERSION);
    when(mockDirectoryService.getUserOrThrow(FULL_USER_NAME)).thenReturn(googleUser);
    when(mockDirectoryService.createUser(GIVEN_NAME, FAMILY_NAME, FULL_USER_NAME, CONTACT_EMAIL)).thenReturn(googleUser);
    when(mockCloudStorageClient.getCaptchaServerKey()).thenReturn("Server_Key");
    try {
        when(mockCaptchaVerificationService.verifyCaptcha(CAPTCHA_TOKEN)).thenReturn(true);
        when(mockCaptchaVerificationService.verifyCaptcha(WRONG_CAPTCHA_TOKEN)).thenReturn(false);
        when(mockFireCloudService.getUserTermsOfServiceStatus()).thenReturn(true);
    } catch (ApiException | org.pmiops.workbench.firecloud.ApiException e) {
        e.printStackTrace();
    }
    accessModules = TestMockFactory.createAccessModules(accessModuleDao);
}
Also used : InstitutionTierConfig(org.pmiops.workbench.model.InstitutionTierConfig) CreateAccountRequest(org.pmiops.workbench.model.CreateAccountRequest) DbUser(org.pmiops.workbench.db.model.DbUser) User(com.google.api.services.directory.model.User) Address(org.pmiops.workbench.model.Address) Profile(org.pmiops.workbench.model.Profile) ApiException(org.pmiops.workbench.captcha.ApiException) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

User (com.google.api.services.directory.model.User)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ApiException (org.pmiops.workbench.captcha.ApiException)1 DbUser (org.pmiops.workbench.db.model.DbUser)1 Address (org.pmiops.workbench.model.Address)1 CreateAccountRequest (org.pmiops.workbench.model.CreateAccountRequest)1 InstitutionTierConfig (org.pmiops.workbench.model.InstitutionTierConfig)1 Profile (org.pmiops.workbench.model.Profile)1