use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClusterConfigResourceTest method getClusterConfig_existingConfig_returnsConfig.
@Test
public void getClusterConfig_existingConfig_returnsConfig() {
expect(clusterConfigManager.getClusterConfig(CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName())).andReturn(completedFuture(Optional.of(CONFIG_1)));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clusterConfigsResource.getClusterConfig(response, CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName());
GetClusterConfigResponse expected = GetClusterConfigResponse.create(ClusterConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/broker-configs/config-1").setResourceName("crn:///kafka=cluster-1/broker-config=config-1").build()).setClusterId(CLUSTER_ID).setConfigType(ClusterConfig.Type.BROKER).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());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class ClusterConfigResourceTest method resetClusterConfig_existingConfig_resetsConfig.
@Test
public void resetClusterConfig_existingConfig_resetsConfig() {
expect(clusterConfigManager.deleteClusterConfig(CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName())).andReturn(completedFuture(null));
replay(clusterConfigManager);
FakeAsyncResponse response = new FakeAsyncResponse();
clusterConfigsResource.deleteClusterConfig(response, CLUSTER_ID, ClusterConfig.Type.BROKER, CONFIG_1.getName());
assertNull(response.getValue());
assertNull(response.getException());
assertTrue(response.isDone());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AclsResourceTest method deleteAcl_deletesAndReturnsMatchedAcls.
@Test
public void deleteAcl_deletesAndReturnsMatchedAcls() {
expect(aclManager.deleteAcls(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.deleteAcls(response, CLUSTER_ID, Acl.ResourceType.TOPIC, /* resourceName= */
"topic-1", Acl.PatternType.MATCH, /* principal= */
"", /* host= */
"", Acl.Operation.ANY, Acl.Permission.ALLOW);
DeleteAclsResponse expected = DeleteAclsResponse.create(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()));
assertEquals(expected, response.getValue());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AclsResourceTest method createAcl_createsAcl.
@Test
public void createAcl_createsAcl() {
expect(aclManager.createAcl(CLUSTER_ID, Acl.ResourceType.TOPIC, /* resourceName= */
"*", Acl.PatternType.LITERAL, /* principal= */
"User:alice", /* host= */
"*", Acl.Operation.READ, Acl.Permission.ALLOW)).andReturn(completedFuture(/* value= */
null));
replay(aclManager);
FakeAsyncResponse response = new FakeAsyncResponse();
aclsResource.createAcl(response, CLUSTER_ID, CreateAclRequest.builder().setResourceType(Acl.ResourceType.TOPIC).setResourceName("*").setPatternType(Acl.PatternType.LITERAL).setPrincipal("User:alice").setHost("*").setOperation(Acl.Operation.READ).setPermission(Acl.Permission.ALLOW).build());
assertNull(response.getValue());
assertNull(response.getException());
}
use of io.confluent.kafkarest.response.FakeAsyncResponse in project kafka-rest by confluentinc.
the class AlterClusterConfigBatchActionTest method alterClusterConfigs_existingConfig_alterConfigs.
@Test
public void alterClusterConfigs_existingConfig_alterConfigs() {
expect(clusterConfigManager.alterClusterConfigs(CLUSTER_ID, ClusterConfig.Type.BROKER, Arrays.asList(AlterConfigCommand.set(CONFIG_1.getName(), "newValue"), AlterConfigCommand.delete(CONFIG_2.getName())))).andReturn(completedFuture(null));
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()))));
assertNull(response.getValue());
assertNull(response.getException());
assertTrue(response.isDone());
}
Aggregations