use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyDefinition in project cloudbreak by hortonworks.
the class MockUserManagementService method buildGetRightsResponse.
private GetRightsResponse buildGetRightsResponse(String accountId) {
List<Group> workloadGroups = List.copyOf(mockGroupManagementService.getOrCreateWorkloadGroups(accountId));
List<Group> userGroups = List.copyOf(mockGroupManagementService.getOrCreateUserGroups(accountId));
PolicyStatement policyStatement = PolicyStatement.newBuilder().addRight(ALL_RIGHTS_AND_RESOURCES).addResource(ALL_RIGHTS_AND_RESOURCES).build();
PolicyDefinition policyDefinition = PolicyDefinition.newBuilder().addStatement(policyStatement).build();
Policy powerUserPolicy = Policy.newBuilder().setCrn(mockCrnService.createCrn(ACCOUNT_ID_ALTUS, CrnResourceDescriptor.POLICY, "PowerUserPolicy").toString()).setCreationDateMs(CREATION_DATE_MS).setPolicyDefinition(policyDefinition).build();
Role powerUserRole = Role.newBuilder().setCrn("crn:altus:iam:us-west-1:altus:role:PowerUser").setCreationDateMs(CREATION_DATE_MS).addPolicy(powerUserPolicy).build();
RoleAssignment roleAssignment = RoleAssignment.newBuilder().setRole(powerUserRole).build();
GetRightsResponse.Builder rightsBuilder = GetRightsResponse.newBuilder().addRoleAssignment(roleAssignment);
workloadGroups.forEach(group -> rightsBuilder.addGroupCrn(group.getCrn()));
userGroups.forEach(group -> rightsBuilder.addGroupCrn(group.getCrn()));
return rightsBuilder.build();
}
Aggregations