use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class WorkloadCredentialServiceTest method testSetWorkloadCredentialWhenThereAreNoModifications.
@Test
void testSetWorkloadCredentialWhenThereAreNoModifications() throws Exception {
when(freeIpaClient.formatDate(any(Optional.class))).thenReturn(FreeIpaClient.MAX_PASSWORD_EXPIRATION_DATETIME);
when(freeIpaClient.invoke(any(), any(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(4202, "", null)));
underTest.setWorkloadCredential(false, freeIpaClient, new WorkloadCredentialUpdate(USER, USER_CRN, createWorkloadCredential()));
verify(freeIpaClient).invoke(eq("user_mod"), eq(List.of(USER)), any(), any());
verifyNoInteractions(interruptChecker);
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class WorkloadCredentialServiceTest method testSingleSetWorkloadCredentialsWhenErrorOccurs.
@Test
void testSingleSetWorkloadCredentialsWhenErrorOccurs() throws Exception {
Multimap<String, String> warnings = ArrayListMultimap.create();
when(freeIpaClient.invoke(any(), any(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(5000, "", null)));
setWorkloadCredentials(false, false, freeIpaClient, getCredentialMap(), getUsersWithCredentialsToUpdate(), getUserToCrnMap(), warnings::put);
verify(freeIpaClient, times(4)).invoke(eq("user_mod"), any(), any(), any());
assertEquals(4, warnings.size());
verify(interruptChecker, times(4)).throwTimeoutExIfInterrupted();
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class WorkloadCredentialServiceTest method testSingleSetWorkloadCredentialsWhenThereAreNoModifications.
@Test
void testSingleSetWorkloadCredentialsWhenThereAreNoModifications() throws Exception {
Multimap<String, String> warnings = ArrayListMultimap.create();
when(freeIpaClient.invoke(any(), any(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(4202, "", null)));
setWorkloadCredentials(false, false, freeIpaClient, getCredentialMap(), getUsersWithCredentialsToUpdate(), getUserToCrnMap(), warnings::put);
verify(freeIpaClient, times(4)).invoke(eq("user_mod"), any(), any(), any());
assertEquals(0, warnings.size());
verify(interruptChecker, times(4)).throwTimeoutExIfInterrupted();
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class KerberosMgmtRoleComponentV1Test method testAddRoleAndPrivilegesForServiceWithRole.
@Test
public void testAddRoleAndPrivilegesForServiceWithRole() throws Exception {
Service service = new Service();
service.setKrbprincipalname(List.of(SERVICE));
service.setKrbcanonicalname(SERVICE);
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())).thenReturn(role);
Privilege privilege = new Privilege();
Set<String> noHosts = new HashSet<>();
Set<String> services = new HashSet<>();
services.add(SERVICE);
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.of(service), Optional.empty(), roleRequest, mockIpaClient);
Mockito.verify(mockIpaClient).addRole(ROLE);
Mockito.verify(mockIpaClient).addRolePrivileges(ROLE, privileges);
Mockito.verify(mockIpaClient).addRoleMember(ROLE, null, null, noHosts, null, services);
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class KerberosMgmtRoleComponentV1Test method testPrivilegeExistReturnFalse.
@Test
public void testPrivilegeExistReturnFalse() throws Exception {
RoleRequest roleRequest = new RoleRequest();
roleRequest.setRoleName(ROLE);
Set<String> privileges = new HashSet<>();
privileges.add(PRIVILEGE1);
privileges.add(PRIVILEGE2);
roleRequest.setPrivileges(privileges);
Mockito.when(mockIpaClient.showPrivilege(any())).thenThrow(new FreeIpaClientException(ERROR_MESSAGE, new JsonRpcClientException(NOT_FOUND, ERROR_MESSAGE, null)));
Assertions.assertFalse(underTest.privilegesExist(roleRequest, mockIpaClient));
}
Aggregations