From c1bdb5ca4147a503a57ffed9cf6cf0450103abf9 Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Fri, 19 Jul 2024 10:45:59 +0200 Subject: [PATCH] fix: sonar issues (#37) --- .../pages/onecx-iam-bff-docs.adoc | 6 +- .../pages/onecx-iam-bff-extensions.adoc | 58 +++++++++---------- .../iam/bff/rs/RolesRestControllerTest.java | 8 +-- .../iam/bff/rs/UsersRestControllerTest.java | 12 ++-- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-docs.adoc b/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-docs.adoc index 30a5c30..01e9165 100644 --- a/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-docs.adoc +++ b/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-docs.adoc @@ -20,7 +20,8 @@ quarkus.openapi-generator.codegen.spec.onecx_iam_kc_svc_yaml.base-package=gen.or quarkus.openapi-generator.codegen.spec.onecx_iam_kc_svc_yaml.return-response=true quarkus.openapi-generator.codegen.spec.onecx_iam_kc_svc_yaml.additional-api-type-annotations=@org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders quarkus.openapi-generator.codegen.spec.onecx_iam_kc_svc_yaml.additional-model-type-annotations=@io.quarkus.runtime.annotations.RegisterForReflection; -%prod.quarkus.rest-client.onecx_iam_kc_svc_yaml.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter +quarkus.openapi-generator.codegen.spec.onecx_iam_kc_svc_yaml.enable-security-generation=false +%prod.quarkus.rest-client.onecx_iam_kc_svc.providers=io.quarkus.oidc.client.reactive.filter.OidcClientRequestReactiveFilter %prod.quarkus.oidc-client.client-id=${quarkus.application.name} ---- ==== @@ -61,5 +62,8 @@ app: keycloak: client: enabled: true + spec: + kcConfig: + defaultClientScopes: [ ocx-ia:all, ocx-pm:read ] ---- diff --git a/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-extensions.adoc b/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-extensions.adoc index ccd95f1..ce40476 100644 --- a/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-extensions.adoc +++ b/docs/modules/onecx-iam-bff/pages/onecx-iam-bff-extensions.adoc @@ -12,37 +12,37 @@ h| Version | https://quarkus.io/guides/rest[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-rest.adoc[Link] -| 3.11.1 +| 3.12.2 | quarkus-smallrye-openapi | https://quarkus.io/guides/openapi-swaggerui[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-openapi.adoc[Link] -| 3.11.1 +| 3.12.2 | quarkus-rest-jackson | https://quarkus.io/guides/rest-json[Link] | -| 3.11.1 +| 3.12.2 | quarkus-smallrye-health | https://quarkus.io/guides/smallrye-health[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-health.adoc[Link] -| 3.11.1 +| 3.12.2 | quarkus-opentelemetry | https://quarkus.io/guides/opentelemetry[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-opentelemetry.adoc[Link] -| 3.11.1 +| 3.12.2 | quarkus-micrometer-registry-prometheus | https://quarkus.io/guides/telemetry-micrometer[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-micrometer-registry-prometheus.adoc[Link] -| 3.11.1 +| 3.12.2 | quarkus-openapi-generator @@ -54,92 +54,92 @@ h| Version | https://quarkus.io/guides/rest-client[Link] | -| 3.11.1 +| 3.12.2 | tkit-quarkus-log-cdi | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.25.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] -| 2.25.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] +| 2.28.0 | tkit-quarkus-log-rs | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.25.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] -| 2.25.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] +| 2.28.0 | tkit-quarkus-log-json | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.25.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] -| 2.25.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] +| 2.28.0 | tkit-quarkus-rest | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.25.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link] -| 2.25.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest.adoc[Link] +| 2.28.0 | tkit-quarkus-rest-context | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-rest-context.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.25.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link] -| 2.25.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-rest-context.adoc[Link] +| 2.28.0 | tkit-quarkus-jpa | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-jpa.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.25.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link] -| 2.25.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-jpa.adoc[Link] +| 2.28.0 | quarkus-hibernate-validator | https://quarkus.io/guides/validation[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-hibernate-validator.adoc[Link] -| 3.11.1 +| 3.12.2 | onecx-permissions | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-permissions.html[Link] -| https://github.com/onecx/onecx-quarkus/blob/0.20.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link] -| 0.20.0 +| https://github.com/onecx/onecx-quarkus/blob/0.24.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link] +| 0.24.0 | quarkus-oidc | https://quarkus.io/guides/security-oidc-bearer-token-authentication-tutorial[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-oidc.adoc[Link] -| 3.11.1 +| 3.12.2 | tkit-quarkus-security | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-security.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.25.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] -| 2.25.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.28.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] +| 2.28.0 | onecx-core | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link] | -| 0.20.0 +| 0.24.0 | quarkus-arc | https://quarkus.io/guides/cdi-reference[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-arc.adoc[Link] -| 3.11.1 +| 3.12.2 | quarkus-container-image-docker | https://quarkus.io/guides/container-image[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link] -| 3.11.1 +| 3.12.2 | quarkus-rest-client-oidc-filter | | -| 3.11.1 +| 3.12.2 |=== \ No newline at end of file diff --git a/src/test/java/org/tkit/onecx/iam/bff/rs/RolesRestControllerTest.java b/src/test/java/org/tkit/onecx/iam/bff/rs/RolesRestControllerTest.java index a763c4f..3f7a6f6 100644 --- a/src/test/java/org/tkit/onecx/iam/bff/rs/RolesRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/iam/bff/rs/RolesRestControllerTest.java @@ -42,12 +42,12 @@ class RolesRestControllerTest extends AbstractTest { KeycloakTestClient keycloakClient = new KeycloakTestClient(); - static final String mockId = "MOCK_ID"; + static final String MOCK_ID = "MOCK_ID"; @BeforeEach void resetExpectation() { try { - mockServerClient.clear(mockId); + mockServerClient.clear(MOCK_ID); } catch (Exception ex) { // mockId not existing } @@ -76,7 +76,7 @@ void searchRolesByCriteriaTest() { mockServerClient.when(request().withPath("/internal/roles/search") .withMethod(HttpMethod.POST)) .withPriority(100) - .withId(mockId) + .withId(MOCK_ID) .respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode()) .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(rolePageResult))); @@ -139,7 +139,7 @@ void searchRolesByCriteriaTest_shouldReturnBadRequest_whenBadRequestResponse() { .withMethod(HttpMethod.POST) .withBody(JsonBody.json(roleSearchCriteria))) .withPriority(100) - .withId(mockId) + .withId(MOCK_ID) .respond(httpRequest -> response().withStatusCode(BAD_REQUEST.getStatusCode()) .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(problemDetailResponse))); diff --git a/src/test/java/org/tkit/onecx/iam/bff/rs/UsersRestControllerTest.java b/src/test/java/org/tkit/onecx/iam/bff/rs/UsersRestControllerTest.java index d0c4a1f..60d1043 100644 --- a/src/test/java/org/tkit/onecx/iam/bff/rs/UsersRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/iam/bff/rs/UsersRestControllerTest.java @@ -40,13 +40,13 @@ class UsersRestControllerTest extends AbstractTest { KeycloakTestClient keycloakClient = new KeycloakTestClient(); - static final String mockId = "MOCK_ID_USER"; + static final String MOCK_ID = "MOCK_ID_USER"; @BeforeEach void resetExpectation() { try { - mockServerClient.clear(mockId); + mockServerClient.clear(MOCK_ID); } catch (Exception ex) { // mockId not existing } @@ -58,7 +58,7 @@ void resetPasswordTest() { mockServerClient.when(request().withPath("/internal/users/password") .withMethod(HttpMethod.PUT)) .withPriority(100) - .withId(mockId) + .withId(MOCK_ID) .respond(httpRequest -> response().withStatusCode((Response.Status.NO_CONTENT.getStatusCode())) .withContentType(MediaType.APPLICATION_JSON)); @@ -108,7 +108,7 @@ void resetPasswordTest_shouldReturnBadRequest_whenBadRequestResponse() { //Mockserver mockServerClient.when(request().withPath("/internal/users/password").withMethod(HttpMethod.PUT) .withBody(JsonBody.json(userResetPasswordRequest))) - .withId(mockId) + .withId(MOCK_ID) .respond(httpRequest -> response().withStatusCode(Response.Status.BAD_REQUEST.getStatusCode()) .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(problemDetailResponse))); @@ -178,7 +178,7 @@ void searchUsersByCriteriaTest() { mockServerClient.when(request().withPath("/internal/users/search") .withMethod(HttpMethod.POST)) .withPriority(100) - .withId(mockId) + .withId(MOCK_ID) .respond(httpRequest -> response().withStatusCode(Response.Status.OK.getStatusCode()) .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(userPageResult))); @@ -232,7 +232,7 @@ void searchRolesByCriteriaTest_shouldReturnBadRequest_whenBadRequestResponse() { //Mockserver mockServerClient.when(request().withPath("/internal/users/search").withMethod(HttpMethod.POST) .withBody(JsonBody.json(userSearchCriteria))) - .withId(mockId) + .withId(MOCK_ID) .respond(httpRequest -> response().withStatusCode(Response.Status.BAD_REQUEST.getStatusCode()) .withContentType(MediaType.APPLICATION_JSON) .withBody(JsonBody.json(problemDetailResponse)));