Search in sources :

Example 26 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class GroupAddMemberOperationTest method testInvokeWhenResultHasMissingUser.

@Test
public void testInvokeWhenResultHasMissingUser() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    Group group = new Group();
    group.setMemberUser(List.of("user1"));
    rpcResponse.setResult(group);
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    GroupAddMemberOperation.create(GROUP_NAME, USERS, warnings::put).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("group_add_member"), anyList(), any(), any());
    assertEquals(1, warnings.size());
}
Also used : Group(com.sequenceiq.freeipa.client.model.Group) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 27 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class GroupAddOperationTest method testInvoke.

@Test
public void testInvoke() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    rpcResponse.setResult(new Group());
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    GroupAddOperation.create(GROUP_NAME, POSIX, warnings::put).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("group_add"), anyList(), any(), any());
}
Also used : Group(com.sequenceiq.freeipa.client.model.Group) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 28 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class GroupAddOperationTest method testInvokePosix.

@Test
public void testInvokePosix() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    rpcResponse.setResult(new Group());
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    GroupAddOperation.create(GROUP_NAME, POSIX, warnings::put).invoke(freeIpaClient);
    ArgumentCaptor<Map<String, Object>> paramCaptor = ArgumentCaptor.forClass(Map.class);
    verify(freeIpaClient).invoke(eq("group_add"), anyList(), paramCaptor.capture(), any());
    Map<String, Object> params = paramCaptor.getValue();
    assertTrue(!params.containsKey("nonposix"));
}
Also used : Group(com.sequenceiq.freeipa.client.model.Group) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 29 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class GroupRemoveMemberOperationTest method testInvokeWhenResultStillHasUser.

@Test
public void testInvokeWhenResultStillHasUser() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    Group group = new Group();
    group.setMemberUser(List.of("user1"));
    rpcResponse.setResult(group);
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    GroupRemoveMemberOperation.create(GROUP_NAME, USERS, warnings::put).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("group_remove_member"), anyList(), any(), any());
    assertEquals(1, warnings.size());
}
Also used : Group(com.sequenceiq.freeipa.client.model.Group) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 30 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class SudoCommandAddOperationTest method testInvoke.

@Test
public void testInvoke() throws FreeIpaClientException {
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    rpcResponse.setResult(new SudoCommand());
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    SudoCommandAddOperation.create(NAME).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("sudocmd_add"), argThat(argument -> argument.contains(NAME) && argument.size() == 1), argThat(argument -> argument.isEmpty()), eq(SudoCommand.class));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Mockito.when(org.mockito.Mockito.when) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) SudoCommand(com.sequenceiq.freeipa.client.model.SudoCommand) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) SudoCommand(com.sequenceiq.freeipa.client.model.SudoCommand) Test(org.junit.jupiter.api.Test)

Aggregations

RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)43 Test (org.junit.jupiter.api.Test)31 Map (java.util.Map)17 Group (com.sequenceiq.freeipa.client.model.Group)12 User (com.sequenceiq.freeipa.client.model.User)10 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)9 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)9 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)9 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)9 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)9 Mock (org.mockito.Mock)9 Mockito.verify (org.mockito.Mockito.verify)9 Mockito.when (org.mockito.Mockito.when)9 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)9 RPCMessage (com.sequenceiq.cloudbreak.client.RPCMessage)8 List (java.util.List)8 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)7 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)7 SudoRule (com.sequenceiq.freeipa.client.model.SudoRule)6 FmsUser (com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser)6