From 69574db8e83ae1378662acc1db925e6064d2b6fd Mon Sep 17 00:00:00 2001 From: "maciej.moscicki" Date: Thu, 22 Aug 2024 16:41:10 +0200 Subject: [PATCH 1/4] remove topic blacklist --- .../tech/hermes/api/BlacklistStatus.java | 40 ------- .../pl/allegro/tech/hermes/api/ErrorCode.java | 2 - .../zookeeper/ZookeeperPaths.java | 9 -- hermes-console/package.json | 4 +- .../BlacklistZookeeperNotifyingCache.java | 63 ----------- .../blacklist/TopicBlacklistCallback.java | 8 -- .../topic/NotificationBasedTopicsCache.java | 31 +---- .../config/FrontendConfiguration.java | 12 +- .../hermes/frontend/metric/CachedTopic.java | 14 --- .../publishing/handlers/TopicHandler.java | 12 -- .../management/api/BlacklistEndpoint.java | 86 -------------- .../config/storage/StorageConfiguration.java | 8 -- .../blacklist/NotUnblacklistedException.java | 22 ---- .../blacklist/TopicBlacklistRepository.java | 14 --- .../blacklist/TopicBlacklistService.java | 41 ------- .../AddTopicToBlacklistRepositoryCommand.java | 37 ------ ...veTopicFromBlacklistRepositoryCommand.java | 41 ------- .../management/domain/topic/TopicService.java | 8 +- .../ZookeeperTopicBlacklistRepository.java | 48 -------- .../zookeeper/ZookeeperRepositoryManager.java | 7 -- .../client/integration/HermesTestClient.java | 26 ----- .../integration/ManagementTestClient.java | 24 ---- .../integrationtests/TopicBlacklistTest.java | 106 ------------------ .../management/TopicManagementTest.java | 15 --- 24 files changed, 6 insertions(+), 672 deletions(-) delete mode 100644 hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java delete mode 100644 hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/BlacklistZookeeperNotifyingCache.java delete mode 100644 hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/TopicBlacklistCallback.java delete mode 100644 hermes-management/src/main/java/pl/allegro/tech/hermes/management/api/BlacklistEndpoint.java delete mode 100644 hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/NotUnblacklistedException.java delete mode 100644 hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistRepository.java delete mode 100644 hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistService.java delete mode 100644 hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/AddTopicToBlacklistRepositoryCommand.java delete mode 100644 hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/RemoveTopicFromBlacklistRepositoryCommand.java delete mode 100644 hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/blacklist/ZookeeperTopicBlacklistRepository.java delete mode 100644 integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/TopicBlacklistTest.java diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java deleted file mode 100644 index 8be8d8d53b..0000000000 --- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/BlacklistStatus.java +++ /dev/null @@ -1,40 +0,0 @@ -package pl.allegro.tech.hermes.api; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - -public final class BlacklistStatus { - - public static final BlacklistStatus BLACKLISTED = new BlacklistStatus(true); - public static final BlacklistStatus NOT_BLACKLISTED = new BlacklistStatus(false); - - private final boolean blacklisted; - - @JsonCreator - private BlacklistStatus(@JsonProperty("blacklisted") boolean blacklisted) { - this.blacklisted = blacklisted; - } - - public boolean isBlacklisted() { - return blacklisted; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BlacklistStatus that = (BlacklistStatus) o; - return blacklisted == that.blacklisted; - } - - @Override - public int hashCode() { - return Objects.hash(blacklisted); - } -} diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ErrorCode.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ErrorCode.java index 953e468f97..71a5391966 100644 --- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ErrorCode.java +++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/ErrorCode.java @@ -48,9 +48,7 @@ public enum ErrorCode { SUBSCRIPTION_ENDPOINT_ADDRESS_CHANGE_EXCEPTION(INTERNAL_SERVER_ERROR), OAUTH_PROVIDER_NOT_EXISTS(NOT_FOUND), OAUTH_PROVIDER_ALREADY_EXISTS(BAD_REQUEST), - TOPIC_BLACKLISTED(FORBIDDEN), THROUGHPUT_QUOTA_VIOLATION(429), - TOPIC_NOT_UNBLACKLISTED(BAD_REQUEST), TOPIC_CONSTRAINTS_ALREADY_EXIST(BAD_REQUEST), TOPIC_CONSTRAINTS_DO_NOT_EXIST(BAD_REQUEST), SUBSCRIPTION_CONSTRAINTS_ALREADY_EXIST(BAD_REQUEST), diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java index be3cb23393..15bdb45300 100644 --- a/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java +++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java @@ -23,7 +23,6 @@ public class ZookeeperPaths { public static final String ADMIN_PATH = "admin"; public static final String PREVIEW_PATH = "preview"; public static final String OAUTH_PROVIDERS_PATH = "oauth-providers"; - public static final String BLACKLIST_PATH = "blacklist"; public static final String MAX_RATE_PATH = "max-rate"; public static final String MAX_RATE_HISTORY_PATH = "history"; public static final String STORAGE_HEALTH_PATH = "storage-health"; @@ -138,14 +137,6 @@ public String consumersWorkloadConstraintsPath(String constraintsPath) { return Joiner.on(URL_SEPARATOR).join(consumersWorkloadConstraintsPath(), constraintsPath); } - public String topicsBlacklistPath() { - return Joiner.on(URL_SEPARATOR).join(basePath, BLACKLIST_PATH, TOPICS_PATH); - } - - public String blacklistedTopicPath(String qualifiedTopicName) { - return Joiner.on(URL_SEPARATOR).join(topicsBlacklistPath(), qualifiedTopicName); - } - public String oAuthProvidersPath() { return Joiner.on(URL_SEPARATOR).join(basePath, OAUTH_PROVIDERS_PATH); } diff --git a/hermes-console/package.json b/hermes-console/package.json index 321306bf5e..18827e25e3 100644 --- a/hermes-console/package.json +++ b/hermes-console/package.json @@ -12,8 +12,8 @@ "test:unit": "vitest --silent --environment jsdom", "build-only": "vite build", "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false", - "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore", - "lint:fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", + "lint": "eslint src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore", + "lint:fix": "eslint src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "dev-server": "node json-server/server.ts" }, "dependencies": { diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/BlacklistZookeeperNotifyingCache.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/BlacklistZookeeperNotifyingCache.java deleted file mode 100644 index cfb11574a2..0000000000 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/BlacklistZookeeperNotifyingCache.java +++ /dev/null @@ -1,63 +0,0 @@ -package pl.allegro.tech.hermes.frontend.blacklist; - -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.recipes.cache.PathChildrenCache; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperPaths; - -import java.util.ArrayList; -import java.util.List; - -public class BlacklistZookeeperNotifyingCache extends PathChildrenCache implements PathChildrenCacheListener { - - private static final Logger logger = LoggerFactory.getLogger(BlacklistZookeeperNotifyingCache.class); - - private final List topicCallbacks = new ArrayList<>(); - - public BlacklistZookeeperNotifyingCache(CuratorFramework curator, ZookeeperPaths paths) { - super(curator, paths.topicsBlacklistPath(), true); - getListenable().addListener(this); - } - - @Override - public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception { - if (event == null || event.getData() == null) { - return; - } - - logger.info("Got {} event for path {}", event.getType(), event.getData().getPath()); - - String qualifiedTopicName = getTopicName(event); - - switch (event.getType()) { - case CHILD_ADDED: - topicCallbacks.forEach(callback -> callback.onTopicBlacklisted(qualifiedTopicName)); - break; - case CHILD_REMOVED: - topicCallbacks.forEach(callback -> callback.onTopicUnblacklisted(qualifiedTopicName)); - break; - default: - break; - } - } - - public void startup() { - try { - this.start(); - } catch (Exception e) { - throw new IllegalStateException("Failed to start Zookeeper Topic Blacklist cache", e); - } - } - - private String getTopicName(PathChildrenCacheEvent event) { - String[] paths = event.getData().getPath().split("/"); - return paths[paths.length - 1]; - } - - public void addCallback(TopicBlacklistCallback callback) { - topicCallbacks.add(callback); - } -} diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/TopicBlacklistCallback.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/TopicBlacklistCallback.java deleted file mode 100644 index f63e770198..0000000000 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/blacklist/TopicBlacklistCallback.java +++ /dev/null @@ -1,8 +0,0 @@ -package pl.allegro.tech.hermes.frontend.blacklist; - -public interface TopicBlacklistCallback { - - default void onTopicBlacklisted(String qualifiedTopicName) {} - - default void onTopicUnblacklisted(String qualifiedTopicName) {} -} diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java index 5ac0b5d232..e902545edf 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java @@ -4,15 +4,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import pl.allegro.tech.hermes.api.Topic; -import pl.allegro.tech.hermes.api.TopicName; import pl.allegro.tech.hermes.common.kafka.KafkaNamesMapper; import pl.allegro.tech.hermes.common.metric.MetricsFacade; import pl.allegro.tech.hermes.domain.group.GroupRepository; import pl.allegro.tech.hermes.domain.notifications.InternalNotificationsBus; import pl.allegro.tech.hermes.domain.notifications.TopicCallback; import pl.allegro.tech.hermes.domain.topic.TopicRepository; -import pl.allegro.tech.hermes.frontend.blacklist.BlacklistZookeeperNotifyingCache; -import pl.allegro.tech.hermes.frontend.blacklist.TopicBlacklistCallback; import pl.allegro.tech.hermes.frontend.metric.CachedTopic; import pl.allegro.tech.hermes.frontend.metric.ThroughputRegistry; @@ -21,7 +18,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -public class NotificationBasedTopicsCache implements TopicCallback, TopicsCache, TopicBlacklistCallback { +public class NotificationBasedTopicsCache implements TopicCallback, TopicsCache { private static final Logger logger = LoggerFactory.getLogger(NotificationBasedTopicsCache.class); @@ -34,7 +31,6 @@ public class NotificationBasedTopicsCache implements TopicCallback, TopicsCache, private final ThroughputRegistry throughputRegistry; public NotificationBasedTopicsCache(InternalNotificationsBus notificationsBus, - BlacklistZookeeperNotifyingCache blacklistZookeeperNotifyingCache, GroupRepository groupRepository, TopicRepository topicRepository, MetricsFacade metricsFacade, @@ -46,7 +42,6 @@ public NotificationBasedTopicsCache(InternalNotificationsBus notificationsBus, this.kafkaNamesMapper = kafkaNamesMapper; this.throughputRegistry = throughputRegistry; notificationsBus.registerTopicCallback(this); - blacklistZookeeperNotifyingCache.addCallback(this); } @Override @@ -72,26 +67,6 @@ public void onTopicChanged(Topic topic) { topicCache.put(topic.getName().qualifiedName(), cachedTopic(topic)); } - @Override - public void onTopicBlacklisted(String qualifiedTopicName) { - Optional topic = Optional.ofNullable( - Optional.ofNullable( - topicCache.get(qualifiedTopicName)).map(CachedTopic::getTopic).orElseGet(() -> - topicRepository.getTopicDetails(TopicName.fromQualifiedName(qualifiedTopicName)))); - - topic.ifPresent(t -> topicCache.put(qualifiedTopicName, bannedTopic(t))); - } - - @Override - public void onTopicUnblacklisted(String qualifiedTopicName) { - Optional topic = Optional.ofNullable( - Optional.ofNullable( - topicCache.get(qualifiedTopicName)).map(CachedTopic::getTopic).orElseGet(() -> - topicRepository.getTopicDetails(TopicName.fromQualifiedName(qualifiedTopicName)))); - - topic.ifPresent(t -> topicCache.put(qualifiedTopicName, cachedTopic(t))); - } - @Override public Optional getTopic(String qualifiedTopicName) { return Optional.ofNullable(topicCache.get(qualifiedTopicName)); @@ -114,8 +89,4 @@ public void start() { private CachedTopic cachedTopic(Topic topic) { return new CachedTopic(topic, metricsFacade, throughputRegistry, kafkaNamesMapper.toKafkaTopics(topic)); } - - private CachedTopic bannedTopic(Topic topic) { - return new CachedTopic(topic, metricsFacade, throughputRegistry, kafkaNamesMapper.toKafkaTopics(topic), true); - } } diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java index a11e42a9a0..3c4f7ee402 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java @@ -10,7 +10,6 @@ import pl.allegro.tech.hermes.domain.group.GroupRepository; import pl.allegro.tech.hermes.domain.notifications.InternalNotificationsBus; import pl.allegro.tech.hermes.domain.topic.TopicRepository; -import pl.allegro.tech.hermes.frontend.blacklist.BlacklistZookeeperNotifyingCache; import pl.allegro.tech.hermes.frontend.buffer.BackupMessagesLoader; import pl.allegro.tech.hermes.frontend.buffer.PersistentBufferExtension; import pl.allegro.tech.hermes.frontend.cache.topic.NotificationBasedTopicsCache; @@ -43,10 +42,9 @@ public TopicsCache notificationBasedTopicsCache(InternalNotificationsBus interna TopicRepository topicRepository, MetricsFacade metricsFacade, ThroughputRegistry throughputRegistry, - KafkaNamesMapper kafkaNamesMapper, - BlacklistZookeeperNotifyingCache blacklistZookeeperNotifyingCache) { + KafkaNamesMapper kafkaNamesMapper) { - return new NotificationBasedTopicsCache(internalNotificationsBus, blacklistZookeeperNotifyingCache, + return new NotificationBasedTopicsCache(internalNotificationsBus, groupRepository, topicRepository, metricsFacade, throughputRegistry, kafkaNamesMapper); } @@ -79,12 +77,6 @@ public PersistentBufferExtension persistentBufferExtension(LocalMessageStoragePr metricsFacade); } - @Bean(initMethod = "startup") - public BlacklistZookeeperNotifyingCache blacklistZookeeperNotifyingCache(CuratorFramework curator, - ZookeeperPaths zookeeperPaths) { - return new BlacklistZookeeperNotifyingCache(curator, zookeeperPaths); - } - @Bean public BrokerListeners defaultBrokerListeners() { return new BrokerListeners(); diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java index 9ffb726071..9bc5d1d9b7 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java @@ -19,7 +19,6 @@ public class CachedTopic { private final Topic topic; private final KafkaTopics kafkaTopics; private final MetricsFacade metricsFacade; - private final boolean blacklisted; private final HermesTimer topicProducerLatencyTimer; private final HermesTimer globalProducerLatencyTimer; @@ -47,18 +46,9 @@ public CachedTopic(Topic topic, MetricsFacade metricsFacade, ThroughputRegistry throughputRegistry, KafkaTopics kafkaTopics) { - this(topic, metricsFacade, throughputRegistry, kafkaTopics, false); - } - - public CachedTopic(Topic topic, - MetricsFacade metricsFacade, - ThroughputRegistry throughputRegistry, - KafkaTopics kafkaTopics, - boolean blacklisted) { this.topic = topic; this.kafkaTopics = kafkaTopics; this.metricsFacade = metricsFacade; - this.blacklisted = blacklisted; globalRequestMeter = metricsFacade.topics().topicGlobalRequestCounter(); topicRequestMeter = metricsFacade.topics().topicRequestCounter(topic.getName()); @@ -100,10 +90,6 @@ public KafkaTopics getKafkaTopics() { return kafkaTopics; } - public boolean isBlacklisted() { - return blacklisted; - } - public StartedTimersPair startProducerLatencyTimers() { return new StartedTimersPair(topicProducerLatencyTimer.time(), globalProducerLatencyTimer.time()); } diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java index 2158892266..7ed8c2143a 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java @@ -17,7 +17,6 @@ import static io.undertow.util.StatusCodes.INTERNAL_SERVER_ERROR; import static pl.allegro.tech.hermes.api.ErrorCode.AUTH_ERROR; -import static pl.allegro.tech.hermes.api.ErrorCode.TOPIC_BLACKLISTED; import static pl.allegro.tech.hermes.api.ErrorCode.TOPIC_NOT_EXISTS; import static pl.allegro.tech.hermes.api.ErrorDescription.error; @@ -67,10 +66,6 @@ private void onRequestValid(HttpServerExchange exchange, String messageId, Consu } CachedTopic cachedTopic = maybeTopic.get(); - if (cachedTopic.isBlacklisted()) { - blacklistedTopic(exchange, topicName, messageId); - return; - } Topic topic = cachedTopic.getTopic(); if (topic.isAuthEnabled() && !hasPermission(exchange, topic)) { @@ -111,13 +106,6 @@ private void requestForbidden(HttpServerExchange exchange, String messageId, Str qualifiedTopicName); } - private void blacklistedTopic(HttpServerExchange exchange, String qualifiedTopicName, String messageId) { - messageErrorProcessor.sendQuietly(exchange, - error("Topic blacklisted: " + qualifiedTopicName, TOPIC_BLACKLISTED), - messageId, - qualifiedTopicName); - } - // Default Undertow's response code (200) was changed in order to avoid situations in which something wrong happens and Hermes-Frontend // does not publish message but return code 200 // Since the default code is 500, clients have information that they should retry publishing diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/api/BlacklistEndpoint.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/api/BlacklistEndpoint.java deleted file mode 100644 index bd796708ad..0000000000 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/api/BlacklistEndpoint.java +++ /dev/null @@ -1,86 +0,0 @@ -package pl.allegro.tech.hermes.management.api; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import jakarta.annotation.security.RolesAllowed; -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.DELETE; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.HttpMethod; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.container.ContainerRequestContext; -import jakarta.ws.rs.core.Context; -import jakarta.ws.rs.core.Response; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import pl.allegro.tech.hermes.api.BlacklistStatus; -import pl.allegro.tech.hermes.management.api.auth.HermesSecurityAwareRequestUser; -import pl.allegro.tech.hermes.management.api.auth.Roles; -import pl.allegro.tech.hermes.management.domain.auth.RequestUser; -import pl.allegro.tech.hermes.management.domain.blacklist.TopicBlacklistService; - -import java.util.List; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static jakarta.ws.rs.core.Response.status; -import static pl.allegro.tech.hermes.api.BlacklistStatus.BLACKLISTED; -import static pl.allegro.tech.hermes.api.BlacklistStatus.NOT_BLACKLISTED; - -@Component -@Path("/blacklist") -@Api(value = "/blacklist", description = "Operations on topics") -public class BlacklistEndpoint { - - private final TopicBlacklistService topicBlacklistService; - - @Autowired - public BlacklistEndpoint(TopicBlacklistService topicBlacklistService) { - this.topicBlacklistService = topicBlacklistService; - } - - @GET - @Produces(APPLICATION_JSON) - @Path("/topics/{topicName}") - @ApiOperation(value = "Is topic blacklisted", httpMethod = HttpMethod.GET) - public BlacklistStatus isTopicBlacklisted(@PathParam("topicName") String qualifiedTopicName) { - return topicBlacklistService.isBlacklisted(qualifiedTopicName) ? BLACKLISTED : NOT_BLACKLISTED; - } - - @GET - @Produces(APPLICATION_JSON) - @Path("/topics") - @RolesAllowed(Roles.ADMIN) - public List topicsBlacklist() { - return topicBlacklistService.list(); - } - - @POST - @Produces(APPLICATION_JSON) - @Consumes(APPLICATION_JSON) - @Path("/topics") - @RolesAllowed(Roles.ADMIN) - @ApiOperation(value = "Blacklist topics", httpMethod = HttpMethod.POST) - public Response blacklistTopics( - List qualifiedTopicNames, - @Context ContainerRequestContext requestContext) { - RequestUser blacklistRequester = new HermesSecurityAwareRequestUser(requestContext); - qualifiedTopicNames.forEach(topicName -> topicBlacklistService.blacklist(topicName, blacklistRequester)); - return status(Response.Status.OK).build(); - } - - @DELETE - @Produces(APPLICATION_JSON) - @Path("/topics/{topicName}") - @RolesAllowed(Roles.ADMIN) - @ApiOperation(value = "Unblacklist topic", httpMethod = HttpMethod.DELETE) - public Response unblacklistTopic( - @PathParam("topicName") String qualifiedTopicName, - @Context ContainerRequestContext requestContext) { - RequestUser unblacklistRequester = new HermesSecurityAwareRequestUser(requestContext); - topicBlacklistService.unblacklist(qualifiedTopicName, unblacklistRequester); - return status(Response.Status.OK).build(); - } -} diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java index 9bf60b1c79..1c8eeff596 100644 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java +++ b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java @@ -27,12 +27,10 @@ import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperSubscriptionRepository; import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperTopicRepository; import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperWorkloadConstraintsRepository; -import pl.allegro.tech.hermes.management.domain.blacklist.TopicBlacklistRepository; import pl.allegro.tech.hermes.management.domain.dc.MultiDatacenterRepositoryCommandExecutor; import pl.allegro.tech.hermes.management.domain.mode.ModeService; import pl.allegro.tech.hermes.management.domain.readiness.DatacenterReadinessRepository; import pl.allegro.tech.hermes.management.domain.retransmit.OfflineRetransmissionRepository; -import pl.allegro.tech.hermes.management.infrastructure.blacklist.ZookeeperTopicBlacklistRepository; import pl.allegro.tech.hermes.management.infrastructure.metrics.SummedSharedCounter; import pl.allegro.tech.hermes.management.infrastructure.readiness.ZookeeperDatacenterReadinessRepository; import pl.allegro.tech.hermes.management.infrastructure.retransmit.ZookeeperOfflineRetransmissionRepository; @@ -144,12 +142,6 @@ MessagePreviewRepository messagePreviewRepository() { return new ZookeeperMessagePreviewRepository(localClient.getCuratorFramework(), objectMapper, zookeeperPaths()); } - @Bean - TopicBlacklistRepository topicBlacklistRepository() { - ZookeeperClient localClient = clientManager().getLocalClient(); - return new ZookeeperTopicBlacklistRepository(localClient.getCuratorFramework(), objectMapper, zookeeperPaths()); - } - @Bean WorkloadConstraintsRepository workloadConstraintsRepository() { ZookeeperClient localClient = clientManager().getLocalClient(); diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/NotUnblacklistedException.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/NotUnblacklistedException.java deleted file mode 100644 index 510b8cd51f..0000000000 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/NotUnblacklistedException.java +++ /dev/null @@ -1,22 +0,0 @@ -package pl.allegro.tech.hermes.management.domain.blacklist; - -import pl.allegro.tech.hermes.api.ErrorCode; -import pl.allegro.tech.hermes.common.exception.HermesException; - -import static pl.allegro.tech.hermes.api.ErrorCode.TOPIC_NOT_UNBLACKLISTED; - -public class NotUnblacklistedException extends HermesException { - - @Override - public ErrorCode getCode() { - return TOPIC_NOT_UNBLACKLISTED; - } - - public NotUnblacklistedException(String qualifiedTopicName, Throwable cause) { - super("Topic not unblacklisted: " + qualifiedTopicName, cause); - } - - public NotUnblacklistedException(String qualifiedTopicName) { - this(qualifiedTopicName, null); - } -} diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistRepository.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistRepository.java deleted file mode 100644 index ae62045264..0000000000 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package pl.allegro.tech.hermes.management.domain.blacklist; - -import java.util.List; - -public interface TopicBlacklistRepository { - - void add(String qualifiedTopicName); - - void remove(String qualifiedTopicName); - - boolean isBlacklisted(String qualifiedTopicName); - - List list(); -} diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistService.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistService.java deleted file mode 100644 index 3e5350ecc5..0000000000 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/TopicBlacklistService.java +++ /dev/null @@ -1,41 +0,0 @@ -package pl.allegro.tech.hermes.management.domain.blacklist; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import pl.allegro.tech.hermes.management.domain.auth.RequestUser; -import pl.allegro.tech.hermes.management.domain.blacklist.commands.AddTopicToBlacklistRepositoryCommand; -import pl.allegro.tech.hermes.management.domain.blacklist.commands.RemoveTopicFromBlacklistRepositoryCommand; -import pl.allegro.tech.hermes.management.domain.dc.MultiDatacenterRepositoryCommandExecutor; - -import java.util.List; - -@Component -public class TopicBlacklistService { - - private final TopicBlacklistRepository repository; - private final MultiDatacenterRepositoryCommandExecutor multiDcExecutor; - - @Autowired - public TopicBlacklistService(TopicBlacklistRepository repository, - MultiDatacenterRepositoryCommandExecutor multiDcExecutor) { - this.repository = repository; - this.multiDcExecutor = multiDcExecutor; - } - - public void blacklist(String qualifiedTopicName, RequestUser blacklistRequester) { - multiDcExecutor.executeByUser(new AddTopicToBlacklistRepositoryCommand(qualifiedTopicName), blacklistRequester); - } - - public void unblacklist(String qualifiedTopicName, RequestUser unblacklistRequester) { - multiDcExecutor.executeByUser(new RemoveTopicFromBlacklistRepositoryCommand(qualifiedTopicName), unblacklistRequester); - } - - public boolean isBlacklisted(String qualifiedTopicName) { - return repository.isBlacklisted(qualifiedTopicName); - } - - public List list() { - return repository.list(); - } - -} diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/AddTopicToBlacklistRepositoryCommand.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/AddTopicToBlacklistRepositoryCommand.java deleted file mode 100644 index d4259545d8..0000000000 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/AddTopicToBlacklistRepositoryCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package pl.allegro.tech.hermes.management.domain.blacklist.commands; - -import pl.allegro.tech.hermes.management.domain.blacklist.TopicBlacklistRepository; -import pl.allegro.tech.hermes.management.domain.dc.DatacenterBoundRepositoryHolder; -import pl.allegro.tech.hermes.management.domain.dc.RepositoryCommand; - -public class AddTopicToBlacklistRepositoryCommand extends RepositoryCommand { - - private final String qualifiedTopicName; - - public AddTopicToBlacklistRepositoryCommand(String qualifiedTopicName) { - this.qualifiedTopicName = qualifiedTopicName; - } - - @Override - public void backup(DatacenterBoundRepositoryHolder holder) {} - - @Override - public void execute(DatacenterBoundRepositoryHolder holder) { - holder.getRepository().add(qualifiedTopicName); - } - - @Override - public void rollback(DatacenterBoundRepositoryHolder holder, Exception exception) { - holder.getRepository().remove(qualifiedTopicName); - } - - @Override - public Class getRepositoryType() { - return TopicBlacklistRepository.class; - } - - @Override - public String toString() { - return "AddTopicToBlacklist(" + qualifiedTopicName + ")"; - } -} diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/RemoveTopicFromBlacklistRepositoryCommand.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/RemoveTopicFromBlacklistRepositoryCommand.java deleted file mode 100644 index 1ca0ef3367..0000000000 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/blacklist/commands/RemoveTopicFromBlacklistRepositoryCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -package pl.allegro.tech.hermes.management.domain.blacklist.commands; - -import pl.allegro.tech.hermes.management.domain.blacklist.TopicBlacklistRepository; -import pl.allegro.tech.hermes.management.domain.dc.DatacenterBoundRepositoryHolder; -import pl.allegro.tech.hermes.management.domain.dc.RepositoryCommand; - -public class RemoveTopicFromBlacklistRepositoryCommand extends RepositoryCommand { - private final String qualifiedTopicName; - private boolean exists = false; - - public RemoveTopicFromBlacklistRepositoryCommand(String qualifiedTopicName) { - this.qualifiedTopicName = qualifiedTopicName; - } - - @Override - public void backup(DatacenterBoundRepositoryHolder holder) { - exists = holder.getRepository().isBlacklisted(qualifiedTopicName); - } - - @Override - public void execute(DatacenterBoundRepositoryHolder holder) { - holder.getRepository().remove(qualifiedTopicName); - } - - @Override - public void rollback(DatacenterBoundRepositoryHolder holder, Exception exception) { - if (exists) { - holder.getRepository().add(qualifiedTopicName); - } - } - - @Override - public Class getRepositoryType() { - return TopicBlacklistRepository.class; - } - - @Override - public String toString() { - return "RemoveTopicFromBlacklist(" + qualifiedTopicName + ")"; - } -} diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java index 26fe3ae834..c66b426854 100644 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java +++ b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java @@ -24,7 +24,6 @@ import pl.allegro.tech.hermes.management.config.TopicProperties; import pl.allegro.tech.hermes.management.domain.Auditor; import pl.allegro.tech.hermes.management.domain.auth.RequestUser; -import pl.allegro.tech.hermes.management.domain.blacklist.TopicBlacklistService; import pl.allegro.tech.hermes.management.domain.dc.DatacenterBoundRepositoryHolder; import pl.allegro.tech.hermes.management.domain.dc.MultiDatacenterRepositoryCommandExecutor; import pl.allegro.tech.hermes.management.domain.dc.RepositoryManager; @@ -66,7 +65,6 @@ public class TopicService { private final TopicMetricsRepository metricRepository; private final MultiDCAwareService multiDCAwareService; - private final TopicBlacklistService topicBlacklistService; private final TopicValidator topicValidator; private final TopicContentTypeMigrationService topicContentTypeMigrationService; private final Clock clock; @@ -86,7 +84,7 @@ public TopicService(MultiDCAwareService multiDCAwareService, GroupService groupService, TopicProperties topicProperties, SchemaService schemaService, TopicMetricsRepository metricRepository, - TopicBlacklistService topicBlacklistService, TopicValidator topicValidator, + TopicValidator topicValidator, TopicContentTypeMigrationService topicContentTypeMigrationService, Clock clock, Auditor auditor, @@ -100,7 +98,6 @@ public TopicService(MultiDCAwareService multiDCAwareService, this.topicProperties = topicProperties; this.schemaService = schemaService; this.metricRepository = metricRepository; - this.topicBlacklistService = topicBlacklistService; this.topicValidator = topicValidator; this.topicContentTypeMigrationService = topicContentTypeMigrationService; this.clock = clock; @@ -133,9 +130,6 @@ public void removeTopicWithSchema(Topic topic, RequestUser removedBy) { if (!topicProperties.isAllowRemoval()) { throw new TopicRemovalDisabledException(topic); } - if (topicBlacklistService.isBlacklisted(topic.getQualifiedName())) { - topicBlacklistService.unblacklist(topic.getQualifiedName(), removedBy); - } removeTopic(topic, removedBy); } diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/blacklist/ZookeeperTopicBlacklistRepository.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/blacklist/ZookeeperTopicBlacklistRepository.java deleted file mode 100644 index 1ba3da65bd..0000000000 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/blacklist/ZookeeperTopicBlacklistRepository.java +++ /dev/null @@ -1,48 +0,0 @@ -package pl.allegro.tech.hermes.management.infrastructure.blacklist; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.curator.framework.CuratorFramework; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperBasedRepository; -import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperPaths; -import pl.allegro.tech.hermes.management.domain.blacklist.NotUnblacklistedException; -import pl.allegro.tech.hermes.management.domain.blacklist.TopicBlacklistRepository; - -import java.util.List; - -public class ZookeeperTopicBlacklistRepository extends ZookeeperBasedRepository implements TopicBlacklistRepository { - - private static final Logger logger = LoggerFactory.getLogger(ZookeeperTopicBlacklistRepository.class); - - public ZookeeperTopicBlacklistRepository(CuratorFramework zookeeper, ObjectMapper mapper, ZookeeperPaths paths) { - super(zookeeper, mapper, paths); - } - - @Override - public void add(String qualifiedTopicName) { - logger.info("Adding topic {} to Blacklist", qualifiedTopicName); - ensurePathExists(paths.blacklistedTopicPath(qualifiedTopicName)); - } - - @Override - public void remove(String qualifiedTopicName) { - logger.info("Removing topic {} from Blacklist", qualifiedTopicName); - try { - super.remove(paths.blacklistedTopicPath(qualifiedTopicName)); - } catch (Exception e) { - logger.warn("Removing topic {} from Blacklist caused an exception", qualifiedTopicName, e); - throw new NotUnblacklistedException(qualifiedTopicName, e); - } - } - - @Override - public boolean isBlacklisted(String qualifiedTopicName) { - return pathExists(paths.blacklistedTopicPath(qualifiedTopicName)); - } - - @Override - public List list() { - return childrenOf(paths.topicsBlacklistPath()); - } -} diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java index 8d72b11395..a5094272df 100644 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java +++ b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java @@ -25,12 +25,10 @@ import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperTopicRepository; import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperWorkloadConstraintsRepository; import pl.allegro.tech.hermes.management.config.storage.ZookeeperGroupRepositoryFactory; -import pl.allegro.tech.hermes.management.domain.blacklist.TopicBlacklistRepository; import pl.allegro.tech.hermes.management.domain.dc.DatacenterBoundRepositoryHolder; import pl.allegro.tech.hermes.management.domain.dc.RepositoryManager; import pl.allegro.tech.hermes.management.domain.readiness.DatacenterReadinessRepository; import pl.allegro.tech.hermes.management.domain.retransmit.OfflineRetransmissionRepository; -import pl.allegro.tech.hermes.management.infrastructure.blacklist.ZookeeperTopicBlacklistRepository; import pl.allegro.tech.hermes.management.infrastructure.readiness.ZookeeperDatacenterReadinessRepository; import pl.allegro.tech.hermes.management.infrastructure.retransmit.ZookeeperOfflineRetransmissionRepository; @@ -54,7 +52,6 @@ public class ZookeeperRepositoryManager implements RepositoryManager { private final Map oAuthProviderRepositoriesByDc = new HashMap<>(); private final Map offsetChangeIndicatorsByDc = new HashMap<>(); private final Map messagePreviewRepositoriesByDc = new HashMap<>(); - private final Map topicBlacklistRepositoriesByDc = new HashMap<>(); private final Map workloadConstraintsRepositoriesByDc = new HashMap<>(); private final Map lastUndeliveredMessageReaderByDc = new HashMap<>(); private final Map adminToolByDc = new HashMap<>(); @@ -102,9 +99,6 @@ public void start() { MessagePreviewRepository messagePreviewRepository = new ZookeeperMessagePreviewRepository(zookeeper, mapper, paths); messagePreviewRepositoriesByDc.put(dcName, messagePreviewRepository); - TopicBlacklistRepository topicBlacklistRepository = new ZookeeperTopicBlacklistRepository(zookeeper, mapper, paths); - topicBlacklistRepositoriesByDc.put(dcName, topicBlacklistRepository); - WorkloadConstraintsRepository workloadConstraintsRepository = new ZookeeperWorkloadConstraintsRepository(zookeeper, mapper, paths); workloadConstraintsRepositoriesByDc.put(dcName, workloadConstraintsRepository); @@ -162,7 +156,6 @@ private void initRepositoryTypeMap() { repositoryByType.put(OAuthProviderRepository.class, oAuthProviderRepositoriesByDc); repositoryByType.put(SubscriptionOffsetChangeIndicator.class, offsetChangeIndicatorsByDc); repositoryByType.put(MessagePreviewRepository.class, messagePreviewRepositoriesByDc); - repositoryByType.put(TopicBlacklistRepository.class, topicBlacklistRepositoriesByDc); repositoryByType.put(WorkloadConstraintsRepository.class, workloadConstraintsRepositoriesByDc); repositoryByType.put(LastUndeliveredMessageReader.class, lastUndeliveredMessageReaderByDc); repositoryByType.put(AdminTool.class, adminToolByDc); diff --git a/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/HermesTestClient.java b/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/HermesTestClient.java index 1f646f1e76..d97417cf3f 100644 --- a/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/HermesTestClient.java +++ b/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/HermesTestClient.java @@ -5,7 +5,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.MultiValueMap; -import pl.allegro.tech.hermes.api.BlacklistStatus; import pl.allegro.tech.hermes.api.ConsumerGroup; import pl.allegro.tech.hermes.api.Group; import pl.allegro.tech.hermes.api.MessageFiltersVerificationInput; @@ -228,31 +227,6 @@ public String publishSlowly(int clientTimeout, int pauseTimeBetweenChunks, int d return publishSlowly(clientTimeout, pauseTimeBetweenChunks, delayBeforeSendingFirstData, topicName, false); } - public void blacklistTopic(String topicQualifiedName) { - managementTestClient.blacklistTopic(topicQualifiedName).expectStatus().is2xxSuccessful(); - } - - public WebTestClient.ResponseSpec blacklistTopicResponse(String topicQualifiedName) { - return managementTestClient.blacklistTopic(topicQualifiedName); - } - - public void unblacklistTopic(String topicQualifiedName) { - managementTestClient.unblacklistTopic(topicQualifiedName).expectStatus().is2xxSuccessful(); - } - - public BlacklistStatus isTopicBlacklisted(String topicQualifiedName) { - return managementTestClient.isTopicBlacklisted(topicQualifiedName) - .expectStatus() - .is2xxSuccessful() - .expectBody(BlacklistStatus.class) - .returnResult() - .getResponseBody(); - } - - public WebTestClient.ResponseSpec unblacklistTopicResponse(String topicQualifiedName) { - return managementTestClient.unblacklistTopic(topicQualifiedName); - } - public WebTestClient.ResponseSpec getLatestUndeliveredMessage(String topicQualifiedName, String subscriptionName) { return managementTestClient.getLatestUndeliveredMessage(topicQualifiedName, subscriptionName); } diff --git a/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java b/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java index d3dfcc5e5c..2f983f8394 100644 --- a/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java +++ b/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java @@ -44,10 +44,6 @@ public class ManagementTestClient { private static final String RETRANSMISSION_PATH = "/topics/{topicName}/subscriptions/{subscriptionName}/retransmission"; - private static final String BLACKLIST_TOPICS_PATH = "/blacklist/topics"; - - private static final String BLACKLIST_TOPIC_PATH = "/blacklist/topics/{topicName}"; - private static final String LATEST_UNDELIVERED_MESSAGE = "/topics/{topicName}/subscriptions/{subscriptionName}/undelivered"; private static final String TOPIC_PREVIEW = "/topics/{topicName}/preview"; @@ -256,26 +252,6 @@ private List mapStringJsonToListOfString(String jsonString) { } } - public WebTestClient.ResponseSpec blacklistTopic(String topicQualifiedName) { - return webTestClient.post().uri(BLACKLIST_TOPICS_PATH) - .body(Mono.just(List.of(topicQualifiedName)), List.class) - .exchange(); - } - - public WebTestClient.ResponseSpec unblacklistTopic(String topicQualifiedName) { - return webTestClient.delete().uri(UriBuilder.fromUri(managementContainerUrl) - .path(BLACKLIST_TOPIC_PATH) - .build(topicQualifiedName)) - .exchange(); - } - - public WebTestClient.ResponseSpec isTopicBlacklisted(String topicQualifiedName) { - return webTestClient.get().uri(UriBuilder.fromUri(managementContainerUrl) - .path(BLACKLIST_TOPIC_PATH) - .build(topicQualifiedName)) - .exchange(); - } - public WebTestClient.ResponseSpec getLatestUndeliveredMessage(String topicQualifiedName, String subscriptionName) { return webTestClient.get().uri(UriBuilder.fromUri(managementContainerUrl) .path(LATEST_UNDELIVERED_MESSAGE) diff --git a/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/TopicBlacklistTest.java b/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/TopicBlacklistTest.java deleted file mode 100644 index 3b98dd7d54..0000000000 --- a/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/TopicBlacklistTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package pl.allegro.tech.hermes.integrationtests; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.springframework.test.web.reactive.server.WebTestClient; -import pl.allegro.tech.hermes.api.Topic; -import pl.allegro.tech.hermes.integrationtests.setup.HermesExtension; -import pl.allegro.tech.hermes.test.helper.message.TestMessage; - -import java.time.Duration; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.waitAtMost; -import static pl.allegro.tech.hermes.api.BlacklistStatus.BLACKLISTED; -import static pl.allegro.tech.hermes.api.BlacklistStatus.NOT_BLACKLISTED; -import static pl.allegro.tech.hermes.test.helper.builder.TopicBuilder.topicWithRandomName; - -public class TopicBlacklistTest { - - @RegisterExtension - public static final HermesExtension hermes = new HermesExtension(); - - @Test - public void shouldRefuseMessageOnBlacklistedTopic() { - // given - Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); - TestMessage message = TestMessage.of("hello", "world"); - - // when - hermes.api().blacklistTopic(topic.getQualifiedName()); - waitAtMost(Duration.ofSeconds(10)).untilAsserted(() -> { - WebTestClient.ResponseSpec response = hermes.api().publish(topic.getQualifiedName(), message.body()); - - // then - response.expectStatus().isForbidden(); - }); - } - - @Test - public void shouldAcceptMessageOnUnblacklistedTopic() { - // given - Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); - TestMessage message = TestMessage.of("hello", "world"); - hermes.api().blacklistTopic(topic.getQualifiedName()); - - // when - hermes.api().unblacklistTopic(topic.getQualifiedName()); - waitAtMost(Duration.ofSeconds(10)).untilAsserted(() -> { - WebTestClient.ResponseSpec response = hermes.api().publish(topic.getQualifiedName(), message.body()); - - // then - response.expectStatus().is2xxSuccessful(); - }); - } - - @Test - public void shouldBlacklistNonExistingTopic() { - // expect - WebTestClient.ResponseSpec response = hermes.api().blacklistTopicResponse("nonExisting.topic"); - - // then - response.expectStatus().isOk(); - } - - - @Test - public void shouldUnBlacklistTopic() { - // given - Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); - hermes.api().blacklistTopic(topic.getQualifiedName()); - - // when - WebTestClient.ResponseSpec response = hermes.api().unblacklistTopicResponse(topic.getQualifiedName()); - - // then - response.expectStatus().isOk(); - } - - @Test - public void shouldReportValidStatusOfTopic() { - // given - Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); - - // when - hermes.api().blacklistTopic(topic.getQualifiedName()); - - // then - assertThat(hermes.api().isTopicBlacklisted(topic.getQualifiedName())).isEqualTo(BLACKLISTED); - - // when - hermes.api().unblacklistTopic(topic.getQualifiedName()); - - // then - assertThat(hermes.api().isTopicBlacklisted(topic.getQualifiedName())).isEqualTo(NOT_BLACKLISTED); - } - - @Test - public void shouldReturnErrorOnNonBlacklistedUnblacklist() { - // when - Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); - WebTestClient.ResponseSpec response = hermes.api().unblacklistTopicResponse(topic.getQualifiedName()); - - // then - response.expectStatus().isBadRequest(); - } -} \ No newline at end of file diff --git a/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java b/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java index 461492ccd9..c8a12bff6a 100644 --- a/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java +++ b/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java @@ -146,21 +146,6 @@ public void shouldRemoveTopic() { waitAtMost(Duration.ofSeconds(10)).untilAsserted(() -> assertThat(getGroupTopicsList(topic.getName().getGroupName())).isEmpty()); } - @Test - public void shouldUnblacklistTopicWhileDeleting() { - // given - Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); - hermes.api().blacklistTopic(topic.getQualifiedName()); - - // when - WebTestClient.ResponseSpec response = hermes.api().deleteTopic(topic.getQualifiedName()); - - // then - response.expectStatus().isOk(); - waitAtMost(Duration.ofSeconds(10)).untilAsserted(() -> assertThat(getGroupTopicsList(topic.getName().getGroupName())).isEmpty()); - assertThat(hermes.api().isTopicBlacklisted(topic.getQualifiedName()).isBlacklisted()).isFalse(); - } - @Test public void shouldNotAllowOnDeletingTopicWithSubscriptions() { // given From 27af5ed9280eda79a0bace6ae4355360b7530157 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 22 Jan 2025 19:26:15 +0100 Subject: [PATCH 2/4] Fixes after merge --- .../integration/ManagementTestClient.java | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java b/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java index b8aed74d71..cbeb740cd2 100644 --- a/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java +++ b/hermes-test-helper/src/main/java/pl/allegro/tech/hermes/test/helper/client/integration/ManagementTestClient.java @@ -277,41 +277,6 @@ private List mapStringJsonToListOfString(String jsonString) { } } - public WebTestClient.ResponseSpec getLatestUndeliveredMessage(String topicQualifiedName, String subscriptionName) { - return webTestClient.get().uri(UriBuilder.fromUri(managementContainerUrl) - .path(LATEST_UNDELIVERED_MESSAGE) - .build(topicQualifiedName, subscriptionName)) - .exchange(); - } - - public WebTestClient.ResponseSpec blacklistTopic(String topicQualifiedName) { - return webTestClient - .post() - .uri(BLACKLIST_TOPICS_PATH) - .body(Mono.just(List.of(topicQualifiedName)), List.class) - .exchange(); - } - - public WebTestClient.ResponseSpec unblacklistTopic(String topicQualifiedName) { - return webTestClient - .delete() - .uri( - UriBuilder.fromUri(managementContainerUrl) - .path(BLACKLIST_TOPIC_PATH) - .build(topicQualifiedName)) - .exchange(); - } - - public WebTestClient.ResponseSpec isTopicBlacklisted(String topicQualifiedName) { - return webTestClient - .get() - .uri( - UriBuilder.fromUri(managementContainerUrl) - .path(BLACKLIST_TOPIC_PATH) - .build(topicQualifiedName)) - .exchange(); - } - public WebTestClient.ResponseSpec getLatestUndeliveredMessage( String topicQualifiedName, String subscriptionName) { return webTestClient From cab46da202e75466dbeaceab0f2b4ac0d4439c45 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 22 Jan 2025 19:31:16 +0100 Subject: [PATCH 3/4] Google java format fix --- .../zookeeper/ZookeeperPaths.java | 6 +-- .../topic/NotificationBasedTopicsCache.java | 45 ++++++++++--------- .../config/FrontendConfiguration.java | 2 - .../hermes/frontend/metric/CachedTopic.java | 6 +-- .../publishing/handlers/TopicHandler.java | 16 +++---- .../config/storage/StorageConfiguration.java | 16 +++---- .../management/domain/topic/TopicService.java | 21 +++++---- .../zookeeper/ZookeeperRepositoryManager.java | 9 ++-- .../management/TopicManagementTest.java | 10 ++--- 9 files changed, 61 insertions(+), 70 deletions(-) diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java index 15fdc666c9..5fe6cfae93 100644 --- a/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java +++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/infrastructure/zookeeper/ZookeeperPaths.java @@ -151,9 +151,9 @@ public String consumersWorkloadConstraintsPath(String constraintsPath) { return Joiner.on(URL_SEPARATOR).join(consumersWorkloadConstraintsPath(), constraintsPath); } - public String oAuthProvidersPath() { - return Joiner.on(URL_SEPARATOR).join(basePath, OAUTH_PROVIDERS_PATH); - } + public String oAuthProvidersPath() { + return Joiner.on(URL_SEPARATOR).join(basePath, OAUTH_PROVIDERS_PATH); + } public String oAuthProviderPath(String oAuthProviderName) { return Joiner.on(URL_SEPARATOR).join(oAuthProvidersPath(), oAuthProviderName); diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java index bc8d4f24f2..47e42b368b 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/cache/topic/NotificationBasedTopicsCache.java @@ -17,8 +17,7 @@ import pl.allegro.tech.hermes.frontend.metric.CachedTopic; import pl.allegro.tech.hermes.frontend.metric.ThroughputRegistry; -public class NotificationBasedTopicsCache - implements TopicCallback, TopicsCache { +public class NotificationBasedTopicsCache implements TopicCallback, TopicsCache { private static final Logger logger = LoggerFactory.getLogger(NotificationBasedTopicsCache.class); @@ -30,19 +29,20 @@ public class NotificationBasedTopicsCache private final KafkaNamesMapper kafkaNamesMapper; private final ThroughputRegistry throughputRegistry; - public NotificationBasedTopicsCache(InternalNotificationsBus notificationsBus, - GroupRepository groupRepository, - TopicRepository topicRepository, - MetricsFacade metricsFacade, - ThroughputRegistry throughputRegistry, - KafkaNamesMapper kafkaNamesMapper) { - this.groupRepository = groupRepository; - this.topicRepository = topicRepository; - this.metricsFacade = metricsFacade; - this.kafkaNamesMapper = kafkaNamesMapper; - this.throughputRegistry = throughputRegistry; - notificationsBus.registerTopicCallback(this); - } + public NotificationBasedTopicsCache( + InternalNotificationsBus notificationsBus, + GroupRepository groupRepository, + TopicRepository topicRepository, + MetricsFacade metricsFacade, + ThroughputRegistry throughputRegistry, + KafkaNamesMapper kafkaNamesMapper) { + this.groupRepository = groupRepository; + this.topicRepository = topicRepository; + this.metricsFacade = metricsFacade; + this.kafkaNamesMapper = kafkaNamesMapper; + this.throughputRegistry = throughputRegistry; + notificationsBus.registerTopicCallback(this); + } @Override public void onTopicCreated(Topic topic) { @@ -70,10 +70,10 @@ public void onTopicChanged(Topic topic) { topicCache.put(topic.getName().qualifiedName(), cachedTopic(topic)); } - @Override - public Optional getTopic(String qualifiedTopicName) { - return Optional.ofNullable(topicCache.get(qualifiedTopicName)); - } + @Override + public Optional getTopic(String qualifiedTopicName) { + return Optional.ofNullable(topicCache.get(qualifiedTopicName)); + } @Override public List getTopics() { @@ -89,7 +89,8 @@ public void start() { } } - private CachedTopic cachedTopic(Topic topic) { - return new CachedTopic(topic, metricsFacade, throughputRegistry, kafkaNamesMapper.toKafkaTopics(topic)); - } + private CachedTopic cachedTopic(Topic topic) { + return new CachedTopic( + topic, metricsFacade, throughputRegistry, kafkaNamesMapper.toKafkaTopics(topic)); + } } diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java index 9a4350b3dc..4949ed47b5 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/config/FrontendConfiguration.java @@ -3,7 +3,6 @@ import jakarta.inject.Named; import java.time.Clock; import java.util.List; -import org.apache.curator.framework.CuratorFramework; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -21,7 +20,6 @@ import pl.allegro.tech.hermes.frontend.producer.BrokerMessageProducer; import pl.allegro.tech.hermes.frontend.validator.MessageValidators; import pl.allegro.tech.hermes.frontend.validator.TopicMessageValidator; -import pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperPaths; import pl.allegro.tech.hermes.schema.SchemaExistenceEnsurer; import pl.allegro.tech.hermes.schema.SchemaRepository; import pl.allegro.tech.hermes.tracker.frontend.Trackers; diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java index 2456c63009..b416bd451b 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/metric/CachedTopic.java @@ -15,9 +15,9 @@ public class CachedTopic { - private final Topic topic; - private final KafkaTopics kafkaTopics; - private final MetricsFacade metricsFacade; + private final Topic topic; + private final KafkaTopics kafkaTopics; + private final MetricsFacade metricsFacade; private final HermesTimer topicProducerLatencyTimer; private final HermesTimer globalProducerLatencyTimer; diff --git a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java index d62f816dbc..757cb58161 100644 --- a/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java +++ b/hermes-frontend/src/main/java/pl/allegro/tech/hermes/frontend/publishing/handlers/TopicHandler.java @@ -66,12 +66,12 @@ private void onRequestValid( String topicName = exchange.getQueryParameters().get("qualifiedTopicName").getFirst(); Optional maybeTopic = topicsCache.getTopic(topicName); - if (!maybeTopic.isPresent()) { + if (maybeTopic.isEmpty()) { unknownTopic(exchange, topicName, messageId); return; } - CachedTopic cachedTopic = maybeTopic.get(); + CachedTopic cachedTopic = maybeTopic.get(); Topic topic = cachedTopic.getTopic(); if (topic.isAuthEnabled() && !hasPermission(exchange, topic)) { @@ -108,13 +108,11 @@ private void unknownTopic( UNKNOWN_TOPIC_NAME); } - private void requestForbidden(HttpServerExchange exchange, String messageId, String qualifiedTopicName) { - messageErrorProcessor.sendQuietly( - exchange, - error("Permission denied.", AUTH_ERROR), - messageId, - qualifiedTopicName); - } + private void requestForbidden( + HttpServerExchange exchange, String messageId, String qualifiedTopicName) { + messageErrorProcessor.sendQuietly( + exchange, error("Permission denied.", AUTH_ERROR), messageId, qualifiedTopicName); + } // Default Undertow's response code (200) was changed in order to avoid situations in which // something wrong happens and Hermes-Frontend diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java index 97efbf5fca..09a5565475 100644 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java +++ b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/storage/StorageConfiguration.java @@ -1,9 +1,6 @@ package pl.allegro.tech.hermes.management.config.storage; -import static org.slf4j.LoggerFactory.getLogger; - import com.fasterxml.jackson.databind.ObjectMapper; -import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -46,8 +43,6 @@ @EnableConfigurationProperties(StorageClustersProperties.class) public class StorageConfiguration { - private static final Logger logger = getLogger(StorageConfiguration.class); - @Autowired StorageClustersProperties storageClustersProperties; @Autowired ObjectMapper objectMapper; @@ -148,11 +143,12 @@ MessagePreviewRepository messagePreviewRepository() { localClient.getCuratorFramework(), objectMapper, zookeeperPaths()); } - @Bean - WorkloadConstraintsRepository workloadConstraintsRepository() { - ZookeeperClient localClient = clientManager().getLocalClient(); - return new ZookeeperWorkloadConstraintsRepository(localClient.getCuratorFramework(), objectMapper, zookeeperPaths()); - } + @Bean + WorkloadConstraintsRepository workloadConstraintsRepository() { + ZookeeperClient localClient = clientManager().getLocalClient(); + return new ZookeeperWorkloadConstraintsRepository( + localClient.getCuratorFramework(), objectMapper, zookeeperPaths()); + } @Bean @Primary diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java index cd5b97905a..a8bf06969d 100644 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java +++ b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/domain/topic/TopicService.java @@ -125,15 +125,16 @@ public void createTopicWithSchema( createTopic(topic, createdBy, isAllowedToManage); } - public void removeTopicWithSchema(Topic topic, RequestUser removedBy) { - auditor.beforeObjectRemoval(removedBy.getUsername(), Topic.class.getSimpleName(), topic.getQualifiedName()); - subscriptionRemover.removeSubscriptionRelatedToTopic(topic, removedBy); - removeSchema(topic); - if (!topicProperties.isAllowRemoval()) { - throw new TopicRemovalDisabledException(topic); - } - removeTopic(topic, removedBy); + public void removeTopicWithSchema(Topic topic, RequestUser removedBy) { + auditor.beforeObjectRemoval( + removedBy.getUsername(), Topic.class.getSimpleName(), topic.getQualifiedName()); + subscriptionRemover.removeSubscriptionRelatedToTopic(topic, removedBy); + removeSchema(topic); + if (!topicProperties.isAllowRemoval()) { + throw new TopicRemovalDisabledException(topic); } + removeTopic(topic, removedBy); + } public void updateTopicWithSchema(TopicName topicName, PatchData patch, RequestUser modifiedBy) { Topic topic = getTopicDetails(topicName); @@ -286,9 +287,7 @@ public List getAllTopics() { public Optional preview(TopicName topicName, int idx) { List result = - loadMessagePreviewsFromAllDc(topicName).stream() - .map(MessagePreview::getContent) - .collect(toList()); + loadMessagePreviewsFromAllDc(topicName).stream().map(MessagePreview::getContent).toList(); if (idx >= 0 && idx < result.size()) { return Optional.of(result.get(idx)); diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java index 9ca9772580..779d11e251 100644 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java +++ b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/infrastructure/zookeeper/ZookeeperRepositoryManager.java @@ -1,7 +1,6 @@ package pl.allegro.tech.hermes.management.infrastructure.zookeeper; import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -120,9 +119,9 @@ public void start() { new ZookeeperMessagePreviewRepository(zookeeper, mapper, paths); messagePreviewRepositoriesByDc.put(dcName, messagePreviewRepository); - WorkloadConstraintsRepository workloadConstraintsRepository = - new ZookeeperWorkloadConstraintsRepository(zookeeper, mapper, paths); - workloadConstraintsRepositoriesByDc.put(dcName, workloadConstraintsRepository); + WorkloadConstraintsRepository workloadConstraintsRepository = + new ZookeeperWorkloadConstraintsRepository(zookeeper, mapper, paths); + workloadConstraintsRepositoriesByDc.put(dcName, workloadConstraintsRepository); LastUndeliveredMessageReader lastUndeliveredMessageReader = new ZookeeperLastUndeliveredMessageReader(zookeeper, paths, mapper); @@ -167,7 +166,7 @@ public DatacenterBoundRepositoryHolder getLocalRepository(Class reposi public List> getRepositories(Class repositoryType) { return getRepositoriesByType(repositoryType).entrySet().stream() - .sorted(Comparator.comparing(Map.Entry::getKey)) + .sorted(Map.Entry.comparingByKey()) .map(entry -> new DatacenterBoundRepositoryHolder<>(entry.getValue(), entry.getKey())) .collect(Collectors.toList()); } diff --git a/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java b/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java index b4e4963fee..645ca978e4 100644 --- a/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java +++ b/integration-tests/src/integrationTest/java/pl/allegro/tech/hermes/integrationtests/management/TopicManagementTest.java @@ -143,11 +143,11 @@ public void shouldRemoveTopic() { () -> assertThat(getGroupTopicsList(topic.getName().getGroupName())).isEmpty()); } - @Test - public void shouldNotAllowOnDeletingTopicWithSubscriptions() { - // given - Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); - hermes.initHelper().createSubscription(subscriptionWithRandomName(topic.getName()).build()); + @Test + public void shouldNotAllowOnDeletingTopicWithSubscriptions() { + // given + Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build()); + hermes.initHelper().createSubscription(subscriptionWithRandomName(topic.getName()).build()); // when WebTestClient.ResponseSpec response = hermes.api().deleteTopic(topic.getQualifiedName()); From d42b69c46532484498fc72ed3d81974ec852a0b2 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Thu, 23 Jan 2025 18:39:34 +0100 Subject: [PATCH 4/4] Removed not needed change --- hermes-console/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hermes-console/package.json b/hermes-console/package.json index 3c69c5d96d..39a78a0357 100644 --- a/hermes-console/package.json +++ b/hermes-console/package.json @@ -12,8 +12,8 @@ "test:unit": "vitest --silent --environment jsdom", "build-only": "vite build", "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false", - "lint": "eslint src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore", - "lint:fix": "eslint src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore", + "lint:fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "dev-server": "node json-server/server.ts" }, "dependencies": {