use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse in project cloudbreak by hortonworks.
the class MockUserManagementServiceTest method getAccountTestIncludesFixedEntitlements.
@Test
void getAccountTestIncludesFixedEntitlements() {
ReflectionTestUtils.setField(underTest, "cbLicense", VALID_LICENSE);
underTest.initializeWorkloadPasswordPolicy();
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();
List<String> entitlements = account.getEntitlementsList().stream().map(Entitlement::getEntitlementName).collect(Collectors.toList());
assertThat(entitlements).contains("CDP_AZURE", "CDP_GCP", "CDP_AUTOMATIC_USERSYNC_POLLER", "CLOUDERA_INTERNAL_ACCOUNT", "DATAHUB_AZURE_AUTOSCALING", "DATAHUB_AWS_AUTOSCALING", "DATAHUB_GCP_AUTOSCALING", "LOCAL_DEV", "DATAHUB_FLOW_SCALING", "DATAHUB_STREAMING_SCALING", "CDP_CM_ADMIN_CREDENTIALS");
}
use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse in project cloudbreak by hortonworks.
the class MockUserManagementServiceTest method getAccountTestIncludesConditionalEntitlement.
@ParameterizedTest(name = "{0}")
@MethodSource("conditionalEntitlementDataProvider")
void getAccountTestIncludesConditionalEntitlement(String testCaseName, String conditionFieldName, boolean condition, String entitlementName, boolean entitlementPresentExpected) {
ReflectionTestUtils.setField(underTest, "cbLicense", VALID_LICENSE);
underTest.initializeWorkloadPasswordPolicy();
ReflectionTestUtils.setField(underTest, conditionFieldName, condition);
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();
List<String> entitlements = account.getEntitlementsList().stream().map(Entitlement::getEntitlementName).collect(Collectors.toList());
if (entitlementPresentExpected) {
assertThat(entitlements).contains(entitlementName);
} else {
assertThat(entitlements).doesNotContain(entitlementName);
}
}
use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse 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.GetAccountResponse 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