Search in sources :

Example 1 with DescribeAclsResponse

use of org.apache.kafka.common.requests.DescribeAclsResponse in project apache-kafka-on-k8s by banzaicloud.

the class KafkaAdminClientTest method testDescribeAcls.

@Test
public void testDescribeAcls() throws Exception {
    try (AdminClientUnitTestEnv env = mockClientEnv()) {
        env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
        env.kafkaClient().prepareMetadataUpdate(env.cluster(), Collections.<String>emptySet());
        env.kafkaClient().setNode(env.cluster().controller());
        // Test a call where we get back ACL1 and ACL2.
        env.kafkaClient().prepareResponse(new DescribeAclsResponse(0, ApiError.NONE, asList(ACL1, ACL2)));
        assertCollectionIs(env.adminClient().describeAcls(FILTER1).values().get(), ACL1, ACL2);
        // Test a call where we get back no results.
        env.kafkaClient().prepareResponse(new DescribeAclsResponse(0, ApiError.NONE, Collections.<AclBinding>emptySet()));
        assertTrue(env.adminClient().describeAcls(FILTER2).values().get().isEmpty());
        // Test a call where we get back an error.
        env.kafkaClient().prepareResponse(new DescribeAclsResponse(0, new ApiError(Errors.SECURITY_DISABLED, "Security is disabled"), Collections.<AclBinding>emptySet()));
        assertFutureError(env.adminClient().describeAcls(FILTER2).values(), SecurityDisabledException.class);
    }
}
Also used : DescribeAclsResponse(org.apache.kafka.common.requests.DescribeAclsResponse) AclBinding(org.apache.kafka.common.acl.AclBinding) ApiError(org.apache.kafka.common.requests.ApiError) Test(org.junit.Test)

Aggregations

AclBinding (org.apache.kafka.common.acl.AclBinding)1 ApiError (org.apache.kafka.common.requests.ApiError)1 DescribeAclsResponse (org.apache.kafka.common.requests.DescribeAclsResponse)1 Test (org.junit.Test)1