use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group in project cloudbreak by hortonworks.
the class MockUserManagementService method listWorkloadAdministrationGroups.
@Override
public void listWorkloadAdministrationGroups(ListWorkloadAdministrationGroupsRequest request, StreamObserver<ListWorkloadAdministrationGroupsResponse> responseObserver) {
mockCrnService.ensureInternalActor();
String accountId = request.getAccountId();
LOGGER.info("List workload administration groups: {}", accountId);
ListWorkloadAdministrationGroupsResponse.Builder responseBuilder = ListWorkloadAdministrationGroupsResponse.newBuilder();
for (UmsVirtualGroupRight right : UmsVirtualGroupRight.values()) {
Group group = mockGroupManagementService.createGroup(accountId, mockGroupManagementService.generateWorkloadGroupName(right.getRight()));
responseBuilder.addWorkloadAdministrationGroup(WorkloadAdministrationGroup.newBuilder().setWorkloadAdministrationGroupName(group.getGroupName()).setRightName(right.getRight()).setResource(MOCK_RESOURCE).build());
}
responseObserver.onNext(responseBuilder.build());
responseObserver.onCompleted();
}
use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group 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();
}
use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group in project cloudbreak by hortonworks.
the class MockGroupManagementService method createWorkloadGroups.
private Map<String, Group> createWorkloadGroups(String accountId) {
Map<String, Group> groups = new HashMap<>();
for (UmsVirtualGroupRight right : UmsVirtualGroupRight.values()) {
Group group = createGroup(accountId, generateWorkloadGroupName(right.getRight()));
groups.put(group.getCrn(), group);
}
LOGGER.info("workload groups for user: {}", groups);
return groups;
}
Aggregations