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());
}
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());
}
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"));
}
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());
}
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();
}
Aggregations