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"
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;
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)
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(
@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);
}
}
}
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;
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());
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()
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;
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());
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()
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)
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)
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)
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)
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()
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)
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)));
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)
@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()
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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(
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(
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)))
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(
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(
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(
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(
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)))
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(
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)
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())));
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)
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(
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(
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)))
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(
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(
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(
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(
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)))
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(
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()
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)));
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)
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)
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)));
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()
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
+}
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
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'
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;
@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();
}
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;
private final KeycloakService keycloakService;
- @Autowired
public RolesController(BffConfig bffConfig, KeycloakService keycloakService) {
super(bffConfig);
this.keycloakService = keycloakService;
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;
private final KeycloakService keycloakService;
- @Autowired
public UsersController(BffConfig bffConfig, KeycloakService keycloakService) {
super(bffConfig);
this.keycloakService = 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());
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)'
- }
}
}
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'
\r
major=0\r
minor=1\r
-patch=0\r
+patch=1\r
\r
base_version=${major}.${minor}.${patch}\r
\r
# Release must be completed with git revision # in Jenkins\r
release_version=${base_version}\r
-snapshot_version=${base_version}-SNAPSHOT
\ No newline at end of file
+snapshot_version=${base_version}-SNAPSHOT\r