Search in sources :

Example 1 with WorkloadPasswordPolicy

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadPasswordPolicy 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);
    }
}
Also used : Path(java.nio.file.Path) GetAccountResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse) Account(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account) WorkloadPasswordPolicy(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadPasswordPolicy) GetAccountRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Account (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account)1 GetAccountRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountRequest)1 GetAccountResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse)1 WorkloadPasswordPolicy (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadPasswordPolicy)1 Path (java.nio.file.Path)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1