From 685eb2bf19ade6538001db2bddb2053bbea67ec0 Mon Sep 17 00:00:00 2001 From: Julien Chanaud Date: Fri, 26 Nov 2021 23:27:36 +0100 Subject: [PATCH] Upgrade to Micronaut 3.1.4 (#112) * Prepare micronaut 3; refactor + passing test * Rework HttpClient in Connect test * Update gradle.properties * Migrate to 3.1.4 * Migrate to graalVM 21.3.0 --- .github/workflows/on_pull_request.yml | 2 +- .github/workflows/on_push_master.yml | 4 +- .github/workflows/on_push_tag.yml | 4 +- api/build.gradle | 6 ++- .../com/michelin/ns4kafka/Application.java | 2 - .../AccessControlListController.java | 2 +- .../AkhqClaimProviderController.java | 2 +- .../controllers/ConnectController.java | 2 +- .../controllers/ConsumerGroupController.java | 2 +- .../controllers/NamespaceController.java | 2 +- .../NamespacedResourceController.java | 2 +- .../controllers/ResourceController.java | 2 +- .../controllers/RoleBindingController.java | 2 +- .../controllers/StreamController.java | 2 +- .../ns4kafka/controllers/TopicController.java | 2 +- .../ns4kafka/logs/ConsoleLogListener.java | 2 +- .../ns4kafka/logs/KafkaLogListener.java | 4 +- .../kafka/DelayStartupListener.java | 2 +- .../KafkaAccessControlEntryRepository.java | 2 +- .../kafka/KafkaConnectorRepository.java | 2 +- .../kafka/KafkaNamespaceRepository.java | 2 +- .../kafka/KafkaRoleBindingRepository.java | 2 +- .../repositories/kafka/KafkaStore.java | 4 +- .../kafka/KafkaStreamRepository.java | 2 +- .../kafka/KafkaTopicRepository.java | 2 +- .../security/ResourceBasedSecurityRule.java | 24 ++++++---- .../security/gitlab/GitlabApiClient.java | 4 +- .../gitlab/GitlabAuthenticationProvider.java | 15 +++--- .../gitlab/GitlabAuthenticationService.java | 10 ++-- .../ldap/LdapAuthenticationMapper.java | 13 +++-- .../LocalUserAuthenticationProvider.java | 12 ++--- .../services/AccessControlEntryService.java | 4 +- .../services/ConsumerGroupService.java | 4 +- .../services/KafkaConnectService.java | 4 +- .../ns4kafka/services/NamespaceService.java | 4 +- .../ns4kafka/services/RoleBindingService.java | 4 +- .../ns4kafka/services/StreamService.java | 4 +- .../ns4kafka/services/TopicService.java | 4 +- .../connect/KafkaConnectClientProxy.java | 8 ++-- .../AccessControlEntryAsyncExecutor.java | 4 +- .../executors/ConnectorAsyncExecutor.java | 4 +- .../executors/ConsumerGroupAsyncExecutor.java | 2 +- .../KafkaAsyncExecutorScheduler.java | 4 +- .../executors/TopicAsyncExecutor.java | 4 +- .../AccessControlListControllerTest.java | 27 +++++------ .../ExceptionHandlerControllerTest.java | 4 +- .../integration/AccessControlListTest.java | 6 +-- .../ns4kafka/integration/ConnectTest.java | 23 ++++----- .../integration/ExceptionHandlerTest.java | 6 +-- .../ns4kafka/integration/LoginTest.java | 6 +-- .../ns4kafka/integration/StreamTest.java | 6 +-- .../ns4kafka/integration/TopicTest.java | 6 +-- .../GitlabAuthenticationProviderTest.java | 29 +++++------ .../GitlabAuthenticationServiceTest.java | 12 ++--- .../LocalUserAuthenticationProviderTest.java | 17 +++---- .../ResourceBasedSecurityRuleTest.java | 48 ++++++++++++------- .../services/KafkaConnectClientProxyTest.java | 31 ++++++------ api/src/test/resources/application-test.yml | 2 +- build.gradle | 2 +- .../ns4kafka/cli/ApiResourcesSubcommand.java | 2 +- .../ns4kafka/cli/ApplySubcommand.java | 2 +- .../ns4kafka/cli/ConnectorsSubcommand.java | 2 +- .../ns4kafka/cli/DeleteRecordsSubcommand.java | 2 +- .../ns4kafka/cli/DeleteSubcommand.java | 2 +- .../michelin/ns4kafka/cli/DiffSubcommand.java | 2 +- .../michelin/ns4kafka/cli/GetSubcommand.java | 2 +- .../ns4kafka/cli/ImportSubcommand.java | 2 +- .../ns4kafka/cli/KafkactlCommand.java | 4 +- .../ns4kafka/cli/ResetOffsetsSubcommand.java | 2 +- .../cli/services/ApiResourcesService.java | 4 +- .../ns4kafka/cli/services/FileService.java | 2 +- .../ns4kafka/cli/services/FormatService.java | 4 +- .../ns4kafka/cli/services/LoginService.java | 2 +- .../cli/services/ResourceService.java | 4 +- gradle.properties | 2 +- 75 files changed, 241 insertions(+), 218 deletions(-) diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index dfb7f732..f55ef99b 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -13,7 +13,7 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: DeLaGuardo/setup-graalvm@4.0 with: - graalvm: '21.1.0' + graalvm: '21.3.0' java: 'java11' - name: Install Native Image run: gu install native-image diff --git a/.github/workflows/on_push_master.yml b/.github/workflows/on_push_master.yml index ac6791a6..1f3d9b9f 100644 --- a/.github/workflows/on_push_master.yml +++ b/.github/workflows/on_push_master.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: DeLaGuardo/setup-graalvm@4.0 with: - graalvm: '21.1.0' + graalvm: '21.3.0' java: 'java11' - name: Install Native Image run: gu install native-image @@ -60,7 +60,7 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: DeLaGuardo/setup-graalvm@4.0 with: - graalvm: '20.3.2' + graalvm: '21.3.0' java: 'java11' - name: Install Native Image run: ${{ env.JAVA_HOME }}\bin\gu.cmd install native-image diff --git a/.github/workflows/on_push_tag.yml b/.github/workflows/on_push_tag.yml index 088be9b8..25a8e2ba 100644 --- a/.github/workflows/on_push_tag.yml +++ b/.github/workflows/on_push_tag.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: DeLaGuardo/setup-graalvm@4.0 with: - graalvm: '21.1.0' + graalvm: '21.3.0' java: 'java11' - name: Install Native Image run: gu install native-image @@ -62,7 +62,7 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: DeLaGuardo/setup-graalvm@4.0 with: - graalvm: '20.3.2' + graalvm: '21.3.0' java: 'java11' - name: Install Native Image run: ${{ env.JAVA_HOME }}\bin\gu.cmd install native-image diff --git a/api/build.gradle b/api/build.gradle index 4a200238..e7eabc24 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -21,14 +21,18 @@ micronaut { dependencies { compileOnly 'org.projectlombok:lombok:1.18.20' + compileOnly("com.google.code.findbugs:jsr305") + annotationProcessor 'org.projectlombok:lombok:1.18.20' annotationProcessor("io.micronaut.openapi:micronaut-openapi") annotationProcessor("io.micronaut:micronaut-management") annotationProcessor("io.micronaut.security:micronaut-security-annotations") annotationProcessor("io.swagger.core.v3:swagger-annotations") + annotationProcessor("io.micronaut:micronaut-http-validation") implementation("io.micronaut:micronaut-validation") implementation("io.micronaut:micronaut-runtime") + implementation("io.micronaut.rxjava3:micronaut-rxjava3") implementation("javax.annotation:javax.annotation-api") implementation("io.micronaut:micronaut-http-client") implementation("io.micronaut.openapi:micronaut-openapi") @@ -43,7 +47,7 @@ dependencies { testAnnotationProcessor 'org.projectlombok:lombok:1.18.20' testCompileOnly 'org.projectlombok:lombok:1.18.16' - + testImplementation("io.micronaut.rxjava3:micronaut-rxjava3-http-client:2.0.0") testImplementation 'org.testcontainers:kafka:1.15.3' testImplementation "org.testcontainers:junit-jupiter" testImplementation 'org.mockito:mockito-inline:3.7.7' diff --git a/api/src/main/java/com/michelin/ns4kafka/Application.java b/api/src/main/java/com/michelin/ns4kafka/Application.java index eaed6e80..1d923fb1 100644 --- a/api/src/main/java/com/michelin/ns4kafka/Application.java +++ b/api/src/main/java/com/michelin/ns4kafka/Application.java @@ -2,7 +2,6 @@ import io.micronaut.openapi.annotation.OpenAPIInclude; import io.micronaut.runtime.Micronaut; -import io.reactivex.plugins.RxJavaPlugins; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; @@ -30,7 +29,6 @@ public class Application { public static void main(String[] args) { - RxJavaPlugins.setErrorHandler(throwable -> {}); Micronaut.run(Application.class, args); } } diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/AccessControlListController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/AccessControlListController.java index e0f54260..a5b59d30 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/AccessControlListController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/AccessControlListController.java @@ -12,7 +12,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.time.Instant; import java.util.Comparator; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java index bb3eaf1b..4c530c63 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java @@ -12,7 +12,7 @@ import lombok.Getter; import javax.annotation.security.RolesAllowed; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.util.List; import java.util.Map; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/ConnectController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/ConnectController.java index 9cd2d1ed..39c42f4f 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/ConnectController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/ConnectController.java @@ -11,7 +11,7 @@ import io.micronaut.scheduling.annotation.ExecuteOn; import io.swagger.v3.oas.annotations.tags.Tag; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.time.Instant; import java.util.Date; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/ConsumerGroupController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/ConsumerGroupController.java index dc1070aa..351a62be 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/ConsumerGroupController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/ConsumerGroupController.java @@ -11,7 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.kafka.common.TopicPartition; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.time.Instant; import java.util.Date; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/NamespaceController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/NamespaceController.java index 81fb24d2..349b27b0 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/NamespaceController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/NamespaceController.java @@ -8,7 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import javax.annotation.security.RolesAllowed; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.time.Instant; import java.util.ArrayList; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/NamespacedResourceController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/NamespacedResourceController.java index 9b8faecd..c0bf0598 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/NamespacedResourceController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/NamespacedResourceController.java @@ -3,7 +3,7 @@ import com.michelin.ns4kafka.models.Namespace; import com.michelin.ns4kafka.services.NamespaceService; -import javax.inject.Inject; +import jakarta.inject.Inject; /** * Base Controller for all Namespaced resources diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/ResourceController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/ResourceController.java index 8dd1f3d4..08fcdf22 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/ResourceController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/ResourceController.java @@ -7,7 +7,7 @@ import io.micronaut.http.HttpResponse; import io.micronaut.security.utils.SecurityService; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.time.Instant; import java.util.Date; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/RoleBindingController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/RoleBindingController.java index 29723aee..6440e2e9 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/RoleBindingController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/RoleBindingController.java @@ -11,7 +11,7 @@ import io.micronaut.scheduling.annotation.ExecuteOn; import io.swagger.v3.oas.annotations.tags.Tag; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.time.Instant; import java.util.Date; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/StreamController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/StreamController.java index 92c83c98..4f60ccdf 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/StreamController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/StreamController.java @@ -8,7 +8,7 @@ import io.micronaut.http.annotation.*; import io.swagger.v3.oas.annotations.tags.Tag; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.time.Instant; import java.util.Date; diff --git a/api/src/main/java/com/michelin/ns4kafka/controllers/TopicController.java b/api/src/main/java/com/michelin/ns4kafka/controllers/TopicController.java index ea018494..c3889765 100644 --- a/api/src/main/java/com/michelin/ns4kafka/controllers/TopicController.java +++ b/api/src/main/java/com/michelin/ns4kafka/controllers/TopicController.java @@ -11,7 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.kafka.common.TopicPartition; -import javax.inject.Inject; +import jakarta.inject.Inject; import javax.validation.Valid; import java.time.Instant; import java.util.Date; diff --git a/api/src/main/java/com/michelin/ns4kafka/logs/ConsoleLogListener.java b/api/src/main/java/com/michelin/ns4kafka/logs/ConsoleLogListener.java index fa516b7f..e8a058b2 100644 --- a/api/src/main/java/com/michelin/ns4kafka/logs/ConsoleLogListener.java +++ b/api/src/main/java/com/michelin/ns4kafka/logs/ConsoleLogListener.java @@ -6,7 +6,7 @@ import io.micronaut.core.util.StringUtils; import lombok.extern.slf4j.Slf4j; -import javax.inject.Singleton; +import jakarta.inject.Singleton; @Slf4j @Singleton diff --git a/api/src/main/java/com/michelin/ns4kafka/logs/KafkaLogListener.java b/api/src/main/java/com/michelin/ns4kafka/logs/KafkaLogListener.java index af706d75..00ac6432 100644 --- a/api/src/main/java/com/michelin/ns4kafka/logs/KafkaLogListener.java +++ b/api/src/main/java/com/michelin/ns4kafka/logs/KafkaLogListener.java @@ -9,8 +9,8 @@ import io.micronaut.core.util.StringUtils; import io.micronaut.scheduling.annotation.Async; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; @Singleton @Requires(property = "ns4kafka.log.kafka.enabled", value = StringUtils.TRUE) diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/DelayStartupListener.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/DelayStartupListener.java index 7c431873..5eb39bc2 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/DelayStartupListener.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/DelayStartupListener.java @@ -6,7 +6,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.List; @Slf4j diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaAccessControlEntryRepository.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaAccessControlEntryRepository.java index c495a700..00d5acf4 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaAccessControlEntryRepository.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaAccessControlEntryRepository.java @@ -7,7 +7,7 @@ import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.producer.Producer; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.util.Collection; import java.util.Optional; diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaConnectorRepository.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaConnectorRepository.java index 75fee26f..9977b3b9 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaConnectorRepository.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaConnectorRepository.java @@ -7,7 +7,7 @@ import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.producer.Producer; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.util.List; import java.util.stream.Collectors; diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaNamespaceRepository.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaNamespaceRepository.java index c40784fe..3d9260e7 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaNamespaceRepository.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaNamespaceRepository.java @@ -7,7 +7,7 @@ import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.producer.Producer; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaRoleBindingRepository.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaRoleBindingRepository.java index ec03e3d3..37939748 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaRoleBindingRepository.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaRoleBindingRepository.java @@ -7,7 +7,7 @@ import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.producer.Producer; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStore.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStore.java index 587ead65..a4781d9c 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStore.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStore.java @@ -19,8 +19,8 @@ import org.apache.kafka.common.errors.TopicExistsException; import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Named; +import jakarta.inject.Inject; +import jakarta.inject.Named; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStreamRepository.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStreamRepository.java index 53ed681a..72018b1e 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStreamRepository.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaStreamRepository.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.stream.Collectors; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import com.michelin.ns4kafka.models.KafkaStream; import com.michelin.ns4kafka.repositories.StreamRepository; diff --git a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaTopicRepository.java b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaTopicRepository.java index 987dc53e..74699346 100644 --- a/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaTopicRepository.java +++ b/api/src/main/java/com/michelin/ns4kafka/repositories/kafka/KafkaTopicRepository.java @@ -10,7 +10,7 @@ import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.producer.Producer; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.util.List; import java.util.stream.Collectors; diff --git a/api/src/main/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRule.java b/api/src/main/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRule.java index 009e4d8d..a6d35398 100644 --- a/api/src/main/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRule.java +++ b/api/src/main/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRule.java @@ -4,18 +4,20 @@ import com.michelin.ns4kafka.repositories.NamespaceRepository; import com.michelin.ns4kafka.repositories.RoleBindingRepository; import io.micronaut.core.annotation.Nullable; +import io.micronaut.core.async.publisher.Publishers; import io.micronaut.core.util.StringUtils; import io.micronaut.http.HttpRequest; +import io.micronaut.security.authentication.Authentication; import io.micronaut.security.rules.SecurityRule; import io.micronaut.security.rules.SecurityRuleResult; import io.micronaut.web.router.RouteMatch; +import jakarta.inject.Singleton; import lombok.extern.slf4j.Slf4j; +import org.reactivestreams.Publisher; -import javax.inject.Singleton; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -39,18 +41,24 @@ public ResourceBasedSecurityRule(SecurityConfig securityConfig, RoleBindingRepos this.roleBindingRepository = roleBindingRepository; this.namespaceRepository = namespaceRepository; } - @Override - public SecurityRuleResult check(HttpRequest request, @Nullable RouteMatch routeMatch, @Nullable Map claims) { + public Publisher check(HttpRequest request, @Nullable RouteMatch routeMatch, @Nullable Authentication authentication) { + return Publishers.just(check_security(request, routeMatch, authentication)); + } + + public SecurityRuleResult check_security(HttpRequest request, @Nullable RouteMatch routeMatch, @Nullable Authentication authentication) { //Unauthenticated request - if (claims == null || !claims.keySet().containsAll( List.of("groups", "sub", "roles"))) { + if(authentication == null){ + return SecurityRuleResult.UNKNOWN; + } + if (!authentication.getAttributes().keySet().containsAll( List.of("groups", "sub", "roles"))) { log.debug("No Authentication available for path [{}]. Returning unknown.",request.getPath()); return SecurityRuleResult.UNKNOWN; } - String sub = claims.get("sub").toString(); - List groups = (List) claims.get("groups"); - List roles = (List) claims.get("roles"); + String sub = authentication.getName(); + List groups = (List) authentication.getAttributes().get("groups"); + Collection roles = authentication.getRoles(); //Request to a URL that is not in the scope of this SecurityRule Matcher matcher = namespacedResourcePattern.matcher(request.getPath()); diff --git a/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabApiClient.java b/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabApiClient.java index 63aea6bb..04f8bbd4 100644 --- a/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabApiClient.java +++ b/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabApiClient.java @@ -4,13 +4,11 @@ import io.micronaut.http.annotation.Get; import io.micronaut.http.annotation.Header; import io.micronaut.http.client.annotation.Client; -import io.reactivex.Flowable; +import io.reactivex.rxjava3.core.Flowable; import java.util.List; import java.util.Map; -import static io.micronaut.http.HttpRequest.GET; - @Client("${micronaut.security.gitlab.url}") public interface GitlabApiClient { @Get("/api/v4/groups?min_access_level=10&sort=asc&page={page}") diff --git a/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationProvider.java b/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationProvider.java index d6f10a03..a39ac78a 100644 --- a/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationProvider.java +++ b/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationProvider.java @@ -1,17 +1,17 @@ package com.michelin.ns4kafka.security.gitlab; import com.michelin.ns4kafka.security.ResourceBasedSecurityRule; -import edu.umd.cs.findbugs.annotations.Nullable; +import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpRequest; import io.micronaut.security.authentication.*; -import io.reactivex.BackpressureStrategy; -import io.reactivex.Flowable; -import io.reactivex.schedulers.Schedulers; +import io.reactivex.rxjava3.core.BackpressureStrategy; +import io.reactivex.rxjava3.core.Flowable; +import io.reactivex.rxjava3.schedulers.Schedulers; import lombok.extern.slf4j.Slf4j; import org.reactivestreams.Publisher; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.Map; @@ -35,8 +35,7 @@ public Publisher authenticate(@Nullable HttpRequest h String username = gitlabAuthenticationService.findUsername(token).blockingGet(); List groups = gitlabAuthenticationService.findAllGroups(token).toList().blockingGet(); - UserDetails user = new UserDetails(username, resourceBasedSecurityRule.computeRolesFromGroups(groups), Map.of("groups", groups)); - + AuthenticationResponse user = AuthenticationResponse.success(username, resourceBasedSecurityRule.computeRolesFromGroups(groups), Map.of("groups", groups)); emitter.onNext(user); emitter.onComplete(); }catch (Exception e){ diff --git a/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationService.java b/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationService.java index d222e959..87daa01f 100644 --- a/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationService.java +++ b/api/src/main/java/com/michelin/ns4kafka/security/gitlab/GitlabAuthenticationService.java @@ -2,18 +2,16 @@ import io.micronaut.core.util.StringUtils; import io.micronaut.http.HttpResponse; -import io.reactivex.Flowable; -import io.reactivex.Maybe; +import io.reactivex.rxjava3.core.Flowable; +import io.reactivex.rxjava3.core.Maybe; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static io.micronaut.http.HttpRequest.GET; - @Slf4j @Singleton public class GitlabAuthenticationService { diff --git a/api/src/main/java/com/michelin/ns4kafka/security/ldap/LdapAuthenticationMapper.java b/api/src/main/java/com/michelin/ns4kafka/security/ldap/LdapAuthenticationMapper.java index edfd79ee..1bfb4a6e 100644 --- a/api/src/main/java/com/michelin/ns4kafka/security/ldap/LdapAuthenticationMapper.java +++ b/api/src/main/java/com/michelin/ns4kafka/security/ldap/LdapAuthenticationMapper.java @@ -1,18 +1,17 @@ package com.michelin.ns4kafka.security.ldap; import com.michelin.ns4kafka.security.ResourceBasedSecurityRule; -import io.micronaut.configuration.security.ldap.ContextAuthenticationMapper; -import io.micronaut.configuration.security.ldap.DefaultContextAuthenticationMapper; -import io.micronaut.configuration.security.ldap.configuration.LdapConfiguration; import io.micronaut.context.annotation.Replaces; import io.micronaut.context.annotation.Requires; import io.micronaut.core.convert.value.ConvertibleValues; import io.micronaut.core.util.StringUtils; import io.micronaut.security.authentication.AuthenticationResponse; -import io.micronaut.security.authentication.UserDetails; +import io.micronaut.security.ldap.ContextAuthenticationMapper; +import io.micronaut.security.ldap.DefaultContextAuthenticationMapper; +import io.micronaut.security.ldap.configuration.LdapConfiguration; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; -import javax.inject.Inject; -import javax.inject.Singleton; import java.util.List; import java.util.Map; import java.util.Set; @@ -26,6 +25,6 @@ public class LdapAuthenticationMapper implements ContextAuthenticationMapper { ResourceBasedSecurityRule resourceBasedSecurityRule; @Override public AuthenticationResponse map(ConvertibleValues attributes, String username, Set groups) { - return new UserDetails(username, resourceBasedSecurityRule.computeRolesFromGroups(List.copyOf(groups)), Map.of("groups",groups)); + return AuthenticationResponse.success(username, resourceBasedSecurityRule.computeRolesFromGroups(List.copyOf(groups)), Map.of("groups",groups)); } } diff --git a/api/src/main/java/com/michelin/ns4kafka/security/local/LocalUserAuthenticationProvider.java b/api/src/main/java/com/michelin/ns4kafka/security/local/LocalUserAuthenticationProvider.java index f5a96d6f..ac8d588d 100644 --- a/api/src/main/java/com/michelin/ns4kafka/security/local/LocalUserAuthenticationProvider.java +++ b/api/src/main/java/com/michelin/ns4kafka/security/local/LocalUserAuthenticationProvider.java @@ -2,16 +2,16 @@ import com.michelin.ns4kafka.security.ResourceBasedSecurityRule; import com.michelin.ns4kafka.security.SecurityConfig; -import edu.umd.cs.findbugs.annotations.Nullable; +import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpRequest; import io.micronaut.security.authentication.*; -import io.reactivex.BackpressureStrategy; -import io.reactivex.Flowable; +import io.reactivex.rxjava3.core.BackpressureStrategy; +import io.reactivex.rxjava3.core.Flowable; import lombok.extern.slf4j.Slf4j; import org.reactivestreams.Publisher; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.Map; import java.util.Optional; @@ -35,7 +35,7 @@ public Publisher authenticate(@Nullable HttpRequest h .filter(localUser -> localUser.isValidPassword(password)) .findFirst(); if (authenticatedUser.isPresent()) { - UserDetails user = new UserDetails(username, + AuthenticationResponse user = AuthenticationResponse.success(username, resourceBasedSecurityRule.computeRolesFromGroups(authenticatedUser.get().getGroups()), Map.of("groups", authenticatedUser.get().getGroups())); emitter.onNext(user); diff --git a/api/src/main/java/com/michelin/ns4kafka/services/AccessControlEntryService.java b/api/src/main/java/com/michelin/ns4kafka/services/AccessControlEntryService.java index 49bfda46..eb170e52 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/AccessControlEntryService.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/AccessControlEntryService.java @@ -5,8 +5,8 @@ import com.michelin.ns4kafka.repositories.AccessControlEntryRepository; import io.micronaut.context.ApplicationContext; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.Optional; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/ConsumerGroupService.java b/api/src/main/java/com/michelin/ns4kafka/services/ConsumerGroupService.java index 62df9fb4..094e7484 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/ConsumerGroupService.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/ConsumerGroupService.java @@ -9,8 +9,8 @@ import io.micronaut.inject.qualifiers.Qualifiers; import org.apache.kafka.common.TopicPartition; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.time.Duration; import java.time.Instant; import java.time.OffsetDateTime; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/KafkaConnectService.java b/api/src/main/java/com/michelin/ns4kafka/services/KafkaConnectService.java index 105f649a..bf0465a0 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/KafkaConnectService.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/KafkaConnectService.java @@ -16,8 +16,8 @@ import io.micronaut.inject.qualifiers.Qualifiers; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.Locale; import java.util.Optional; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/NamespaceService.java b/api/src/main/java/com/michelin/ns4kafka/services/NamespaceService.java index 8d87b11f..e2bdc10c 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/NamespaceService.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/NamespaceService.java @@ -4,8 +4,8 @@ import com.michelin.ns4kafka.repositories.NamespaceRepository; import com.michelin.ns4kafka.services.executors.KafkaAsyncExecutorConfig; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.Optional; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/RoleBindingService.java b/api/src/main/java/com/michelin/ns4kafka/services/RoleBindingService.java index 05fbd51f..0d09d88f 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/RoleBindingService.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/RoleBindingService.java @@ -3,8 +3,8 @@ import com.michelin.ns4kafka.models.RoleBinding; import com.michelin.ns4kafka.repositories.RoleBindingRepository; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.Optional; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/StreamService.java b/api/src/main/java/com/michelin/ns4kafka/services/StreamService.java index 232dfab2..d6cb001b 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/StreamService.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/StreamService.java @@ -3,8 +3,8 @@ import com.michelin.ns4kafka.models.*; import com.michelin.ns4kafka.repositories.StreamRepository; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.*; import java.util.stream.Collectors; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/TopicService.java b/api/src/main/java/com/michelin/ns4kafka/services/TopicService.java index 965069eb..c6c0088e 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/TopicService.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/TopicService.java @@ -8,8 +8,8 @@ import org.apache.kafka.clients.admin.RecordsToDelete; import org.apache.kafka.common.TopicPartition; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/connect/KafkaConnectClientProxy.java b/api/src/main/java/com/michelin/ns4kafka/services/connect/KafkaConnectClientProxy.java index ccfeab6f..8dd15a06 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/connect/KafkaConnectClientProxy.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/connect/KafkaConnectClientProxy.java @@ -11,18 +11,18 @@ import io.micronaut.http.MutableHttpResponse; import io.micronaut.http.annotation.Filter; import io.micronaut.http.client.ProxyHttpClient; -import io.micronaut.http.filter.OncePerRequestHttpServerFilter; +import io.micronaut.http.filter.HttpServerFilter; import io.micronaut.http.filter.ServerFilterChain; +import jakarta.inject.Inject; import org.reactivestreams.Publisher; -import javax.inject.Inject; import java.net.URI; import java.util.List; import java.util.Optional; import java.util.UUID; @Filter(KafkaConnectClientProxy.PROXY_PREFIX + "/**") -public class KafkaConnectClientProxy extends OncePerRequestHttpServerFilter { +public class KafkaConnectClientProxy implements HttpServerFilter { public static final String PROXY_PREFIX = "/connect-proxy"; public static final String PROXY_HEADER_KAFKA_CLUSTER = "X-Kafka-Cluster"; public static final String PROXY_HEADER_CONNECT_CLUSTER = "X-Connect-Cluster"; @@ -38,7 +38,7 @@ public class KafkaConnectClientProxy extends OncePerRequestHttpServerFilter { List kafkaAsyncExecutorConfigs; @Override - public Publisher> doFilterOnce(HttpRequest request, ServerFilterChain chain) { + public Publisher> doFilter(HttpRequest request, ServerFilterChain chain) { // check call is initiated from micronaut and not from outisde if (!request.getHeaders().contains(KafkaConnectClientProxy.PROXY_HEADER_SECRET)) { return Publishers.just(new ResourceValidationException(List.of("Missing required Header " + KafkaConnectClientProxy.PROXY_HEADER_SECRET), null, null)); diff --git a/api/src/main/java/com/michelin/ns4kafka/services/executors/AccessControlEntryAsyncExecutor.java b/api/src/main/java/com/michelin/ns4kafka/services/executors/AccessControlEntryAsyncExecutor.java index f69aa332..bc182b1c 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/executors/AccessControlEntryAsyncExecutor.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/executors/AccessControlEntryAsyncExecutor.java @@ -20,8 +20,8 @@ import org.apache.kafka.common.resource.ResourcePattern; import org.apache.kafka.common.resource.ResourceType; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/executors/ConnectorAsyncExecutor.java b/api/src/main/java/com/michelin/ns4kafka/services/executors/ConnectorAsyncExecutor.java index 5e75ff5e..89206c56 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/executors/ConnectorAsyncExecutor.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/executors/ConnectorAsyncExecutor.java @@ -11,8 +11,8 @@ import io.micronaut.http.client.exceptions.ReadTimeoutException; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.Map; import java.util.stream.Collectors; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/executors/ConsumerGroupAsyncExecutor.java b/api/src/main/java/com/michelin/ns4kafka/services/executors/ConsumerGroupAsyncExecutor.java index 4fea82dc..a422aed1 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/executors/ConsumerGroupAsyncExecutor.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/executors/ConsumerGroupAsyncExecutor.java @@ -8,7 +8,7 @@ import org.apache.kafka.clients.consumer.OffsetAndMetadata; import org.apache.kafka.common.TopicPartition; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/executors/KafkaAsyncExecutorScheduler.java b/api/src/main/java/com/michelin/ns4kafka/services/executors/KafkaAsyncExecutorScheduler.java index 7f2ca533..0adf8c34 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/executors/KafkaAsyncExecutorScheduler.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/executors/KafkaAsyncExecutorScheduler.java @@ -7,8 +7,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/api/src/main/java/com/michelin/ns4kafka/services/executors/TopicAsyncExecutor.java b/api/src/main/java/com/michelin/ns4kafka/services/executors/TopicAsyncExecutor.java index 12bddc15..de7105c2 100644 --- a/api/src/main/java/com/michelin/ns4kafka/services/executors/TopicAsyncExecutor.java +++ b/api/src/main/java/com/michelin/ns4kafka/services/executors/TopicAsyncExecutor.java @@ -10,8 +10,8 @@ import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.config.ConfigResource; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.net.MalformedURLException; import java.time.Instant; import java.util.*; diff --git a/api/src/test/java/com/michelin/ns4kafka/controllers/AccessControlListControllerTest.java b/api/src/test/java/com/michelin/ns4kafka/controllers/AccessControlListControllerTest.java index 78c86182..2861f236 100644 --- a/api/src/test/java/com/michelin/ns4kafka/controllers/AccessControlListControllerTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/controllers/AccessControlListControllerTest.java @@ -10,7 +10,6 @@ import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; import io.micronaut.security.authentication.Authentication; -import io.micronaut.security.authentication.DefaultAuthentication; import io.micronaut.security.utils.SecurityService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -239,7 +238,7 @@ void applyAsAdmin_Failure() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("admin", Map.of("roles",List.of("isAdmin()"))); + Authentication auth = Authentication.build("admin", Map.of("roles",List.of("isAdmin()"))); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -266,7 +265,7 @@ void applyAsAdmin_Success() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("admin", Map.of("roles",List.of("isAdmin()"))); + Authentication auth = Authentication.build("admin", Map.of("roles",List.of("isAdmin()"))); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -298,7 +297,7 @@ void applyValidationErrors() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -326,7 +325,7 @@ void applySuccess() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -360,7 +359,7 @@ void applySuccess_AlreadyExists() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -404,7 +403,7 @@ void applySuccess_ChangedResource() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -441,7 +440,7 @@ void applyDryRunAdmin() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("admin", Map.of("roles",List.of("isAdmin()"))); + Authentication auth = Authentication.build("admin", Map.of("roles",List.of("isAdmin()"))); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -470,7 +469,7 @@ void applyDryRun() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(namespaceService.findByName("test")) .thenReturn(Optional.of(ns)); @@ -496,7 +495,7 @@ void deleteFailNotFound() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(accessControlEntryService.findByName("test", "ace1")) .thenReturn(Optional.empty()); @@ -518,7 +517,7 @@ void deleteFailSelfAssigned() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(accessControlEntryService.findByName("test", "ace1")) .thenReturn(Optional.of(ace1)); @@ -542,7 +541,7 @@ void deleteSuccessSelfAssigned_AsAdmin() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of("isAdmin()"))); + Authentication auth = Authentication.build("user", Map.of("roles",List.of("isAdmin()"))); Mockito.when(accessControlEntryService.findByName("test", "ace1")) .thenReturn(Optional.of(ace1)); @@ -565,7 +564,7 @@ void deleteSuccess() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(accessControlEntryService.findByName("test", "ace1")) .thenReturn(Optional.of(ace1)); @@ -591,7 +590,7 @@ void deleteDryRun() { .build() ) .build(); - Authentication auth = new DefaultAuthentication("user", Map.of("roles",List.of())); + Authentication auth = Authentication.build("user", Map.of("roles",List.of())); Mockito.when(accessControlEntryService.findByName("test", "ace1")) .thenReturn(Optional.of(ace1)); diff --git a/api/src/test/java/com/michelin/ns4kafka/controllers/ExceptionHandlerControllerTest.java b/api/src/test/java/com/michelin/ns4kafka/controllers/ExceptionHandlerControllerTest.java index 5b209392..a691b513 100644 --- a/api/src/test/java/com/michelin/ns4kafka/controllers/ExceptionHandlerControllerTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/controllers/ExceptionHandlerControllerTest.java @@ -1,5 +1,6 @@ package com.michelin.ns4kafka.controllers; +import io.micronaut.security.authentication.Authentication; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -9,7 +10,6 @@ import io.micronaut.http.HttpStatus; import io.micronaut.security.authentication.AuthenticationException; import io.micronaut.security.authentication.AuthorizationException; -import io.micronaut.security.authentication.DefaultAuthentication; import javax.validation.ConstraintViolationException; import java.util.List; @@ -60,7 +60,7 @@ void authorizationUnauthorizedError() { @Test void authorizationForbiddenError() { var response = exceptionHandlerController.error(HttpRequest.create(HttpMethod.POST, "local") - ,new AuthorizationException(new DefaultAuthentication("user", Map.of()))); + ,new AuthorizationException(Authentication.build("user", Map.of()))); var status = response.body(); Assertions.assertEquals(HttpStatus.FORBIDDEN, response.getStatus()); diff --git a/api/src/test/java/com/michelin/ns4kafka/integration/AccessControlListTest.java b/api/src/test/java/com/michelin/ns4kafka/integration/AccessControlListTest.java index b90566b5..095a56cd 100644 --- a/api/src/test/java/com/michelin/ns4kafka/integration/AccessControlListTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/integration/AccessControlListTest.java @@ -18,16 +18,16 @@ import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; -import io.micronaut.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; +import io.micronaut.rxjava3.http.client.Rx3HttpClient; import io.micronaut.security.authentication.UsernamePasswordCredentials; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import jakarta.inject.Inject; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import javax.inject.Inject; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -39,7 +39,7 @@ public class AccessControlListTest extends AbstractIntegrationTest { @Inject @Client("/") - RxHttpClient client; + Rx3HttpClient client; @Inject List topicAsyncExecutorList; diff --git a/api/src/test/java/com/michelin/ns4kafka/integration/ConnectTest.java b/api/src/test/java/com/michelin/ns4kafka/integration/ConnectTest.java index 77cd1581..84ac8f06 100644 --- a/api/src/test/java/com/michelin/ns4kafka/integration/ConnectTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/integration/ConnectTest.java @@ -19,15 +19,16 @@ import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; -import io.micronaut.http.client.RxHttpClient; +import io.micronaut.http.client.HttpClient; import io.micronaut.http.client.annotation.Client; +import io.micronaut.rxjava3.http.client.Rx3HttpClient; import io.micronaut.security.authentication.UsernamePasswordCredentials; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import jakarta.inject.Inject; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import javax.inject.Inject; import java.net.MalformedURLException; import java.net.URL; import java.util.List; @@ -40,7 +41,9 @@ public class ConnectTest extends AbstractIntegrationConnectTest { @Inject @Client("/") - RxHttpClient client; + Rx3HttpClient client; + + HttpClient connectClient; @Inject List topicAsyncExecutorList; @@ -50,7 +53,8 @@ public class ConnectTest extends AbstractIntegrationConnectTest { private String token; @BeforeAll - void init() { + void init() throws MalformedURLException { + connectClient = HttpClient.create(new URL(connect.getUrl())); Namespace ns1 = Namespace.builder() .metadata(ObjectMeta.builder() .name("ns1") @@ -125,10 +129,8 @@ void init() { } @Test - void createConnect() throws InterruptedException, ExecutionException, MalformedURLException { - - RxHttpClient connectCli = RxHttpClient.create(new URL(connect.getUrl())); - ServerInfo actual = connectCli.retrieve(HttpRequest.GET("/"), ServerInfo.class).blockingFirst(); + void createConnect() { + ServerInfo actual = connectClient.toBlocking().retrieve(HttpRequest.GET(connect.getUrl()), ServerInfo.class); Assertions.assertEquals("6.2.0-ccs", actual.version()); } @@ -201,7 +203,6 @@ void restartConnector() throws InterruptedException, ExecutionException, Malform @Test void PauseAndResumeConnector() throws MalformedURLException, InterruptedException { - RxHttpClient connectCli = RxHttpClient.create(new URL(connect.getUrl())); Topic to = Topic.builder() .metadata(ObjectMeta.builder() .name("ns1-to1") @@ -247,7 +248,7 @@ void PauseAndResumeConnector() throws MalformedURLException, InterruptedExceptio Thread.sleep(2000); // verify paused directly on connect cluster - ConnectorStateInfo actual = connectCli.retrieve(HttpRequest.GET("/connectors/ns1-co2/status"), ConnectorStateInfo.class).blockingFirst(); + ConnectorStateInfo actual = connectClient.toBlocking().retrieve(HttpRequest.GET("/connectors/ns1-co2/status"), ConnectorStateInfo.class); Assertions.assertEquals("PAUSED", actual.connector().state()); Assertions.assertEquals("PAUSED", actual.tasks().get(0).state()); Assertions.assertEquals("PAUSED", actual.tasks().get(1).state()); @@ -262,7 +263,7 @@ void PauseAndResumeConnector() throws MalformedURLException, InterruptedExceptio Thread.sleep(2000); // verify resumed directly on connect cluster - actual = connectCli.retrieve(HttpRequest.GET("/connectors/ns1-co2/status"), ConnectorStateInfo.class).blockingFirst(); + actual = connectClient.toBlocking().retrieve(HttpRequest.GET("/connectors/ns1-co2/status"), ConnectorStateInfo.class); Assertions.assertEquals("RUNNING", actual.connector().state()); Assertions.assertEquals("RUNNING", actual.tasks().get(0).state()); Assertions.assertEquals("RUNNING", actual.tasks().get(1).state()); diff --git a/api/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerTest.java b/api/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerTest.java index 204be361..34f62b24 100644 --- a/api/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerTest.java @@ -1,6 +1,7 @@ package com.michelin.ns4kafka.integration; -import javax.inject.Inject; +import io.micronaut.rxjava3.http.client.Rx3HttpClient; +import jakarta.inject.Inject; import com.michelin.ns4kafka.integration.TopicTest.BearerAccessRefreshToken; import com.michelin.ns4kafka.models.AccessControlEntry; @@ -31,7 +32,6 @@ import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; -import io.micronaut.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; import io.micronaut.http.client.exceptions.HttpClientResponseException; import io.micronaut.security.authentication.UsernamePasswordCredentials; @@ -47,7 +47,7 @@ public class ExceptionHandlerTest extends AbstractIntegrationTest { @Inject @Client("/") - RxHttpClient client; + Rx3HttpClient client; private String token; diff --git a/api/src/test/java/com/michelin/ns4kafka/integration/LoginTest.java b/api/src/test/java/com/michelin/ns4kafka/integration/LoginTest.java index 06068552..65a76ef9 100644 --- a/api/src/test/java/com/michelin/ns4kafka/integration/LoginTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/integration/LoginTest.java @@ -4,14 +4,14 @@ import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; -import io.micronaut.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; +import io.micronaut.rxjava3.http.client.Rx3HttpClient; import io.micronaut.security.authentication.UsernamePasswordCredentials; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import javax.inject.Inject; +import jakarta.inject.Inject; @MicronautTest @Property(name = "micronaut.security.gitlab.enabled", value = "false") @@ -19,7 +19,7 @@ public class LoginTest extends AbstractIntegrationTest { @Inject @Client("/") - RxHttpClient client; + Rx3HttpClient client; @Test void login(){ diff --git a/api/src/test/java/com/michelin/ns4kafka/integration/StreamTest.java b/api/src/test/java/com/michelin/ns4kafka/integration/StreamTest.java index adec1696..30859e38 100644 --- a/api/src/test/java/com/michelin/ns4kafka/integration/StreamTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/integration/StreamTest.java @@ -14,10 +14,11 @@ import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; -import io.micronaut.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; +import io.micronaut.rxjava3.http.client.Rx3HttpClient; import io.micronaut.security.authentication.UsernamePasswordCredentials; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import jakarta.inject.Inject; import org.apache.kafka.clients.admin.Admin; import org.apache.kafka.common.acl.AccessControlEntryFilter; import org.apache.kafka.common.acl.AclBindingFilter; @@ -28,7 +29,6 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import javax.inject.Inject; import java.util.List; import java.util.concurrent.ExecutionException; @@ -39,7 +39,7 @@ public class StreamTest extends AbstractIntegrationTest { @Inject @Client("/") - RxHttpClient client; + Rx3HttpClient client; @Inject List aceAsyncExecutorList; diff --git a/api/src/test/java/com/michelin/ns4kafka/integration/TopicTest.java b/api/src/test/java/com/michelin/ns4kafka/integration/TopicTest.java index a8f51550..ce3c4148 100644 --- a/api/src/test/java/com/michelin/ns4kafka/integration/TopicTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/integration/TopicTest.java @@ -18,9 +18,9 @@ import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; -import io.micronaut.http.client.RxHttpClient; import io.micronaut.http.client.annotation.Client; import io.micronaut.http.client.exceptions.HttpClientResponseException; +import io.micronaut.rxjava3.http.client.Rx3HttpClient; import io.micronaut.security.authentication.UsernamePasswordCredentials; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import lombok.AllArgsConstructor; @@ -34,7 +34,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.Collection; import java.util.List; import java.util.Map; @@ -49,7 +49,7 @@ public class TopicTest extends AbstractIntegrationTest { @Inject @Client("/") - RxHttpClient client; + Rx3HttpClient client; @Inject List topicAsyncExecutorList; diff --git a/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationProviderTest.java b/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationProviderTest.java index fbebb3da..f284cc69 100644 --- a/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationProviderTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationProviderTest.java @@ -5,9 +5,9 @@ import io.micronaut.http.HttpResponse; import io.micronaut.http.client.exceptions.HttpClientResponseException; import io.micronaut.security.authentication.*; -import io.reactivex.Flowable; -import io.reactivex.Maybe; -import io.reactivex.subscribers.TestSubscriber; +import io.reactivex.rxjava3.core.Flowable; +import io.reactivex.rxjava3.core.Maybe; +import io.reactivex.rxjava3.subscribers.TestSubscriber; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -17,6 +17,7 @@ import org.reactivestreams.Publisher; import java.util.List; +import java.util.concurrent.TimeUnit; import static org.mockito.Mockito.when; @@ -45,7 +46,7 @@ public void authenticationSuccess(){ Publisher authenticationResponsePublisher = gitlabAuthenticationProvider.authenticate(null, authenticationRequest); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); //then @@ -55,11 +56,11 @@ public void authenticationSuccess(){ AuthenticationResponse actual = subscriber.values().get(0); Assertions.assertTrue(actual.isAuthenticated()); - Assertions.assertTrue(actual.getUserDetails().isPresent()); + Assertions.assertTrue(actual.getAuthentication().isPresent()); - UserDetails actualUserDetails = actual.getUserDetails().get(); - Assertions.assertEquals("email", actualUserDetails.getUsername()); - Assertions.assertIterableEquals(groups, (List)actualUserDetails.getAttributes("roles","username").get( "groups")); + Authentication actualUserDetails = actual.getAuthentication().get(); + Assertions.assertEquals("email", actualUserDetails.getName()); + Assertions.assertIterableEquals(groups, (List)actualUserDetails.getAttributes().get( "groups")); Assertions.assertIterableEquals(List.of(), actualUserDetails.getRoles(),"User has no custom roles"); } @@ -80,7 +81,7 @@ public void authenticationSuccessAdmin(){ Publisher authenticationResponsePublisher = gitlabAuthenticationProvider.authenticate(null, authenticationRequest); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); //then @@ -90,11 +91,11 @@ public void authenticationSuccessAdmin(){ AuthenticationResponse actual = subscriber.values().get(0); Assertions.assertTrue(actual.isAuthenticated()); - Assertions.assertTrue(actual.getUserDetails().isPresent()); + Assertions.assertTrue(actual.getAuthentication().isPresent()); - UserDetails actualUserDetails = actual.getUserDetails().get(); - Assertions.assertEquals("email", actualUserDetails.getUsername()); - Assertions.assertIterableEquals(groups, (List)actualUserDetails.getAttributes("roles","username").get("groups")); + Authentication actualUserDetails = actual.getAuthentication().get(); + Assertions.assertEquals("email", actualUserDetails.getName()); + Assertions.assertIterableEquals(groups, (List)actualUserDetails.getAttributes().get("groups")); Assertions.assertIterableEquals(List.of(ResourceBasedSecurityRule.IS_ADMIN), actualUserDetails.getRoles(),"User has custom roles"); } @@ -111,7 +112,7 @@ public void authenticationFailure(){ Publisher authenticationResponsePublisher = gitlabAuthenticationProvider.authenticate(null, authenticationRequest); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); //then subscriber.assertError(AuthenticationException.class); diff --git a/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationServiceTest.java b/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationServiceTest.java index 7778bf89..e98a41a2 100644 --- a/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationServiceTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/security/GitlabAuthenticationServiceTest.java @@ -3,9 +3,8 @@ import com.michelin.ns4kafka.security.gitlab.GitlabApiClient; import com.michelin.ns4kafka.security.gitlab.GitlabAuthenticationService; import io.micronaut.http.HttpResponse; -import io.micronaut.security.authentication.AuthenticationResponse; -import io.reactivex.Flowable; -import io.reactivex.subscribers.TestSubscriber; +import io.reactivex.rxjava3.core.Flowable; +import io.reactivex.rxjava3.subscribers.TestSubscriber; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -17,6 +16,7 @@ import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; @ExtendWith(MockitoExtension.class) public class GitlabAuthenticationServiceTest { @@ -37,7 +37,7 @@ void findUserSuccess(){ Publisher authenticationResponsePublisher = gitlabAuthenticationService.findUsername(token).toFlowable(); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertComplete(); subscriber.assertNoErrors(); @@ -62,7 +62,7 @@ void findGroupsOnePage(){ Publisher authenticationResponsePublisher = gitlabAuthenticationService.findAllGroups(token); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertComplete(); subscriber.assertNoErrors(); @@ -102,7 +102,7 @@ void findGroupsThreePages(){ Publisher authenticationResponsePublisher = gitlabAuthenticationService.findAllGroups(token); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertComplete(); subscriber.assertNoErrors(); diff --git a/api/src/test/java/com/michelin/ns4kafka/security/LocalUserAuthenticationProviderTest.java b/api/src/test/java/com/michelin/ns4kafka/security/LocalUserAuthenticationProviderTest.java index a3c2a0e0..862b5f7f 100644 --- a/api/src/test/java/com/michelin/ns4kafka/security/LocalUserAuthenticationProviderTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/security/LocalUserAuthenticationProviderTest.java @@ -2,10 +2,10 @@ import com.michelin.ns4kafka.security.local.LocalUser; import com.michelin.ns4kafka.security.local.LocalUserAuthenticationProvider; +import io.micronaut.security.authentication.Authentication; import io.micronaut.security.authentication.AuthenticationResponse; -import io.micronaut.security.authentication.UserDetails; import io.micronaut.security.authentication.UsernamePasswordCredentials; -import io.reactivex.subscribers.TestSubscriber; +import io.reactivex.rxjava3.subscribers.TestSubscriber; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -17,6 +17,7 @@ import org.reactivestreams.Publisher; import java.util.List; +import java.util.concurrent.TimeUnit; @ExtendWith(MockitoExtension.class) public class LocalUserAuthenticationProviderTest { @@ -38,7 +39,7 @@ void authenticateNoMatchUser() { Publisher authenticationResponsePublisher = localUserAuthenticationProvider.authenticate(null, credentials); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); //then @@ -60,7 +61,7 @@ void authenticateMatchUserNoMatchPassword() { Publisher authenticationResponsePublisher = localUserAuthenticationProvider.authenticate(null, credentials); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); //then @@ -85,7 +86,7 @@ void authenticateMatchUserMatchPassword() { Publisher authenticationResponsePublisher = localUserAuthenticationProvider.authenticate(null, credentials); authenticationResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); //then @@ -95,9 +96,9 @@ void authenticateMatchUserMatchPassword() { AuthenticationResponse actual = subscriber.values().get(0); Assertions.assertTrue(actual.isAuthenticated()); - Assertions.assertTrue(actual.getUserDetails().isPresent()); + Assertions.assertTrue(actual.getAuthentication().isPresent()); - UserDetails actualUserDetails = actual.getUserDetails().get(); - Assertions.assertEquals("admin", actualUserDetails.getUsername()); + Authentication actualUserDetails = actual.getAuthentication().get(); + Assertions.assertEquals("admin", actualUserDetails.getName()); } } diff --git a/api/src/test/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRuleTest.java b/api/src/test/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRuleTest.java index 3bd87bd5..1fd2c2ea 100644 --- a/api/src/test/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRuleTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/security/ResourceBasedSecurityRuleTest.java @@ -6,6 +6,7 @@ import com.michelin.ns4kafka.repositories.NamespaceRepository; import com.michelin.ns4kafka.repositories.RoleBindingRepository; import io.micronaut.http.HttpRequest; +import io.micronaut.security.authentication.Authentication; import io.micronaut.security.rules.SecurityRuleResult; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -33,14 +34,16 @@ public class ResourceBasedSecurityRuleTest { @Test void CheckReturnsUnknown_Unauthenticated(){ - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/anything"),null,null); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/anything"),null,null); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @Test void CheckReturnsUnknown_MissingClaims(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/anything"),null,claims); + Authentication auth = Authentication.build("user", claims); + + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/anything"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @@ -48,7 +51,9 @@ void CheckReturnsUnknown_MissingClaims(){ void CheckReturnsUnknown_InvalidResource(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/non-namespaced/resource"),null, claims); + Authentication auth = Authentication.build("user", claims); + + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/non-namespaced/resource"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @@ -56,12 +61,13 @@ void CheckReturnsUnknown_InvalidResource(){ void CheckReturnsUnknown_NoRoleBinding(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); Mockito.when(roleBindingRepository.findAllForGroups(groups)) .thenReturn(List.of()); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/connects"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/connects"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @@ -69,18 +75,20 @@ void CheckReturnsUnknown_NoRoleBinding(){ void CheckReturnsUnknown_InvalidNamespace(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.empty()); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/connects"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/connects"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @Test void CheckReturnsUnknown_AdminNamespaceAsNotAdmin(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/admin/connects"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/admin/connects"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @@ -88,20 +96,22 @@ void CheckReturnsUnknown_AdminNamespaceAsNotAdmin(){ void CheckReturnsUnknown_InvalidNamespaceAsAdmin(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of("isAdmin()")); + Authentication auth = Authentication.build("user", List.of("isAdmin()"), claims); Mockito.when(namespaceRepository.findByName("admin")) .thenReturn(Optional.empty()); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/admin/connects"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/admin/connects"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @Test void CheckReturnsAllowed_NamespaceAsAdmin(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of("isAdmin()")); + Authentication auth = Authentication.build("user", List.of("isAdmin()"), claims); Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/connects"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/connects"),null, auth); Assertions.assertEquals(SecurityRuleResult.ALLOWED, actual); } @@ -109,6 +119,7 @@ void CheckReturnsAllowed_NamespaceAsAdmin(){ void CheckReturnsAllowed(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(roleBindingRepository.findAllForGroups(groups)) .thenReturn(List.of(RoleBinding.builder() .metadata(ObjectMeta.builder().namespace("test") @@ -125,13 +136,14 @@ void CheckReturnsAllowed(){ Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/connects"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/connects"),null, auth); Assertions.assertEquals(SecurityRuleResult.ALLOWED, actual); } @Test void CheckReturnsAllowed_Subresource(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(roleBindingRepository.findAllForGroups(groups)) .thenReturn(List.of(RoleBinding.builder() .metadata(ObjectMeta.builder().namespace("test") @@ -148,16 +160,17 @@ void CheckReturnsAllowed_Subresource(){ Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/connects/name/restart"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/connects/name/restart"),null, auth); Assertions.assertEquals(SecurityRuleResult.ALLOWED, actual); - actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/topics/name/delete-records"),null, claims); + actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/topics/name/delete-records"),null, auth); Assertions.assertEquals(SecurityRuleResult.ALLOWED, actual); } @Test void CheckReturnsAllowed_ResourceWithHyphen(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(roleBindingRepository.findAllForGroups(groups)) .thenReturn(List.of(RoleBinding.builder() .metadata(ObjectMeta.builder().namespace("test") @@ -174,13 +187,14 @@ void CheckReturnsAllowed_ResourceWithHyphen(){ Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/role-bindings"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/role-bindings"),null, auth); Assertions.assertEquals(SecurityRuleResult.ALLOWED, actual); } @Test void CheckReturnsAllowed_ResourceNameWithDot(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(roleBindingRepository.findAllForGroups(groups)) .thenReturn(List.of(RoleBinding.builder() .metadata(ObjectMeta.builder().namespace("test") @@ -197,7 +211,7 @@ void CheckReturnsAllowed_ResourceNameWithDot(){ Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/topics/topic.with.dots"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/topics/topic.with.dots"),null, auth); Assertions.assertEquals(SecurityRuleResult.ALLOWED, actual); } @@ -205,9 +219,10 @@ void CheckReturnsAllowed_ResourceNameWithDot(){ void CheckReturnsUnknown_SubResource(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); - Mockito.when(roleBindingRepository.findAllForGroups(groups)) + Mockito.when(roleBindingRepository.findAllForGroups(groups)) .thenReturn(List.of(RoleBinding.builder() .metadata(ObjectMeta.builder().namespace("test") .build()) @@ -221,13 +236,14 @@ void CheckReturnsUnknown_SubResource(){ .build()) .build())); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/connects/name/restart"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/connects/name/restart"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } @Test void CheckReturnsUnknown_SubResourceWithDot(){ List groups = List.of("group1"); Map claims = Map.of("sub","user", "groups", groups, "roles", List.of()); + Authentication auth = Authentication.build("user", claims); Mockito.when(namespaceRepository.findByName("test")) .thenReturn(Optional.of(Namespace.builder().build())); Mockito.when(roleBindingRepository.findAllForGroups(groups)) @@ -244,7 +260,7 @@ void CheckReturnsUnknown_SubResourceWithDot(){ .build()) .build())); - SecurityRuleResult actual = resourceBasedSecurityRule.check(HttpRequest.GET("/api/namespaces/test/connects/name.with.dots/restart"),null, claims); + SecurityRuleResult actual = resourceBasedSecurityRule.check_security(HttpRequest.GET("/api/namespaces/test/connects/name.with.dots/restart"),null, auth); Assertions.assertEquals(SecurityRuleResult.UNKNOWN, actual); } diff --git a/api/src/test/java/com/michelin/ns4kafka/services/KafkaConnectClientProxyTest.java b/api/src/test/java/com/michelin/ns4kafka/services/KafkaConnectClientProxyTest.java index 356d62de..43d211e0 100644 --- a/api/src/test/java/com/michelin/ns4kafka/services/KafkaConnectClientProxyTest.java +++ b/api/src/test/java/com/michelin/ns4kafka/services/KafkaConnectClientProxyTest.java @@ -8,7 +8,7 @@ import io.micronaut.http.*; import io.micronaut.http.client.ProxyHttpClient; import io.micronaut.http.simple.SimpleHttpRequest; -import io.reactivex.subscribers.TestSubscriber; +import io.reactivex.rxjava3.subscribers.TestSubscriber; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.stream.Stream; @ExtendWith(MockitoExtension.class) @@ -40,10 +41,10 @@ void doFilterMissingHeader_Secret() { .header("X-Unused", "123"); TestSubscriber> subscriber = new TestSubscriber(); - Publisher> mutableHttpResponsePublisher = proxy.doFilterOnce(request, null); + Publisher> mutableHttpResponsePublisher = proxy.doFilter(request, null); mutableHttpResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertError(ResourceValidationException.class); subscriber.assertError(throwable -> @@ -59,10 +60,10 @@ void doFilterWrongSecret() { .header("X-Proxy-Secret", "123"); TestSubscriber> subscriber = new TestSubscriber(); - Publisher> mutableHttpResponsePublisher = proxy.doFilterOnce(request, null); + Publisher> mutableHttpResponsePublisher = proxy.doFilter(request, null); mutableHttpResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertError(ResourceValidationException.class); subscriber.assertError(throwable -> @@ -79,10 +80,10 @@ void doFilterMissingHeader_KafkaCluster() { .header("X-Unused", "123"); TestSubscriber> subscriber = new TestSubscriber(); - Publisher> mutableHttpResponsePublisher = proxy.doFilterOnce(request, null); + Publisher> mutableHttpResponsePublisher = proxy.doFilter(request, null); mutableHttpResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertError(ResourceValidationException.class); subscriber.assertError(throwable -> @@ -99,10 +100,10 @@ void doFilterMissingHeader_ConnectCluster() { .header(KafkaConnectClientProxy.PROXY_HEADER_KAFKA_CLUSTER, "local"); TestSubscriber> subscriber = new TestSubscriber(); - Publisher> mutableHttpResponsePublisher = proxy.doFilterOnce(request, null); + Publisher> mutableHttpResponsePublisher = proxy.doFilter(request, null); mutableHttpResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertError(ResourceValidationException.class); subscriber.assertError(throwable -> @@ -122,10 +123,10 @@ void doFilterWrongKafkaCluster() { Mockito.when(kafkaAsyncExecutorConfigs.stream()).thenReturn(Stream.empty()); TestSubscriber> subscriber = new TestSubscriber(); - Publisher> mutableHttpResponsePublisher = proxy.doFilterOnce(request, null); + Publisher> mutableHttpResponsePublisher = proxy.doFilter(request, null); mutableHttpResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertError(throwable -> ((ResourceValidationException)throwable) @@ -148,10 +149,10 @@ void doFilterWrongConnectCluster() { .thenReturn(Stream.of(config)); TestSubscriber> subscriber = new TestSubscriber(); - Publisher> mutableHttpResponsePublisher = proxy.doFilterOnce(request, null); + Publisher> mutableHttpResponsePublisher = proxy.doFilter(request, null); mutableHttpResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertError(throwable -> ((ResourceValidationException)throwable) @@ -181,10 +182,10 @@ void doFilterSuccess() { .thenReturn(Publishers.just(HttpResponse.ok())); TestSubscriber> subscriber = new TestSubscriber(); - Publisher> mutableHttpResponsePublisher = proxy.doFilterOnce(request, null); + Publisher> mutableHttpResponsePublisher = proxy.doFilter(request, null); mutableHttpResponsePublisher.subscribe(subscriber); - subscriber.awaitTerminalEvent(); + subscriber.awaitDone(1L, TimeUnit.SECONDS); subscriber.assertValueCount(1); subscriber.assertValue(mutableHttpResponse -> mutableHttpResponse.status() == HttpStatus.OK); diff --git a/api/src/test/resources/application-test.yml b/api/src/test/resources/application-test.yml index 62e3fbb6..77b9d915 100644 --- a/api/src/test/resources/application-test.yml +++ b/api/src/test/resources/application-test.yml @@ -14,7 +14,7 @@ ns4kafka: managed-clusters: test-cluster: manage-users: false - manage-acls: true + manage-acls: false manage-topics: true manage-connectors: true manage-role-bindings: false diff --git a/build.gradle b/build.gradle index b28a5e63..6491d69b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id("com.github.johnrengelman.shadow") version "7.0.0" - id("io.micronaut.application") version "1.5.0" + id("io.micronaut.application") version "2.0.3" id 'jacoco' id "org.sonarqube" version "3.1.1" } diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/ApiResourcesSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/ApiResourcesSubcommand.java index dd76b109..d8e6e110 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/ApiResourcesSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/ApiResourcesSubcommand.java @@ -3,7 +3,7 @@ import com.michelin.ns4kafka.cli.services.ApiResourcesService; import picocli.CommandLine; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.concurrent.Callable; @CommandLine.Command(name = "api-resources", description = "Print the supported API resources on the server") diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/ApplySubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/ApplySubcommand.java index 4a070b9a..01274145 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/ApplySubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/ApplySubcommand.java @@ -11,7 +11,7 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Option; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.io.File; import java.util.List; import java.util.Optional; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/ConnectorsSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/ConnectorsSubcommand.java index fde7f19c..10e862e5 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/ConnectorsSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/ConnectorsSubcommand.java @@ -9,7 +9,7 @@ import com.michelin.ns4kafka.cli.services.ResourceService; import picocli.CommandLine; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.List; import java.util.Map; import java.util.Objects; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteRecordsSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteRecordsSubcommand.java index b983ab06..d1b44408 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteRecordsSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteRecordsSubcommand.java @@ -9,7 +9,7 @@ import picocli.CommandLine.Option; import picocli.CommandLine.Parameters; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.concurrent.Callable; @Command(name = "delete-records", description = "Deletes all records within a topic") diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteSubcommand.java index 77941c6a..edf7b3ae 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/DeleteSubcommand.java @@ -13,7 +13,7 @@ import picocli.CommandLine.Option; import picocli.CommandLine.Parameters; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.io.File; import java.util.List; import java.util.Optional; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/DiffSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/DiffSubcommand.java index 7f966e9b..9c555d1b 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/DiffSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/DiffSubcommand.java @@ -18,7 +18,7 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Option; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.io.File; import java.util.List; import java.util.Optional; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/GetSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/GetSubcommand.java index 70939c46..e1ab63dc 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/GetSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/GetSubcommand.java @@ -14,7 +14,7 @@ import picocli.CommandLine.Option; import picocli.CommandLine.Parameters; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.List; import java.util.Map; import java.util.Optional; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/ImportSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/ImportSubcommand.java index 7965510e..1ba3cba3 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/ImportSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/ImportSubcommand.java @@ -11,7 +11,7 @@ import picocli.CommandLine.Option; import picocli.CommandLine.Parameters; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.util.List; import java.util.Map; import java.util.Optional; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java index db17f36f..4d5b13ed 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java @@ -5,8 +5,8 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Option; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.Optional; import java.util.concurrent.Callable; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/ResetOffsetsSubcommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/ResetOffsetsSubcommand.java index c79ad3d5..24cd01dd 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/ResetOffsetsSubcommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/ResetOffsetsSubcommand.java @@ -10,7 +10,7 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Option; -import javax.inject.Inject; +import jakarta.inject.Inject; import java.time.Duration; import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/services/ApiResourcesService.java b/cli/src/main/java/com/michelin/ns4kafka/cli/services/ApiResourcesService.java index e8c3993a..8937f6f0 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/services/ApiResourcesService.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/services/ApiResourcesService.java @@ -4,8 +4,8 @@ import com.michelin.ns4kafka.cli.models.ApiResource; import com.michelin.ns4kafka.cli.models.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/services/FileService.java b/cli/src/main/java/com/michelin/ns4kafka/cli/services/FileService.java index dc3f2eec..6c0644cc 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/services/FileService.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/services/FileService.java @@ -4,7 +4,7 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.io.File; import java.io.IOException; import java.nio.file.Files; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/services/FormatService.java b/cli/src/main/java/com/michelin/ns4kafka/cli/services/FormatService.java index fec98ecd..88a67a7a 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/services/FormatService.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/services/FormatService.java @@ -15,8 +15,8 @@ import org.yaml.snakeyaml.representer.Representer; import picocli.CommandLine; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.text.ParseException; import java.util.ArrayList; import java.util.Date; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/services/LoginService.java b/cli/src/main/java/com/michelin/ns4kafka/cli/services/LoginService.java index 2d4c5ce0..4104692c 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/services/LoginService.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/services/LoginService.java @@ -10,7 +10,7 @@ import io.micronaut.http.HttpStatus; import io.micronaut.http.client.exceptions.HttpClientResponseException; -import javax.inject.Singleton; +import jakarta.inject.Singleton; import java.io.File; import java.io.IOException; import java.util.Calendar; diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/services/ResourceService.java b/cli/src/main/java/com/michelin/ns4kafka/cli/services/ResourceService.java index 8a6fe3a2..1bf5c2d9 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/services/ResourceService.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/services/ResourceService.java @@ -9,8 +9,8 @@ import io.micronaut.http.HttpStatus; import io.micronaut.http.client.exceptions.HttpClientResponseException; -import javax.inject.Inject; -import javax.inject.Singleton; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; import java.util.List; import java.util.Map; import java.util.stream.Collectors; diff --git a/gradle.properties b/gradle.properties index 9208dc28..d36d8dcf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -micronautVersion=2.5.9 \ No newline at end of file +micronautVersion=3.1.4