Search in sources :

Example 1 with Acl

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);
}
Also used : AclBindingFilter(org.apache.kafka.common.acl.AclBindingFilter) ResourcePatternFilter(org.apache.kafka.common.resource.ResourcePatternFilter) Acl(io.confluent.kafkarest.entities.Acl) AccessControlEntryFilter(org.apache.kafka.common.acl.AccessControlEntryFilter) Test(org.junit.jupiter.api.Test)

Example 2 with Acl

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);
}
Also used : AclBindingFilter(org.apache.kafka.common.acl.AclBindingFilter) ResourcePatternFilter(org.apache.kafka.common.resource.ResourcePatternFilter) Acl(io.confluent.kafkarest.entities.Acl) AccessControlEntryFilter(org.apache.kafka.common.acl.AccessControlEntryFilter) Test(org.junit.jupiter.api.Test)

Aggregations

Acl (io.confluent.kafkarest.entities.Acl)2 AccessControlEntryFilter (org.apache.kafka.common.acl.AccessControlEntryFilter)2 AclBindingFilter (org.apache.kafka.common.acl.AclBindingFilter)2 ResourcePatternFilter (org.apache.kafka.common.resource.ResourcePatternFilter)2 Test (org.junit.jupiter.api.Test)2