use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account in project cloudbreak by hortonworks.
the class MockUserManagementServiceTest method testGetAccountIncludesPasswordPolicy.
@Test
public void testGetAccountIncludesPasswordPolicy() throws IOException {
Path licenseFilePath = Files.createTempFile("license", "txt");
Files.writeString(licenseFilePath, VALID_LICENSE);
ReflectionTestUtils.setField(underTest, "cmLicenseFilePath", licenseFilePath.toString());
try {
underTest.init();
GetAccountRequest req = GetAccountRequest.getDefaultInstance();
StreamRecorder<GetAccountResponse> observer = StreamRecorder.create();
underTest.getAccount(req, observer);
assertThat(observer.getValues().size()).isEqualTo(1);
GetAccountResponse res = observer.getValues().get(0);
assertThat(res.hasAccount()).isTrue();
Account account = res.getAccount();
assertThat(account.hasGlobalPasswordPolicy()).isTrue();
WorkloadPasswordPolicy passwordPolicy = account.getGlobalPasswordPolicy();
assertThat(passwordPolicy.getWorkloadPasswordMaxLifetime()).isEqualTo(MockUserManagementService.PASSWORD_LIFETIME);
} finally {
Files.delete(licenseFilePath);
}
}
use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account in project cloudbreak by hortonworks.
the class MockUserManagementServiceTest method getAccountTestIncludesIds.
@Test
void getAccountTestIncludesIds() {
ReflectionTestUtils.setField(underTest, "cbLicense", VALID_LICENSE);
underTest.initializeWorkloadPasswordPolicy();
GetAccountRequest req = GetAccountRequest.newBuilder().setAccountId(ACCOUNT_ID).build();
StreamRecorder<GetAccountResponse> observer = StreamRecorder.create();
underTest.getAccount(req, observer);
assertThat(observer.getValues().size()).isEqualTo(1);
GetAccountResponse res = observer.getValues().get(0);
assertThat(res.hasAccount()).isTrue();
Account account = res.getAccount();
assertThat(account.getAccountId()).isEqualTo(ACCOUNT_ID);
assertThat(account.getExternalAccountId()).isEqualTo("external-" + ACCOUNT_ID);
}
Aggregations