diff options
27 files changed, 157 insertions, 163 deletions
diff --git a/app/build.gradle b/app/build.gradle index ed30630..4305de0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,7 +41,6 @@ dependencies { implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml' implementation "org.zalando:problem-spring-webflux:$problemSpringVersion" implementation "org.zalando:jackson-datatype-problem:$problemVersion" - implementation "io.swagger.core.v3:swagger-annotations:$swaggerV3Version" implementation "org.mapstruct:mapstruct:$mapStructVersion" annotationProcessor "org.mapstruct:mapstruct-processor:$mapStructVersion" diff --git a/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java index 528568d..a69516c 100644 --- a/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/BaseIntegrationTest.java @@ -36,7 +36,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.UUID; -import org.apache.http.client.utils.URIBuilder; +import org.apache.hc.core5.net.URIBuilder; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.onap.portalng.bff.config.BffConfig; @@ -86,8 +86,7 @@ public abstract class BaseIntegrationTest { WireMock.stubFor( WireMock.get( - WireMock.urlMatching( - String.format("/realms/%s/protocol/openid-connect/certs", realm))) + WireMock.urlMatching("/realms/%s/protocol/openid-connect/certs".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", JWKSet.MIME_TYPE) @@ -98,8 +97,7 @@ public abstract class BaseIntegrationTest { WireMock.stubFor( WireMock.post( - WireMock.urlMatching( - String.format("/realms/%s/protocol/openid-connect/token", realm))) + WireMock.urlMatching("/realms/%s/protocol/openid-connect/token".formatted(realm))) .withBasicAuth("test", "test") .withRequestBody(WireMock.containing("grant_type=client_credentials")) .willReturn( diff --git a/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java b/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java index 0c6aa89..5ffe3ef 100644 --- a/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java +++ b/app/src/test/java/org/onap/portalng/bff/TokenGenerator.java @@ -116,7 +116,7 @@ public class TokenGenerator { @Builder.Default private final List<String> roles = Collections.emptyList(); public String issuer() { - return String.format("http://localhost:%d/realms/%s", port, realm); + return "http://localhost:%d/realms/%s".formatted(port, realm); } } } diff --git a/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java b/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java index 39fc3dc..7275737 100644 --- a/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java +++ b/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.matching.EqualToPattern; import io.restassured.http.Header; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.HttpHeaders; import org.onap.portalng.bff.BaseIntegrationTest; import org.onap.portalng.bff.openapi.client_history.model.ActionResponseHistoryDto; import org.onap.portalng.bff.openapi.client_history.model.ActionsListResponseHistoryDto; diff --git a/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java index 3b16664..801ebb2 100644 --- a/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/preferences/CreatePreferencesIntegrationTest.java @@ -38,25 +38,29 @@ class CreatePreferencesIntegrationTest extends PreferencesMocks { void thatPreferencesCanBeCreated() throws Exception { PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto(); preferencesPreferencesDto.setProperties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockCreatePreferences(preferencesPreferencesDto); final CreatePreferencesRequestApiDto request = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final PreferencesResponseApiDto response = createPreferences(request); assertThat(response).isNotNull(); assertThat(response.getProperties()).isEqualTo(preferencesPreferencesDto.getProperties()); @@ -72,25 +76,29 @@ class CreatePreferencesIntegrationTest extends PreferencesMocks { final PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockCreatePreferencesError(preferencesPreferencesDto, problemPreferencesDto); CreatePreferencesRequestApiDto responseBody = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final ProblemApiDto response = requestSpecification() .given() diff --git a/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java b/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java index 9c5be75..64486c8 100644 --- a/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java +++ b/app/src/test/java/org/onap/portalng/bff/preferences/PreferencesMocks.java @@ -28,7 +28,7 @@ import com.github.tomakehurst.wiremock.matching.EqualToPattern; import io.restassured.http.Header; import java.io.File; import java.io.IOException; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.HttpHeaders; import org.onap.portalng.bff.BaseIntegrationTest; import org.onap.portalng.bff.openapi.client_preferences.model.PreferencesPreferencesDto; import org.onap.portalng.bff.openapi.client_preferences.model.ProblemPreferencesDto; diff --git a/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java index 1cd9a70..0c19b7d 100644 --- a/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/preferences/UpdatePreferencesIntegrationTest.java @@ -38,25 +38,29 @@ class UpdatePreferencesIntegrationTest extends PreferencesMocks { void thatPreferencesCanBeUpdated() throws Exception { PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto(); preferencesPreferencesDto.setProperties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockUpdatePreferences(preferencesPreferencesDto); final CreatePreferencesRequestApiDto requestApiDto = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final PreferencesResponseApiDto response = updatePreferences(requestApiDto); assertThat(response).isNotNull(); assertThat(response.getProperties()).isEqualTo(preferencesPreferencesDto.getProperties()); @@ -72,25 +76,29 @@ class UpdatePreferencesIntegrationTest extends PreferencesMocks { final PreferencesPreferencesDto preferencesPreferencesDto = new PreferencesPreferencesDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); mockUpdatePreferencesError(preferencesPreferencesDto, problemPreferencesDto); CreatePreferencesRequestApiDto requestApiDto = new CreatePreferencesRequestApiDto() .properties( - "{\n" - + "\"properties\": {\n" - + "\"appStarter\": \"value1\",\n" - + "\"dashboard\": {\"key1:\" : \"value2\"}\n" - + "}\n" - + "\n" - + "}"); + """ + { + "properties": { + "appStarter": "value1", + "dashboard": {"key1:" : "value2"} + } + + }\ + """); final ProblemApiDto response = requestSpecification() .given() diff --git a/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java index d9fa9e0..8b0215b 100644 --- a/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/roles/ListRealmRolesIntegrationTest.java @@ -59,7 +59,7 @@ class ListRealmRolesIntegrationTest extends RolesMocks { new ErrorResponseKeycloakDto().errorMessage("Some error message"); WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java b/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java index 2f61995..1422043 100644 --- a/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java +++ b/app/src/test/java/org/onap/portalng/bff/roles/RolesMocks.java @@ -48,7 +48,7 @@ public class RolesMocks extends BaseIntegrationTest { protected void mockListRealmRoles(List<RoleKeycloakDto> roles) throws Exception { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java index 7928c3b..51c870d 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/CreateUserIntegrationTest.java @@ -220,19 +220,17 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { protected void mockCreateUser(UserKeycloakDto request, String userId) throws Exception { WireMock.stubFor( - WireMock.post(WireMock.urlMatching(String.format("/admin/realms/%s/users", realm))) + WireMock.post(WireMock.urlMatching("/admin/realms/%s/users".formatted(realm))) .withRequestBody(WireMock.equalToJson(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) - .withHeader( - "location", String.format("/admin/realms/%s/users/%s", realm, userId)))); + .withHeader("location", "/admin/realms/%s/users/%s".formatted(realm, userId)))); } protected void mockGetUser(String userId, UserKeycloakDto response) throws Exception { WireMock.stubFor( - WireMock.get( - WireMock.urlMatching(String.format("/admin/realms/%s/users/%s", realm, userId))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/%s".formatted(realm, userId))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -243,7 +241,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userId))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userId))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -258,8 +256,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( WireMock.urlMatching( - String.format( - "/admin/realms/%s/users/%s/execute-actions-email", realm, userId))) + "/admin/realms/%s/users/%s/execute-actions-email".formatted(realm, userId))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse() @@ -273,7 +270,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userID))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userID))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -285,8 +282,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( WireMock.urlMatching( - String.format( - "/admin/realms/%s/users/%s/execute-actions-email", realm, userId))) + "/admin/realms/%s/users/%s/execute-actions-email".formatted(realm, userId))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse().withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE))); @@ -294,7 +290,7 @@ class CreateUserIntegrationTest extends BaseIntegrationTest { protected void mockListRealmRoles(List<RoleKeycloakDto> roles) throws Exception { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java index 15ba9ee..61cff96 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/DeleteUserIntegrationTest.java @@ -37,7 +37,7 @@ class DeleteUserIntegrationTest extends BaseIntegrationTest { @Test void userCanBeDeleted() { WireMock.stubFor( - WireMock.delete(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.delete(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn(WireMock.aResponse().withStatus(204))); requestSpecification() @@ -55,7 +55,7 @@ class DeleteUserIntegrationTest extends BaseIntegrationTest { new ErrorResponseKeycloakDto().errorMessage("Some error message"); WireMock.stubFor( - WireMock.delete(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.delete(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java index 337d3e3..c26ce2e 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/GetUserDetailIntegrationTest.java @@ -46,7 +46,7 @@ class GetUserDetailIntegrationTest extends BaseIntegrationTest { new UserKeycloakDto().id("1").username("user1").email("user1@localhost").enabled(true); WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -85,7 +85,7 @@ class GetUserDetailIntegrationTest extends BaseIntegrationTest { new ErrorResponseKeycloakDto().errorMessage("Some error message"); WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) @@ -117,7 +117,7 @@ class GetUserDetailIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userID))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userID))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java index 901308c..d06fb3a 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/ListAssignedRolesIntegrationTest.java @@ -47,7 +47,7 @@ class ListAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -82,7 +82,7 @@ class ListAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java index 06d9b89..87579eb 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/ListAvailableRolesIntegrationTest.java @@ -47,7 +47,7 @@ class ListAvailableRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -82,7 +82,7 @@ class ListAvailableRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java index 2b5fdb4..93c83f4 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/ListUsersIntegrationTest.java @@ -162,7 +162,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { protected void mockGetUserCount(Integer userCount) { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/users/count", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/count".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -174,7 +174,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users\\?first=%s&max=%s", realm, first, max))) + "/admin/realms/%s/users\\?first=%s&max=%s".formatted(realm, first, max))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -183,7 +183,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { protected void mockListRealmRoles(List<RoleKeycloakDto> roles) throws Exception { WireMock.stubFor( - WireMock.get(WireMock.urlMatching(String.format("/admin/realms/%s/roles", realm))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/roles".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -194,8 +194,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { throws Exception { WireMock.stubFor( WireMock.get( - WireMock.urlMatching( - String.format("/admin/realms/%s/roles/%s/users", realm, roleName))) + WireMock.urlMatching("/admin/realms/%s/roles/%s/users".formatted(realm, roleName))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -225,7 +224,7 @@ class ListUsersIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users\\?first=%s&max=%s", realm, first, max))) + "/admin/realms/%s/users\\?first=%s&max=%s".formatted(realm, first, max))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java index 9fcff3b..d3b3de3 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/UpdateAssignedRolesIntegrationTest.java @@ -54,7 +54,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -65,7 +65,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -76,7 +76,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -86,7 +86,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( @@ -137,7 +137,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -148,7 +148,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -159,7 +159,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.delete( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody( @@ -169,7 +169,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -179,7 +179,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( @@ -224,7 +224,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -233,7 +233,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.delete( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .withRequestBody( WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToRemove))) .willReturn(WireMock.aResponse().withStatus(HttpStatus.NO_CONTENT.value()))); @@ -241,7 +241,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -285,7 +285,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -296,7 +296,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -307,7 +307,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -317,7 +317,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( @@ -370,7 +370,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm/available", realm))) + "/admin/realms/%s/users/1/role-mappings/realm/available".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -381,7 +381,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .willReturn( @@ -393,7 +393,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.delete( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody( @@ -403,7 +403,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.post( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs(Scenario.STARTED) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRolesToAdd))) @@ -413,7 +413,7 @@ class UpdateAssignedRolesIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/role-mappings/realm", realm))) + "/admin/realms/%s/users/1/role-mappings/realm".formatted(realm))) .inScenario("test") .whenScenarioStateIs("rolesUpdated") .willReturn( diff --git a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java index 349909f..ee62a50 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserIntegrationTest.java @@ -66,7 +66,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { final UserKeycloakDto keycloakRequest = new UserKeycloakDto().firstName("User1").enabled(false); WireMock.stubFor( - WireMock.put(WireMock.urlMatching(String.format("/admin/realms/%s/users/1", realm))) + WireMock.put(WireMock.urlMatching("/admin/realms/%s/users/1".formatted(realm))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRequest))) .willReturn( WireMock.aResponse() @@ -100,8 +100,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { protected void mockUpdateUser(UserKeycloakDto request, String userId) throws Exception { WireMock.stubFor( - WireMock.put( - WireMock.urlMatching(String.format("/admin/realms/%s/users/%s", realm, userId))) + WireMock.put(WireMock.urlMatching("/admin/realms/%s/users/%s".formatted(realm, userId))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(request))) .willReturn( WireMock.aResponse().withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE))); @@ -109,8 +108,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { protected void mockGetUser(String userId, UserKeycloakDto response) throws Exception { WireMock.stubFor( - WireMock.get( - WireMock.urlMatching(String.format("/admin/realms/%s/users/%s", realm, userId))) + WireMock.get(WireMock.urlMatching("/admin/realms/%s/users/%s".formatted(realm, userId))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) @@ -122,7 +120,7 @@ class UpdateUserIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.get( WireMock.urlMatching( - String.format("/admin/realms/%s/users/%s/role-mappings/realm", realm, userID))) + "/admin/realms/%s/users/%s/role-mappings/realm".formatted(realm, userID))) .willReturn( WireMock.aResponse() .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) diff --git a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java index 11634a8..b88ebff 100644 --- a/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/users/UpdateUserPasswordIntegrationTest.java @@ -43,8 +43,7 @@ class UpdateUserPasswordIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( - WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/reset-password", realm))) + WireMock.urlMatching("/admin/realms/%s/users/1/reset-password".formatted(realm))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRequest))) .willReturn(WireMock.aResponse().withStatus(204))); @@ -72,8 +71,7 @@ class UpdateUserPasswordIntegrationTest extends BaseIntegrationTest { WireMock.stubFor( WireMock.put( - WireMock.urlMatching( - String.format("/admin/realms/%s/users/1/reset-password", realm))) + WireMock.urlMatching("/admin/realms/%s/users/1/reset-password".formatted(realm))) .withRequestBody(WireMock.equalTo(objectMapper.writeValueAsString(keycloakRequest))) .willReturn( WireMock.aResponse() diff --git a/build.gradle b/build.gradle index 3e3b47d..5a2fa92 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,8 @@ ext { mapStructExtensionsVersion = '1.0.2' logbackVersion = '7.4' lombokVersion = '1.18.28' - micrometerVersion = '1.1.4' swaggerV3Version = '2.2.21' // app wiremockVersion = '4.0.4' -}
\ No newline at end of file +} diff --git a/lib/build.gradle b/lib/build.gradle index 44b2920..1e8d11c 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' id 'io.spring.dependency-management' - id 'com.github.johnrengelman.shadow' + id 'com.github.johnrengelman.shadow' id 'maven-publish' // publish lib jar to artifact repository id 'com.diffplug.spotless' // code formatting id 'com.github.spotbugs' // bug linting that can be picked up by IDE @@ -31,10 +31,10 @@ dependencies { implementation "org.mapstruct.extensions.spring:mapstruct-spring-extensions:$mapStructExtensionsVersion" implementation "io.swagger.core.v3:swagger-annotations:$swaggerV3Version" - implementation(platform("io.micrometer:micrometer-tracing-bom:$micrometerVersion")) - implementation("io.micrometer:micrometer-tracing") - implementation("io.micrometer:micrometer-tracing-bridge-otel") - implementation("io.opentelemetry:opentelemetry-exporter-zipkin") + implementation 'io.micrometer:micrometer-tracing' + implementation 'io.micrometer:micrometer-tracing-bridge-otel' + implementation 'io.opentelemetry:opentelemetry-exporter-zipkin' + implementation 'io.micrometer:micrometer-registry-prometheus' annotationProcessor "org.mapstruct:mapstruct-processor:$mapStructVersion" annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' diff --git a/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java b/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java index 94c87bd..4ae842a 100644 --- a/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java +++ b/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java @@ -21,6 +21,8 @@ package org.onap.portalng.bff.config; +import static org.springframework.security.config.Customizer.withDefaults; + import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -43,23 +45,20 @@ public class SecurityConfig { @Bean public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { - return http.httpBasic() - .disable() - .formLogin() - .disable() - .csrf() - .disable() - .cors() - .and() - .authorizeExchange() - .pathMatchers(unauthenticatedEndpoints) - .permitAll() - .anyExchange() - .authenticated() - .and() + return http.httpBasic( + basic -> + basic + .disable() + .formLogin(login -> login.disable().csrf(csrf -> csrf.disable().cors()))) + .authorizeExchange( + exchange -> + exchange + .pathMatchers(unauthenticatedEndpoints) + .permitAll() + .anyExchange() + .authenticated()) .oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::jwt) - .oauth2Client() - .and() + .oauth2Client(withDefaults()) .build(); } diff --git a/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java b/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java index 3958811..69b4093 100644 --- a/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java +++ b/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java @@ -25,7 +25,6 @@ import org.onap.portalng.bff.config.BffConfig; import org.onap.portalng.bff.openapi.server.api.RolesApi; import org.onap.portalng.bff.openapi.server.model.RoleListResponseApiDto; import org.onap.portalng.bff.services.KeycloakService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ServerWebExchange; @@ -38,7 +37,6 @@ public class RolesController extends AbstractBffController implements RolesApi { private final KeycloakService keycloakService; - @Autowired public RolesController(BffConfig bffConfig, KeycloakService keycloakService) { super(bffConfig); this.keycloakService = keycloakService; diff --git a/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java b/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java index f2c5653..a8561af 100644 --- a/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java +++ b/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java @@ -31,7 +31,6 @@ import org.onap.portalng.bff.openapi.server.model.UpdateUserRequestApiDto; import org.onap.portalng.bff.openapi.server.model.UserListResponseApiDto; import org.onap.portalng.bff.openapi.server.model.UserResponseApiDto; import org.onap.portalng.bff.services.KeycloakService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ServerWebExchange; @@ -53,7 +52,6 @@ public class UsersController extends AbstractBffController implements UsersApi { private final KeycloakService keycloakService; - @Autowired public UsersController(BffConfig bffConfig, KeycloakService keycloakService) { super(bffConfig); this.keycloakService = keycloakService; diff --git a/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java b/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java index 5780ad0..92aad46 100644 --- a/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java +++ b/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java @@ -71,9 +71,8 @@ public class KeycloakService { DownstreamApiProblemException.builder() .status(Status.NOT_FOUND) .detail( - String.format( - "Roles not found in the realm: %s", - absentRoles.stream().map(RoleApiDto::getName).toList())) + "Roles not found in the realm: %s" + .formatted(absentRoles.stream().map(RoleApiDto::getName).toList())) .downstreamSystem(ProblemApiDto.DownstreamSystemEnum.KEYCLOAK.toString()) .title(HttpStatus.NOT_FOUND.toString()) .build()); diff --git a/openapi/server/build.gradle b/openapi/server/build.gradle index 95206ed..9307fcc 100644 --- a/openapi/server/build.gradle +++ b/openapi/server/build.gradle @@ -7,13 +7,10 @@ plugins { dependencies { compileOnly "org.springframework.boot:spring-boot-starter-webflux:$springBootVersion" compileOnly "org.openapitools:openapi-generator:$openapiVersion" - compileOnly 'jakarta.validation:jakarta.validation-api:3.0.2' + compileOnly 'jakarta.validation:jakarta.validation-api:3.1.0' constraints { - compileOnly('io.swagger.core.v3:swagger-annotations:2.2.5') { - because 'there is a dependency conflict between swagger-parser versions 2 and 3 (https://github.com/OpenAPITools/openapi-generator/issues/14901)' - } } } diff --git a/settings.gradle b/settings.gradle index cb8a886..ea192ed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,8 +2,8 @@ pluginManagement { // https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_version_management plugins { - id 'io.spring.dependency-management' version '1.1.4' - id 'org.springframework.boot' version '3.2.4' + id 'io.spring.dependency-management' version '1.1.6' + id 'org.springframework.boot' version '3.3.3' id 'org.openapi.generator' version '7.4.0' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'com.gorylenko.gradle-git-properties' version '2.4.1' diff --git a/version.properties b/version.properties index 5294d92..b179fec 100644 --- a/version.properties +++ b/version.properties @@ -4,10 +4,10 @@ major=0
minor=1
-patch=0
+patch=1
base_version=${major}.${minor}.${patch}
# Release must be completed with git revision # in Jenkins
release_version=${base_version}
-snapshot_version=${base_version}-SNAPSHOT
\ No newline at end of file +snapshot_version=${base_version}-SNAPSHOT
|