* [#1383] Spring Boot 3 migration Step 2 Some of the steps: 1. Change spring version parent and versions in root pom.xml 2. update eclipselink versions 3. javax.annotation -> jakarta.annotation (*.java) 4. javax.persistence -> jakarta.persistence (*.java) 5. javax.servlet -> jakarta.servlet (*.java, pom.xml) 6. javax.validation:validation-api -> jakarta.validation:jakarta.validation-api (pom.xml) 7. javax.validation -> jakarta.validation (*.java) 8. javax.transaction -> jakarta.transaction (*.java) 9. replace spring-cloud-stream-binder-test (hawkbit-repository-test) with ``` <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-stream-test-binder</artifactId> </dependency> ``` , TestSupportBinderAutoConfiguration.class }) -> }) @Import(TestChannelBinderConfiguration.class) 10. Set to Simple UI standard parent 11. requestMatchers to securityMatcher 12. @SpringBootApplication(scanBasePackages = "org.eclipse.hawkbit") (otherwise for instance flyway doesn't work - suffix is default ".sql", not H2.sql and don't differentiate dbs? strange is there a change?) 13. @NonEmpty for Long leads to validation exception - replaced with @NotNull 14. RSQLUtilityTest.correctRsqlBuildsPredicate - fixed - mock query builder add method 15. https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#spring-mvc-and-webflux-url-matching-changes - aliases as targers/ return 404 - remove trailing slash 16. firewall tests (allowedHostNameWithNotAllowedHost) doesn't throw 'rejected exception' but return 400 instead (as probably is expected anyway) Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com * Fix tenant listing to do not mix with multitenancy Tenant metadata is not multitenancy aware while depend on distribution set type which is. Thus querying all tenant metadata (in non tenant context) sometimes leads to resolution of distribution set type which is tenant scoped and leads to problems. So, now listing tenant lists just their ids - not fill entities. Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com> --------- Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -18,8 +18,8 @@ import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.ValidationException;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.ValidationException;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadataBodyPut;
|
||||
|
||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadArtifactRestApi;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.ValidationException;
|
||||
import jakarta.validation.ValidationException;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ValidationException;
|
||||
import jakarta.validation.ValidationException;
|
||||
|
||||
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
|
||||
@@ -17,8 +17,8 @@ import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.ValidationException;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.ValidationException;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata;
|
||||
@@ -328,7 +328,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
@Override
|
||||
public ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet(
|
||||
@PathVariable("targetId") final String targetId,
|
||||
@Valid @RequestBody final MgmtDistributionSetAssignments dsAssignments,
|
||||
@RequestBody final MgmtDistributionSetAssignments dsAssignments,
|
||||
@RequestParam(value = "offline", required = false) final boolean offline) {
|
||||
if (offline) {
|
||||
final List<Entry<String, Long>> offlineAssignments = dsAssignments.stream()
|
||||
|
||||
@@ -25,14 +25,15 @@ import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.RestConfiguration;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
|
||||
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.web.servlet.ResultMatcher;
|
||||
|
||||
@ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class,
|
||||
RepositoryApplicationConfiguration.class, TestConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class })
|
||||
RepositoryApplicationConfiguration.class, TestConfiguration.class })
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@TestPropertySource(locations = "classpath:/mgmt-test.properties")
|
||||
public abstract class AbstractManagementApiIntegrationTest extends AbstractRestIntegrationTest {
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
|
||||
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -68,8 +69,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@WebAppConfiguration
|
||||
@AutoConfigureMockMvc
|
||||
@ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class,
|
||||
RepositoryApplicationConfiguration.class, TestConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class })
|
||||
RepositoryApplicationConfiguration.class, TestConfiguration.class })
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@Feature("Component Tests - Management API")
|
||||
@Story("Basic auth Userinfo Resource")
|
||||
public class MgmtBasicAuthResourceTest {
|
||||
|
||||
@@ -350,14 +350,14 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
final DistributionSet generated = testdataFactory.generateDistributionSet(
|
||||
"stanTest", "2", reloaded, Collections.singletonList(softwareModule));
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/distributionsets/")
|
||||
.perform(post("/rest/v1/distributionsets")
|
||||
.content(JsonBuilder.distributionSets(Arrays.asList(generated)))
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isBadRequest()).andReturn();
|
||||
|
||||
final ExceptionInfo exceptionInfo = ResourceUtility.convertException(mvcResult.getResponse().getContentAsString());
|
||||
assertEquals("javax.validation.ValidationException", exceptionInfo.getExceptionClass());
|
||||
assertEquals("jakarta.validation.ValidationException", exceptionInfo.getExceptionClass());
|
||||
assertTrue(exceptionInfo.getMessage().contains("Distribution Set Type already deleted"));
|
||||
}
|
||||
|
||||
@@ -936,7 +936,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
private MvcResult executeMgmtTargetPost(final DistributionSet one, final DistributionSet two,
|
||||
final DistributionSet three) throws Exception {
|
||||
return mvc
|
||||
.perform(post("/rest/v1/distributionsets/")
|
||||
.perform(post("/rest/v1/distributionsets")
|
||||
.content(JsonBuilder.distributionSets(Arrays.asList(one, two, three)))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
|
||||
@@ -175,7 +175,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
||||
@Step
|
||||
private MvcResult runPostDistributionSetType(final List<DistributionSetType> types) throws Exception {
|
||||
return mvc
|
||||
.perform(post("/rest/v1/distributionsettypes/").content(JsonBuilder.distributionSetTypes(types))
|
||||
.perform(post("/rest/v1/distributionsettypes").content(JsonBuilder.distributionSetTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
|
||||
|
||||
@@ -393,7 +393,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andReturn();
|
||||
|
||||
final ExceptionInfo exceptionInfo = ResourceUtility.convertException(mvcResult.getResponse().getContentAsString());
|
||||
assertEquals("javax.validation.ValidationException", exceptionInfo.getExceptionClass());
|
||||
assertEquals("jakarta.validation.ValidationException", exceptionInfo.getExceptionClass());
|
||||
assertTrue(exceptionInfo.getMessage().contains("Software Module Type already deleted"));
|
||||
}
|
||||
|
||||
@@ -1106,7 +1106,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final long current = System.currentTimeMillis();
|
||||
|
||||
final MvcResult mvcResult = mvc.perform(
|
||||
post("/rest/v1/softwaremodules/").accept(MediaType.APPLICATION_JSON_VALUE)
|
||||
post("/rest/v1/softwaremodules").accept(MediaType.APPLICATION_JSON_VALUE)
|
||||
.content(JsonBuilder.softwareModules(modules))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
|
||||
@@ -166,14 +166,14 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
types.add(entityFactory.softwareModuleType().create().key("test-1").name("TestName-1").maxAssignments(-1)
|
||||
.build());
|
||||
|
||||
mvc.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
|
||||
|
||||
types.clear();
|
||||
types.add(entityFactory.softwareModuleType().create().key("test0").name("TestName0").maxAssignments(0).build());
|
||||
|
||||
mvc.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
.colour("col3‚").maxAssignments(3).build());
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -875,7 +875,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
final List<Target> targets = Arrays.asList(test1, test2, test3);
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/targets/").content(JsonBuilder.targets(targets, true))
|
||||
.perform(post("/rest/v1/targets").content(JsonBuilder.targets(targets, true))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
|
||||
@@ -2261,7 +2261,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
final List<Target> targets = Arrays.asList(test1, test2, test3);
|
||||
|
||||
final MvcResult mvcPostResult = mvc
|
||||
.perform(post("/rest/v1/targets/").content(JsonBuilder.targets(targets, true))
|
||||
.perform(post("/rest/v1/targets").content(JsonBuilder.targets(targets, true))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
@Test
|
||||
@Description("Handles GET request for receiving all tenant specific configurations.")
|
||||
public void getTenantConfigurations() throws Exception {
|
||||
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/"))
|
||||
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs"))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk())
|
||||
//check for TenantMetadata additional properties
|
||||
@@ -66,7 +66,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
@Description("Handles GET request for receiving a tenant specific configuration.")
|
||||
public void getTenantConfiguration() throws Exception {
|
||||
//Test TenantConfiguration property
|
||||
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/",
|
||||
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
@@ -76,7 +76,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
@Description("Handles GET request for receiving (TenantMetadata - DefaultDsType) a tenant specific configuration.")
|
||||
public void getTenantMetadata() throws Exception {
|
||||
//Test TenantMetadata property
|
||||
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/",
|
||||
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
DEFAULT_DISTRIBUTION_SET_TYPE_KEY))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk())
|
||||
@@ -91,7 +91,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
final String json = mapper.writeValueAsString(bodyPut);
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/",
|
||||
mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY).content(json)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -109,7 +109,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
final String json = mapper.writeValueAsString(bodyPut);
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/",
|
||||
mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
DEFAULT_DISTRIBUTION_SET_TYPE_KEY).content(json)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -143,7 +143,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
}
|
||||
|
||||
private void assertDefaultDsTypeUpdateBadRequestFails(String newDefaultDsType, long oldDefaultDsType, ResultMatcher resultMatchers) throws Exception {
|
||||
mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/",
|
||||
mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
DEFAULT_DISTRIBUTION_SET_TYPE_KEY).content(newDefaultDsType)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -281,7 +281,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
@Test
|
||||
@Description("Handles DELETE request deleting a tenant specific configuration.")
|
||||
public void deleteTenantConfiguration() throws Exception {
|
||||
mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/",
|
||||
mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
@@ -290,7 +290,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
|
||||
@Test
|
||||
@Description("Tests DELETE request must Fail for TenantMetadata properties.")
|
||||
public void deleteTenantMetadataFail() throws Exception {
|
||||
mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/",
|
||||
mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
|
||||
DEFAULT_DISTRIBUTION_SET_TYPE_KEY))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
Reference in New Issue
Block a user