use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AclsResourceTest method searchAcls_returnsMatchedAcls.
@Test
public void searchAcls_returnsMatchedAcls() {
expect(aclManager.searchAcls(CLUSTER_ID, Acl.ResourceType.TOPIC, /* resourceName= */
"topic-1", Acl.PatternType.MATCH, /* principal= */
null, /* host= */
null, Acl.Operation.ANY, Acl.Permission.ALLOW)).andReturn(completedFuture(Arrays.asList(ACL_1, ACL_2)));
replay(aclManager);
FakeAsyncResponse response = new FakeAsyncResponse();
aclsResource.searchAcls(response, CLUSTER_ID, Acl.ResourceType.TOPIC, /* resourceName= */
"topic-1", Acl.PatternType.MATCH, /* principal= */
"", /* host= */
"", Acl.Operation.ANY, Acl.Permission.ALLOW);
SearchAclsResponse expected = SearchAclsResponse.create(AclDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters/cluster-1/acls" + "?resource_type=TOPIC" + "&resource_name=topic-1" + "&pattern_type=MATCH" + "&principal=" + "&host=" + "&operation=ANY" + "&permission=ALLOW").build()).setData(Arrays.asList(AclData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/acls" + "?resource_type=TOPIC" + "&resource_name=*" + "&pattern_type=LITERAL" + "&principal=User%3Aalice" + "&host=*" + "&operation=READ" + "&permission=ALLOW").build()).setClusterId(CLUSTER_ID).setResourceType(Acl.ResourceType.TOPIC).setResourceName("*").setPatternType(Acl.PatternType.LITERAL).setPrincipal("User:alice").setHost("*").setOperation(Acl.Operation.READ).setPermission(Acl.Permission.ALLOW).build(), AclData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/acls" + "?resource_type=TOPIC" + "&resource_name=topic-" + "&pattern_type=PREFIXED" + "&principal=User%3Abob" + "&host=1.2.3.4" + "&operation=WRITE" + "&permission=ALLOW").build()).setClusterId(CLUSTER_ID).setResourceType(Acl.ResourceType.TOPIC).setResourceName("topic-").setPatternType(Acl.PatternType.PREFIXED).setPrincipal("User:bob").setHost("1.2.3.4").setOperation(Acl.Operation.WRITE).setPermission(Acl.Permission.ALLOW).build())).build());
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AlterClusterConfigBatchActionTest method alterClusterConfigs_nonExistingCluster_throwsNotFound.
@Test
public void alterClusterConfigs_nonExistingCluster_throwsNotFound() {
expect(clusterConfigManager.alterClusterConfigs(CLUSTER_ID, ClusterConfig.Type.BROKER, Arrays.asList(AlterConfigCommand.set(CONFIG_1.getName(), "newValue"), AlterConfigCommand.delete(CONFIG_2.getName())))).andReturn(failedFuture(new NotFoundException()));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
alterClusterConfigBatchAction.alterClusterConfigBatch(response, CLUSTER_ID, ClusterConfig.Type.BROKER, AlterClusterConfigBatchRequest.create(AlterConfigBatchRequestData.create(Arrays.asList(AlterEntry.builder().setName(CONFIG_1.getName()).setValue("newValue").build(), AlterEntry.builder().setName(CONFIG_2.getName()).setOperation(AlterOperation.DELETE).build()))));
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class BrokerConfigResourceTest method resetBrokerConfig_nonExistingConfigOrBrokerOrCluster_throwsNotFound.
@Test
public void resetBrokerConfig_nonExistingConfigOrBrokerOrCluster_throwsNotFound() {
expect(brokerConfigManager.resetBrokerConfig(CLUSTER_ID, BROKER_ID, CONFIG_1.getName())).andReturn(failedFuture(new NotFoundException()));
replay(brokerConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
brokerConfigsResource.resetBrokerConfig(response, CLUSTER_ID, BROKER_ID, CONFIG_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class BrokerConfigResourceTest method getBrokerConfig_nonExistingBrokerorCluster_throwsNotFound.
@Test
public void getBrokerConfig_nonExistingBrokerorCluster_throwsNotFound() {
expect(brokerConfigManager.getBrokerConfig(CLUSTER_ID, BROKER_ID, CONFIG_1.getName())).andReturn(failedFuture(new NotFoundException()));
replay(brokerConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
brokerConfigsResource.getBrokerConfig(response, CLUSTER_ID, BROKER_ID, CONFIG_1.getName());
assertEquals(NotFoundException.class, response.getException().getClass());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class BrokerConfigResourceTest method getBrokerConfig_existingConfig_returnsConfig.
@Test
public void getBrokerConfig_existingConfig_returnsConfig() {
expect(brokerConfigManager.getBrokerConfig(CLUSTER_ID, BROKER_ID, CONFIG_1.getName())).andReturn(completedFuture(Optional.of(CONFIG_1)));
replay(brokerConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
brokerConfigsResource.getBrokerConfig(response, CLUSTER_ID, BROKER_ID, CONFIG_1.getName());
GetBrokerConfigResponse expected = GetBrokerConfigResponse.create(BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1/configs/config-1").setResourceName("crn:///kafka=cluster-1/broker=1/config=config-1").build()).setClusterId(CLUSTER_ID).setBrokerId(BROKER_ID).setName(CONFIG_1.getName()).setValue(CONFIG_1.getValue()).setDefault(CONFIG_1.isDefault()).setReadOnly(CONFIG_1.isReadOnly()).setSensitive(CONFIG_1.isSensitive()).setSource(CONFIG_1.getSource()).setSynonyms(CONFIG_1.getSynonyms().stream().map(ConfigSynonymData::fromConfigSynonym).collect(Collectors.toList())).build());
assertEquals(expected, response.getValue());
}
Aggregations