use of com.sequenceiq.freeipa.client.model.Role in project cloudbreak by hortonworks.
the class RoleAddMemberResponse method handleInternal.
@Override
protected Role handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
Role role = new Role();
role.setCn("roleName");
role.setMemberUser(List.of());
role.setMemberGroup(List.of());
role.setMemberHost(List.of());
role.setMemberHostGroup(List.of());
role.setMemberService(List.of());
return role;
}
use of com.sequenceiq.freeipa.client.model.Role in project cloudbreak by hortonworks.
the class RoleFindResponse method handleInternal.
@Override
protected Set<Role> handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
Role role = new Role();
role.setCn("roleName");
role.setMemberUser(List.of());
role.setMemberGroup(List.of());
role.setMemberHost(List.of());
role.setMemberHostGroup(List.of());
role.setMemberService(List.of());
return Set.of(role);
}
use of com.sequenceiq.freeipa.client.model.Role in project cloudbreak by hortonworks.
the class KerberosMgmtRoleComponentV1Test method testAddRoleAndPrivilegesForHostWithRoleRaceCondition.
@Test
public void testAddRoleAndPrivilegesForHostWithRoleRaceCondition() throws Exception {
Host host = new Host();
host.setFqdn(HOST);
RoleRequest roleRequest = new RoleRequest();
roleRequest.setRoleName(ROLE);
Set<String> privileges = new HashSet<>();
privileges.add(PRIVILEGE1);
privileges.add(PRIVILEGE2);
roleRequest.setPrivileges(privileges);
Role role = new Role();
role.setCn(ROLE);
Mockito.when(mockIpaClient.addRole(anyString())).thenThrow(new FreeIpaClientException("duplicate", new JsonRpcClientException(FreeIpaErrorCodes.DUPLICATE_ENTRY.getValue(), "duplicate", null)));
Privilege privilege = new Privilege();
Set<String> hosts = new HashSet<>();
hosts.add(HOST);
Set<String> noServices = new HashSet<>();
Mockito.when(mockIpaClient.showRole(roleRequest.getRoleName())).thenThrow(new FreeIpaClientException("notfound", new JsonRpcClientException(NOT_FOUND, "notfound", null))).thenReturn(role);
Mockito.when(mockIpaClient.showPrivilege(any())).thenReturn(privilege);
Mockito.when(mockIpaClient.addRolePrivileges(any(), any())).thenReturn(role);
Mockito.when(mockIpaClient.addRoleMember(any(), any(), any(), any(), any(), any())).thenReturn(role);
underTest.addRoleAndPrivileges(Optional.empty(), Optional.of(host), roleRequest, mockIpaClient);
Mockito.verify(mockIpaClient).addRole(ROLE);
Mockito.verify(mockIpaClient).addRolePrivileges(ROLE, privileges);
Mockito.verify(mockIpaClient).addRoleMember(ROLE, null, null, hosts, null, noServices);
}
use of com.sequenceiq.freeipa.client.model.Role in project cloudbreak by hortonworks.
the class KerberosMgmtRoleComponentV1Test method testAddRoleAndPrivilegesForHostWithRoleThatAlreadyExists.
@Test
public void testAddRoleAndPrivilegesForHostWithRoleThatAlreadyExists() throws Exception {
Host host = new Host();
host.setFqdn(HOST);
RoleRequest roleRequest = new RoleRequest();
roleRequest.setRoleName(ROLE);
Set<String> privileges = new HashSet<>();
privileges.add(PRIVILEGE1);
privileges.add(PRIVILEGE2);
roleRequest.setPrivileges(privileges);
Role role = new Role();
role.setCn(ROLE);
Privilege privilege = new Privilege();
Set<String> hosts = new HashSet<>();
hosts.add(HOST);
Set<String> noServices = new HashSet<>();
Mockito.when(mockIpaClient.showPrivilege(any())).thenReturn(privilege);
Mockito.when(mockIpaClient.addRolePrivileges(any(), any())).thenReturn(role);
Mockito.when(mockIpaClient.showRole(anyString())).thenReturn(role);
Mockito.when(mockIpaClient.addRoleMember(any(), any(), any(), any(), any(), any())).thenReturn(role);
underTest.addRoleAndPrivileges(Optional.empty(), Optional.of(host), roleRequest, mockIpaClient);
Mockito.verify(mockIpaClient).addRolePrivileges(ROLE, privileges);
Mockito.verify(mockIpaClient).addRoleMember(ROLE, null, null, hosts, null, noServices);
}
use of com.sequenceiq.freeipa.client.model.Role in project cloudbreak by hortonworks.
the class KerberosMgmtRoleComponentV1Test method testDeleteRoleIfNoLongerUsedWhenRoleIsStillUsedAsMemberService.
@Test
public void testDeleteRoleIfNoLongerUsedWhenRoleIsStillUsedAsMemberService() throws Exception {
Role role = new Role();
role.setCn(ROLE);
List<String> services = new ArrayList<>();
services.add(SERVICE);
role.setMemberService(services);
Mockito.when(mockIpaClient.showRole(anyString())).thenReturn(role);
underTest.deleteRoleIfItIsNoLongerUsed(ROLE, mockIpaClient);
Mockito.verify(mockIpaClient, Mockito.never()).deleteRole(ROLE);
}
Aggregations