use of io.confluent.kafkarest.entities.Acl in project kafka-rest by confluentinc.
the class AclManagerImplTest method searchAcls_returnsMatchedAcls.
@Test
public void searchAcls_returnsMatchedAcls() throws Exception {
expect(clusterManager.getCluster(CLUSTER_ID)).andReturn(completedFuture(Optional.of(Cluster.create(CLUSTER_ID, /* controller= */
null, emptyList()))));
expect(adminClient.describeAcls(new AclBindingFilter(new ResourcePatternFilter(ResourceType.ANY, /* name= */
null, PatternType.ANY), new AccessControlEntryFilter(/* principal= */
null, /* host= */
null, AclOperation.ANY, AclPermissionType.ANY)))).andReturn(describeAclsResult);
expect(describeAclsResult.values()).andReturn(KafkaFuture.completedFuture(Arrays.asList(ACL_BINDING_1, ACL_BINDING_2)));
replay(clusterManager, adminClient, describeAclsResult);
List<Acl> acls = aclManager.searchAcls(CLUSTER_ID, Acl.ResourceType.ANY, /* resourceName= */
null, Acl.PatternType.ANY, /* principal= */
null, /* host= */
null, Acl.Operation.ANY, Acl.Permission.ANY).get();
assertEquals(Arrays.asList(ACL_1, ACL_2), acls);
}
use of io.confluent.kafkarest.entities.Acl in project kafka-rest by confluentinc.
the class AclManagerImplTest method deleteAcls_deletesAndReturnsMatchedAcls.
@Test
public void deleteAcls_deletesAndReturnsMatchedAcls() throws Exception {
AclBindingFilter aclBindingFilter = new AclBindingFilter(new ResourcePatternFilter(ResourceType.ANY, /* name= */
null, PatternType.ANY), new AccessControlEntryFilter(/* principal= */
null, /* host= */
null, AclOperation.ANY, AclPermissionType.ANY));
expect(clusterManager.getCluster(CLUSTER_ID)).andReturn(completedFuture(Optional.of(Cluster.create(CLUSTER_ID, /* controller= */
null, emptyList()))));
expect(adminClient.deleteAcls(singletonList(aclBindingFilter))).andReturn(deleteAclsResult);
expect(deleteAclsResult.values()).andReturn(singletonMap(aclBindingFilter, KafkaFuture.completedFuture(deleteFilterResults)));
expect(deleteFilterResults.values()).andReturn(Arrays.asList(deleteFilterResult1, deleteFilterResult2));
expect(deleteFilterResult1.binding()).andReturn(ACL_BINDING_1);
expect(deleteFilterResult2.binding()).andReturn(ACL_BINDING_2);
replay(clusterManager, adminClient, deleteAclsResult, deleteFilterResults, deleteFilterResult1, deleteFilterResult2);
List<Acl> acls = aclManager.deleteAcls(CLUSTER_ID, Acl.ResourceType.ANY, /* resourceName= */
null, Acl.PatternType.ANY, /* principal= */
null, /* host= */
null, Acl.Operation.ANY, Acl.Permission.ANY).get();
assertEquals(Arrays.asList(ACL_1, ACL_2), acls);
}
Aggregations