Search in sources :

Example 11 with Group

use of com.sequenceiq.freeipa.client.model.Group 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 12 with Group

use of com.sequenceiq.freeipa.client.model.Group 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 13 with Group

use of com.sequenceiq.freeipa.client.model.Group 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 14 with Group

use of com.sequenceiq.freeipa.client.model.Group 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 15 with Group

use of com.sequenceiq.freeipa.client.model.Group in project cloudbreak by hortonworks.

the class UserSyncOperationsTest method testRemoveGroupsSingle.

@Test
public void testRemoveGroupsSingle() throws FreeIpaClientException, TimeoutException {
    Multimap<String, String> warnings = ArrayListMultimap.create();
    Set<FmsGroup> groups = Set.of(new FmsGroup().withName("group1"), new FmsGroup().withName("group2"));
    ArgumentCaptor<List<Object>> flagsCaptor = ArgumentCaptor.forClass(List.class);
    ArgumentCaptor<Map<String, Object>> paramsCaptor = ArgumentCaptor.forClass(Map.class);
    RPCResponse<Object> response1 = new RPCResponse<>();
    response1.setResult(new Group());
    RPCResponse<Object> response2 = new RPCResponse<>();
    response2.setResult(new Group());
    when(freeIpaClient.invoke(eq("group_del"), flagsCaptor.capture(), paramsCaptor.capture(), eq(Group.class))).thenReturn(response1, response2);
    underTest.removeGroups(false, freeIpaClient, groups, warnings::put);
    assertTrue(warnings.isEmpty());
    verifyNoInteractions(batchPartitionSizeProperties);
    verify(freeIpaClient, never()).callBatch(any(), any(), any(), any(), any());
    List<List<Object>> flagsList = flagsCaptor.getAllValues();
    assertThat(flagsList, allOf(hasItem(hasItem("group1")), hasItem(hasItem("group2"))));
    List<Map<String, Object>> paramsList = paramsCaptor.getAllValues();
    assertThat(paramsList, everyItem(aMapWithSize(0)));
    verify(interruptChecker, times(4)).throwTimeoutExIfInterrupted();
}
Also used : FmsGroup(com.sequenceiq.freeipa.service.freeipa.user.model.FmsGroup) Group(com.sequenceiq.freeipa.client.model.Group) FmsGroup(com.sequenceiq.freeipa.service.freeipa.user.model.FmsGroup) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) List(java.util.List) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

Group (com.sequenceiq.freeipa.client.model.Group)21 Test (org.junit.jupiter.api.Test)14 RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)12 Map (java.util.Map)12 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)5 FmsGroup (com.sequenceiq.freeipa.service.freeipa.user.model.FmsGroup)4 List (java.util.List)4 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)3 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)2 FreeIpaErrorCodes (com.sequenceiq.freeipa.client.FreeIpaErrorCodes)2 SudoRule (com.sequenceiq.freeipa.client.model.SudoRule)2 User (com.sequenceiq.freeipa.client.model.User)2 BatchPartitionSizeProperties (com.sequenceiq.freeipa.configuration.BatchPartitionSizeProperties)2 FmsUser (com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser)2 ThreadInterruptChecker (com.sequenceiq.freeipa.util.ThreadInterruptChecker)2 Collection (java.util.Collection)2 Set (java.util.Set)2