diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/JpaRepositoryAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/JpaRepositoryAutoConfiguration.java
index 00db0e5ce..65ad702c9 100644
--- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/JpaRepositoryAutoConfiguration.java
+++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/JpaRepositoryAutoConfiguration.java
@@ -9,7 +9,7 @@
*/
package org.eclipse.hawkbit.autoconfigure.repository;
-import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
+import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyResolver;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -22,8 +22,8 @@ import org.springframework.context.annotation.Import;
* Auto-Configuration for enabling JPA repository.
*/
@Configuration
-@ConditionalOnClass({ RepositoryApplicationConfiguration.class })
-@Import({ RepositoryApplicationConfiguration.class })
+@ConditionalOnClass({ JpaRepositoryConfiguration.class })
+@Import({ JpaRepositoryConfiguration.class })
public class JpaRepositoryAutoConfiguration {
/**
diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java
index ab4809b05..ea13d603e 100644
--- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java
+++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java
@@ -50,7 +50,7 @@ public class ExecutorAutoConfiguration {
/**
* @return ExecutorService with security context availability in thread execution.
*/
- @Bean(destroyMethod = "shutdown")
+ @Bean(name = "asyncExecutor", destroyMethod = "shutdown")
@ConditionalOnMissingBean
public ExecutorService asyncExecutor() {
return new DelegatingSecurityContextExecutorService(threadPoolExecutor());
diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java
index 7472b9ef2..08defa6f5 100644
--- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java
+++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java
@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.ContextAware;
import org.eclipse.hawkbit.audit.AuditContextProvider;
import org.eclipse.hawkbit.audit.AuditLoggingAspect;
-import org.eclipse.hawkbit.im.authentication.SpRole;
+import org.eclipse.hawkbit.repository.RepositoryConfiguration;
import org.eclipse.hawkbit.tenancy.TenantAware.DefaultTenantResolver;
import org.eclipse.hawkbit.tenancy.TenantAware.TenantResolver;
import org.eclipse.hawkbit.tenancy.TenantAwareUserProperties;
@@ -39,11 +39,9 @@ import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.domain.AuditorAware;
-import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
-import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
-import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.security.web.authentication.logout.LogoutHandler;
@@ -57,6 +55,7 @@ import org.springframework.util.CollectionUtils;
*/
@Configuration
@EnableConfigurationProperties({ SecurityProperties.class, HawkbitSecurityProperties.class, TenantAwareUserProperties.class })
+@Import(RepositoryConfiguration.class)
public class SecurityAutoConfiguration {
@Bean
@@ -170,19 +169,4 @@ public class SecurityAutoConfiguration {
simpleUrlLogoutSuccessHandler.setTargetUrlParameter("login");
return simpleUrlLogoutSuccessHandler;
}
-
- @Bean
- @ConditionalOnMissingBean
- static RoleHierarchy roleHierarchy() {
- return RoleHierarchyImpl.fromHierarchy(SpRole.DEFAULT_ROLE_HIERARCHY);
- }
-
- // and, if using method security also add
- @Bean
- @ConditionalOnMissingBean
- static MethodSecurityExpressionHandler methodSecurityExpressionHandler(final RoleHierarchy roleHierarchy) {
- final DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
- expressionHandler.setRoleHierarchy(roleHierarchy);
- return expressionHandler;
- }
}
\ No newline at end of file
diff --git a/hawkbit-ddi/hawkbit-ddi-api/pom.xml b/hawkbit-ddi/hawkbit-ddi-api/pom.xml
index b84813f68..bc630afb6 100644
--- a/hawkbit-ddi/hawkbit-ddi-api/pom.xml
+++ b/hawkbit-ddi/hawkbit-ddi-api/pom.xml
@@ -34,10 +34,6 @@
${project.version}
-
- org.springframework.hateoas
- spring-hateoas
-
org.springdoc
springdoc-openapi-starter-webmvc-ui
diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java
index f38b2672b..0653d8063 100644
--- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java
+++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.ddi.json.model.DdiConfirmationFeedback;
import org.eclipse.hawkbit.ddi.json.model.DdiProgress;
import org.eclipse.hawkbit.ddi.json.model.DdiResult;
import org.eclipse.hawkbit.ddi.json.model.DdiStatus;
-import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
+import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Artifact;
@@ -55,7 +55,7 @@ import org.springframework.test.web.servlet.ResultMatcher;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@ContextConfiguration(
- classes = { DdiApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class })
+ classes = { DdiApiConfiguration.class, RestConfiguration.class, JpaRepositoryConfiguration.class, TestConfiguration.class })
@TestPropertySource(locations = "classpath:/ddi-test.properties")
public abstract class AbstractDDiApiIntegrationTest extends AbstractRestIntegrationTest {
diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java
index c410a269b..6ad013c3d 100644
--- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java
+++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java
@@ -12,6 +12,10 @@ package org.eclipse.hawkbit.ddi.rest.resource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS;
import static org.eclipse.hawkbit.im.authentication.SpPermission.TENANT_CONFIGURATION;
+import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.callAs;
+import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.getAs;
+import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.withController;
+import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.withUser;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@@ -55,7 +59,6 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
-import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.eclipse.hawkbit.repository.test.util.WithUser;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
@@ -126,7 +129,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
final Target findTargetByControllerID = targetManagement.getByControllerID(knownTargetControllerId).get();
assertThat(findTargetByControllerID.getCreatedBy()).isEqualTo(knownCreatedBy);
// make a poll, audit information should not be changed, run as controller principal!
- SecurityContextSwitch.runAs(SecurityContextSwitch.withController("controller", CONTROLLER_ROLE_ANONYMOUS),
+ callAs(withController("controller", CONTROLLER_ROLE_ANONYMOUS),
() -> {
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), knownTargetControllerId))
.andDo(MockMvcResultPrinter.print())
@@ -198,8 +201,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1),
@Expect(type = TenantConfigurationDeletedEvent.class, count = 1) })
void pollWithModifiedGlobalPollingTime() throws Exception {
- withPollingTime("00:02:00", () -> SecurityContextSwitch.runAs(
- SecurityContextSwitch.withUser("controller", CONTROLLER_ROLE_ANONYMOUS),
+ withPollingTime("00:02:00", () -> callAs(
+ withUser("controller", CONTROLLER_ROLE_ANONYMOUS),
() -> {
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711))
.andDo(MockMvcResultPrinter.print())
@@ -221,8 +224,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1),
@Expect(type = TenantConfigurationDeletedEvent.class, count = 1) })
void pollWithModifiedWithOverridesGlobalPollingTime() throws Exception {
- withPollingTime("00:02:00, controllerid == 4711 -> 00:01:00", () -> SecurityContextSwitch.runAs(
- SecurityContextSwitch.withUser("controller", CONTROLLER_ROLE_ANONYMOUS),
+ withPollingTime("00:02:00, controllerid == 4711 -> 00:01:00", () -> callAs(
+ withUser("controller", CONTROLLER_ROLE_ANONYMOUS),
() -> {
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711))
.andDo(MockMvcResultPrinter.print())
@@ -363,7 +366,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
final String knownControllerId1 = "0815";
final long create = System.currentTimeMillis();
// make a poll, audit information should be set on plug and play
- SecurityContextSwitch.runAs(SecurityContextSwitch.withController("controller", CONTROLLER_ROLE_ANONYMOUS),
+ callAs(withController("controller", CONTROLLER_ROLE_ANONYMOUS),
() -> {
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), knownControllerId1))
.andDo(MockMvcResultPrinter.print())
@@ -582,7 +585,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
void sleepTimeResponseForDifferentMaintenanceWindowParameters() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("");
- SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenantadmin", TENANT_CONFIGURATION),
+ getAs(withUser("tenantadmin", TENANT_CONFIGURATION),
() -> {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME, "00:05:00");
return null;
@@ -751,7 +754,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
}
private void withPollingTime(final String pollingTime, final Callable runnable) throws Exception {
- SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenantadmin", TENANT_CONFIGURATION),
+ getAs(withUser("tenantadmin", TENANT_CONFIGURATION),
() -> {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME, pollingTime);
return null;
@@ -759,7 +762,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
try {
runnable.call();
} finally {
- SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenantadmin", TENANT_CONFIGURATION),
+ getAs(withUser("tenantadmin", TENANT_CONFIGURATION),
() -> {
tenantConfigurationManagement.deleteConfiguration(TenantConfigurationKey.POLLING_TIME);
return null;
diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/resources/ddi-test.properties b/hawkbit-ddi/hawkbit-ddi-resource/src/test/resources/ddi-test.properties
index 6205e6406..2db581c1c 100644
--- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/resources/ddi-test.properties
+++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/resources/ddi-test.properties
@@ -8,6 +8,10 @@
# SPDX-License-Identifier: EPL-2.0
#
+# Logging START - activate to see request/response details
+#logging.level.org.eclipse.hawkbit.rest.util.MockMvcResultPrinter=DEBUG
+# Logging END
+
# DDI configuration - START
hawkbit.controller.pollingTime=00:01:00
hawkbit.controller.pollingOverdueTime=00:01:00
@@ -21,6 +25,6 @@ spring.servlet.multipart.max-file-size=5MB
hawkbit.server.security.dos.maxStatusEntriesPerAction=100
hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10
# Quota - END
-# Logging START - activate to see request/response details
-#logging.level.org.eclipse.hawkbit.rest.util.MockMvcResultPrinter=DEBUG
-# Logging END
+
+# disable spring cloud bus for tests
+spring.cloud.bus.enabled=false
diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java
index 45bb93476..89da4eb29 100644
--- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java
+++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java
@@ -39,7 +39,7 @@ import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
-import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
+import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -60,13 +60,17 @@ import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.TestPropertySource;
-@ActiveProfiles({ "test" })
/**
* Feature: Component Tests - Device Management Federation API
* Story: AmqpMessage Dispatcher Service Test
*/
-@SpringBootTest(classes = { RepositoryApplicationConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
+@ActiveProfiles({ "test" })
+@SpringBootTest(classes = { JpaRepositoryConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
+@TestPropertySource(properties = {
+ "spring.main.allow-bean-definition-overriding=true",
+ "spring.cloud.bus.enabled=true" })
class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
private static final String TENANT = "DEFAULT";
diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java
index 197a7a0e4..ee53135ee 100644
--- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java
+++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java
@@ -71,15 +71,14 @@ import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConversionException;
import org.springframework.amqp.support.converter.MessageConverter;
-@ExtendWith(MockitoExtension.class)
/**
* Feature: Component Tests - Device Management Federation API
* Story: AmqpMessage Handler Service Test
*/
+@ExtendWith(MockitoExtension.class)
class AmqpMessageHandlerServiceTest {
- private static final String FAIL_MESSAGE_AMQP_REJECT_REASON = AmqpRejectAndDontRequeueException.class
- .getSimpleName() + " was expected, ";
+ private static final String FAIL_MESSAGE_AMQP_REJECT_REASON = AmqpRejectAndDontRequeueException.class.getSimpleName() + " was expected, ";
private static final String VIRTUAL_HOST = "vHost";
private static final String TENANT = "DEFAULT";
diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java
index ae10258c0..9f84a9a7d 100644
--- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java
+++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java
@@ -31,11 +31,11 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConversionException;
-@ExtendWith(MockitoExtension.class)
/**
* Feature: Component Tests - Device Management Federation API
* Story: Base Amqp Service Test
*/
+@ExtendWith(MockitoExtension.class)
class BaseAmqpServiceTest {
@Mock
diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AbstractAmqpServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AbstractAmqpServiceIntegrationTest.java
index b87d879bc..1a29b4e1d 100644
--- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AbstractAmqpServiceIntegrationTest.java
+++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AbstractAmqpServiceIntegrationTest.java
@@ -42,7 +42,7 @@ import org.eclipse.hawkbit.integration.listener.ReplyToListener;
import org.eclipse.hawkbit.matcher.SoftwareModuleJsonMatcher;
import org.eclipse.hawkbit.rabbitmq.test.AbstractAmqpIntegrationTest;
import org.eclipse.hawkbit.rabbitmq.test.AmqpTestConfiguration;
-import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
+import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
@@ -66,7 +66,7 @@ import org.springframework.util.CollectionUtils;
*/
@ContextConfiguration(classes = {
DmfApiConfiguration.class, DmfTestConfiguration.class,
- RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class })
+ JpaRepositoryConfiguration.class, AmqpTestConfiguration.class })
abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest {
protected static final String TENANT_EXIST = "DEFAULT";
@@ -93,9 +93,9 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
}
protected T waitUntilIsPresent(final Callable> callable) {
- await().until(() -> SecurityContextSwitch.runAsPrivileged(() -> callable.call().isPresent()));
+ await().until(() -> SecurityContextSwitch.callAsPrivileged(() -> callable.call().isPresent()));
try {
- return SecurityContextSwitch.runAsPrivileged(() -> callable.call().get());
+ return SecurityContextSwitch.callAsPrivileged(() -> callable.call().get());
} catch (final Exception e) {
return null;
}
@@ -367,7 +367,7 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId));
await().untilAsserted(() -> {
try {
- final Map controllerAttributes = SecurityContextSwitch.runAsPrivileged(
+ final Map controllerAttributes = SecurityContextSwitch.callAsPrivileged(
() -> targetManagement.getControllerAttributes(controllerId));
assertThat(controllerAttributes).hasSameSizeAs(attributes);
assertThat(controllerAttributes).containsAllEntriesOf(attributes);
diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java
index 85cd8f72a..ce6e31a93 100644
--- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java
+++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java
@@ -794,7 +794,7 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
}
private void waitUntil(final Callable callable) {
- await().until(() -> SecurityContextSwitch.runAsPrivileged(callable));
+ await().until(() -> SecurityContextSwitch.callAsPrivileged(callable));
}
private void assertLatestMultiActionMessageContainsInstallMessages(final String controllerId,
diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java
index dafae26fc..f98f54e89 100644
--- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java
+++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java
@@ -1231,7 +1231,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
private void assertAction(final Long actionId, final int messages, final Status... expectedActionStates) {
await().untilAsserted(() -> {
try {
- SecurityContextSwitch.runAsPrivileged(() -> {
+ SecurityContextSwitch.callAsPrivileged(() -> {
final List actionStatusList = deploymentManagement.findActionStatusByAction(actionId, PAGE).getContent();
// Check correlation ID
@@ -1265,7 +1265,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
final Status... expectedActionStates) {
await().untilAsserted(() -> {
try {
- SecurityContextSwitch.runAsPrivileged(() -> {
+ SecurityContextSwitch.callAsPrivileged(() -> {
final List actionStatusList = deploymentManagement
.findActionStatusByAction(actionId, PAGE).getContent();
assertThat(actionStatusList).hasSize(statusListCount);
diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java
index 82f52e069..b0946cd32 100644
--- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java
+++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java
@@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionFactory;
-import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
+import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest;
import org.junit.jupiter.api.BeforeEach;
@@ -30,12 +30,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
@Slf4j
@RabbitAvailable
-@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, TestConfiguration.class })
+@ContextConfiguration(classes = { JpaRepositoryConfiguration.class, AmqpTestConfiguration.class, TestConfiguration.class })
// Dirty context is necessary to create a new vhost and recreate all necessary beans after every test class.
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
+@TestPropertySource(properties = {
+ "spring.main.allow-bean-definition-overriding=true",
+ "spring.cloud.bus.enabled=true" })
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes
public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest {
@@ -60,6 +64,7 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes
private static final Duration AT_LEAST = Duration.ofMillis(Integer.getInteger("hawkbit.it.amqp.await.atLeastMs", 100));
private static final Duration POLL_INTERVAL = Duration.ofMillis(Integer.getInteger("hawkbit.it.amqp.await.pollIntervalMs", 200));
private static final Duration TIMEOUT = Duration.ofMillis(Integer.getInteger("hawkbit.it.amqp.await.timeoutMs", 5000));
+
@Override
protected ConditionFactory await() {
return Awaitility.await().atLeast(AT_LEAST).pollInterval(POLL_INTERVAL).atMost(TIMEOUT);
diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java
index c7734d58e..991e813c0 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java
+++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java
@@ -19,13 +19,12 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
import org.springframework.stereotype.Controller;
/**
- * Enable {@link ComponentScan} in the resource package to setup all
- * {@link Controller} annotated classes and setup the REST-Resources for the
- * Management API.
+ * Enable {@link ComponentScan} in the resource package to set up all {@link Controller} annotated classes and set up the REST-Resources
+ * for the Management API.
*/
@Configuration
@EnableMethodSecurity(proxyTargetClass = true, securedEnabled = true)
@ComponentScan
@Import({ RestConfiguration.class, OpenApi.class })
@PropertySource("classpath:/hawkbit-mgmt-api-defaults.properties")
-public class MgmtApiConfiguration {}
+public class MgmtApiConfiguration {}
\ No newline at end of file
diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java
index 2a8be887a..68a851cc0 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java
+++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java
@@ -15,7 +15,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import lombok.SneakyThrows;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
-import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
+import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -32,7 +32,7 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.ResultMatcher;
@ContextConfiguration(
- classes = { MgmtApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class })
+ classes = { MgmtApiConfiguration.class, RestConfiguration.class, JpaRepositoryConfiguration.class, TestConfiguration.class })
@TestPropertySource(locations = "classpath:/mgmt-test.properties")
public abstract class AbstractManagementApiIntegrationTest extends AbstractRestIntegrationTest {
diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java
index 26dde90d1..95f270487 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java
+++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java
@@ -20,7 +20,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.Base64;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
-import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
+import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.matcher.EventVerifier;
import org.eclipse.hawkbit.repository.test.util.CleanupTestExecutionListener;
@@ -67,7 +67,7 @@ import org.springframework.web.context.WebApplicationContext;
@WebAppConfiguration
@AutoConfigureMockMvc
@ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class,
- RepositoryApplicationConfiguration.class, TestConfiguration.class })
+ JpaRepositoryConfiguration.class, TestConfiguration.class })
/**
* Feature: Component Tests - Management API
* Story: Basic auth Userinfo Resource
diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java
index c5c8bfaaa..17453d7ea 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java
+++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java
@@ -408,7 +408,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
try {
payload.put(new JSONObject().put("id", trg.getId()));
} catch (final JSONException e) {
- e.printStackTrace();
+ throw new IllegalStateException(e);
}
});
@@ -459,7 +459,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
try {
list.put(new JSONObject().put("id", target.getControllerId()));
} catch (final JSONException e) {
- e.printStackTrace();
+ throw new IllegalStateException(e);
}
});
diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java
index 623b81f8c..a57a793a9 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java
+++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java
@@ -1912,13 +1912,13 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
private void awaitRunningState(final Long rolloutId) {
awaitRollout().until(() -> SecurityContextSwitch
- .runAsPrivileged(() -> rolloutManagement.get(rolloutId).orElseThrow(NoSuchElementException::new))
+ .callAsPrivileged(() -> rolloutManagement.get(rolloutId).orElseThrow(NoSuchElementException::new))
.getStatus().equals(RolloutStatus.RUNNING));
}
private void awaitActionStatus(final Long actionId, final Status status) {
awaitRollout().until(() -> SecurityContextSwitch
- .runAsPrivileged(() -> deploymentManagement.findAction(actionId).orElseThrow(NoSuchElementException::new))
+ .callAsPrivileged(() -> deploymentManagement.findAction(actionId).orElseThrow(NoSuchElementException::new))
.getStatus().equals(status));
}
diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java
index a3f10bac7..7209ca194 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java
+++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java
@@ -9,6 +9,9 @@
*/
package org.eclipse.hawkbit.mgmt.rest.resource;
+import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.callAs;
+import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.getAs;
+import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.withUser;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
@@ -22,7 +25,6 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
-import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.json.JSONObject;
@@ -132,7 +134,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* Update DefaultDistributionSetType Fails if given DistributionSetType ID does not exist.
*/
@Test
- void putTenantMetadataFails() throws Exception {
+ void putTenantMetadataFails() throws Exception {
long oldDefaultDsType = getActualDefaultDsType();
//try an invalid input
String newDefaultDsType = new JSONObject().put("value", true).toString();
@@ -149,7 +151,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* The 'multi.assignments.enabled' property must not be changed to false.
*/
@Test
- void deactivateMultiAssignment() throws Exception {
+ void deactivateMultiAssignment() throws Exception {
final String bodyActivate = new JSONObject().put("value", true).toString();
final String bodyDeactivate = new JSONObject().put("value", false).toString();
@@ -168,7 +170,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* The Batch configuration should not be applied, because of invalid TenantConfiguration props
*/
@Test
- void changeBatchConfigurationShouldFailOnInvalidTenantConfiguration() throws Exception {
+ void changeBatchConfigurationShouldFailOnInvalidTenantConfiguration() throws Exception {
//in this scenario
// some TenantConfiguration are not valid,
// TenantMetadata - DefaultDSType ID is valid,
@@ -185,7 +187,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* The Batch configuration should not be applied, because of invalid TenantMetadata (DefaultDistributionSetType)
*/
@Test
- void changeBatchConfigurationShouldOnInvalidTenantMetadata() throws Exception {
+ void changeBatchConfigurationShouldOnInvalidTenantMetadata() throws Exception {
//in this scenario
// all TenantConfiguration have valid and new values - using old values, inverted
// TenantMetadata - DefaultDSType ID is invalid
@@ -218,7 +220,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* The Batch configuration should be applied
*/
@Test
- void changeBatchConfiguration() throws Exception {
+ void changeBatchConfiguration() throws Exception {
long updatedDistributionSetType = createTestDistributionSetType();
boolean updatedRolloutApprovalEnabled = true;
boolean updatedAuthGatewayTokenEnabled = true;
@@ -253,7 +255,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* The 'repository.actions.autoclose.enabled' property must not be modified if Multi-Assignments is enabled.
*/
@Test
- void autoCloseCannotBeModifiedIfMultiAssignmentIsEnabled() throws Exception {
+ void autoCloseCannotBeModifiedIfMultiAssignmentIsEnabled() throws Exception {
final String bodyActivate = new JSONObject().put("value", true).toString();
final String bodyDeactivate = new JSONObject().put("value", false).toString();
@@ -280,7 +282,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* Handles DELETE request deleting a tenant specific configuration.
*/
@Test
- void deleteTenantConfiguration() throws Exception {
+ void deleteTenantConfiguration() throws Exception {
mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY))
.andDo(MockMvcResultPrinter.print())
@@ -291,7 +293,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
* Tests DELETE request must Fail for TenantMetadata properties.
*/
@Test
- void deleteTenantMetadataFail() throws Exception {
+ void deleteTenantMetadataFail() throws Exception {
mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
DEFAULT_DISTRIBUTION_SET_TYPE_KEY))
.andDo(MockMvcResultPrinter.print())
@@ -303,18 +305,15 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
*/
@Test
void getTenantConfigurationReadGWToken() throws Exception {
- SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenant_admin", SpPermission.TENANT_CONFIGURATION), () -> {
+ getAs(withUser("tenant_admin", SpPermission.TENANT_CONFIGURATION), () -> {
tenantConfigurationManagement.addOrUpdateConfiguration(
- TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY,
- "123");
+ TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY, "123");
return null;
});
// TODO - should be able to read with TENANT_CONFIGURATION but somehow here the role hierarchy doesn't play
// checked in mgmt / update server runtime PreAuthorizeEnabledTest
- SecurityContextSwitch.runAs(
- SecurityContextSwitch.withUser("tenant_admin", SpPermission.READ_TENANT_CONFIGURATION, SpPermission.READ_GATEWAY_SEC_TOKEN),
- () -> {
+ callAs(withUser("tenant_admin", SpPermission.READ_TENANT_CONFIGURATION, SpPermission.READ_GATEWAY_SEC_TOKEN), () -> {
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs"))
.andDo(MockMvcResultPrinter.print())
.andDo(m -> System.out.println("-> 1: " + m.getResponse().getContentAsString()))
@@ -324,7 +323,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
return null;
});
- SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenant_read", SpPermission.READ_TENANT_CONFIGURATION), () -> {
+ callAs(withUser("tenant_read", SpPermission.READ_TENANT_CONFIGURATION), () -> {
mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs"))
.andDo(MockMvcResultPrinter.print())
.andDo(m -> System.out.println("-> 2: " + m.getResponse().getContentAsString()))
diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties
index b685a72f9..29803bb9a 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties
+++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties
@@ -12,3 +12,5 @@
#logging.level.org.eclipse.hawkbit.rest.util.MockMvcResultPrinter=DEBUG
# Logging END
+# disable spring cloud bus for tests
+spring.cloud.bus.enabled=false
\ No newline at end of file
diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java
index 06efb14be..1d1739302 100644
--- a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java
+++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.app.mgmt;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import java.util.HashMap;
@@ -47,6 +48,32 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
}
+ /**
+ * Tests whether request returns distribution set if a role with scope is granted for the user
+ */
+ @Test
+ @WithUser(authorities = { SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY + "/name==DsOne" }, autoCreateTenant = false)
+ void successIfHasRoleWithScope() throws Exception {
+ createDsOne("successIfHasRoleWithScope");
+ mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
+ assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
+ assertThat(result.getResponse().getContentAsString()).contains("DsOne");
+ });
+ }
+
+ /**
+ * Tests whether request doesn't return distribution set if a role with scope doesn't grant access
+ */
+ @Test
+ @WithUser(authorities = { SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY + "/name==DsOne2" }, autoCreateTenant = false)
+ void failIfHasNoForbiddingScope() throws Exception {
+ createDsOne("failIfHasNoForbiddingScope");
+ mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
+ assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
+ assertThat(result.getResponse().getContentAsString()).doesNotContain("DsOne");
+ });
+ }
+
/**
* Tests whether request succeed if a role is granted for the user
*/
@@ -80,4 +107,17 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
mvc.perform(get("/rest/v1/system/configs")).andExpect(result ->
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
}
+
+ private void createDsOne(final String version) throws Exception {
+ mvc.perform(post("/rest/v1/distributionsets")
+ .header("Content-Type", "application/json")
+ .content("""
+ [
+ {
+ "name": "DsOne",
+ "version": "${version}"
+ }
+ ]""".replace("${version}", version)))
+ .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.CREATED.value()));
+ }
}
\ No newline at end of file
diff --git a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java
index 71aeb62b5..271a22a2e 100644
--- a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java
+++ b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.app;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import java.util.HashMap;
@@ -47,6 +48,32 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
}
+ /**
+ * Tests whether request returns distribution set if a role with scope is granted for the user
+ */
+ @Test
+ @WithUser(authorities = { SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY + "/name==DsOne" }, autoCreateTenant = false)
+ void successIfHasRoleWithScope() throws Exception {
+ createDsOne("successIfHasRoleWithScope");
+ mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
+ assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
+ assertThat(result.getResponse().getContentAsString()).contains("DsOne");
+ });
+ }
+
+ /**
+ * Tests whether request doesn't return distribution set if a role with scope doesn't grant access
+ */
+ @Test
+ @WithUser(authorities = { SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY + "/name==DsOne2" }, autoCreateTenant = false)
+ void failIfHasNoForbiddingScope() throws Exception {
+ createDsOne("failIfHasNoForbiddingScope");
+ mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
+ assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
+ assertThat(result.getResponse().getContentAsString()).doesNotContain("DsOne");
+ });
+ }
+
/**
* Tests whether request succeed if a role is granted for the user
*/
@@ -58,7 +85,7 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
}
/**
- * Tests whether read tenant config request fail if a tenant config (or read read) is not granted for the user
+ * Tests whether read tenant config request fail if a tenant config (or read) is not granted for the user
*/
@Test
@WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false)
@@ -81,4 +108,17 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
mvc.perform(get("/rest/v1/system/configs"))
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
}
+
+ private void createDsOne(final String version) throws Exception {
+ mvc.perform(post("/rest/v1/distributionsets")
+ .header("Content-Type", "application/json")
+ .content("""
+ [
+ {
+ "name": "DsOne",
+ "version": "${version}"
+ }
+ ]""".replace("${version}", version)))
+ .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.CREATED.value()));
+ }
}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-api/pom.xml b/hawkbit-repository/hawkbit-repository-api/pom.xml
index f0062cc73..5490eab1f 100644
--- a/hawkbit-repository/hawkbit-repository-api/pom.xml
+++ b/hawkbit-repository/hawkbit-repository-api/pom.xml
@@ -33,10 +33,6 @@
${project.version}
-
- org.springframework.hateoas
- spring-hateoas
-
org.springframework.cloud
spring-cloud-starter-bus-amqp
@@ -55,10 +51,6 @@
com.cronutils
cron-utils
-
- cz.jirutka.rsql
- rsql-parser
-
org.jsoup
jsoup
diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelper.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelper.java
index 9e958b4cc..145103f67 100644
--- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelper.java
+++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelper.java
@@ -21,46 +21,35 @@ import com.cronutils.model.CronType;
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.model.time.ExecutionTime;
import com.cronutils.parser.CronParser;
+import lombok.NoArgsConstructor;
import org.eclipse.hawkbit.repository.exception.InvalidMaintenanceScheduleException;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
- * Helper class to check validity of maintenance schedule definition and manage
- * scheduling of maintenance window using a cron expression based scheduler. It
- * also provides a helper method for conversion of duration specified in
- * HH:mm:ss format to ISO format.
+ * Helper class to check validity of maintenance schedule definition and manage scheduling of maintenance window using
+ * a cron expression based scheduler. It also provides a helper method for conversion of duration specified in HH:mm:ss format to ISO format.
*/
+@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public final class MaintenanceScheduleHelper {
- private static final CronParser cronParser = new CronParser(
- CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
-
- private MaintenanceScheduleHelper() {
- throw new IllegalStateException("Utility class");
- }
+ private static final CronParser CRON_PARSER = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
/**
* Calculate the next available maintenance window.
*
- * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last
- * optional field: "second minute hour dayofmonth month weekday
- * year".
- * @param duration in HH:mm:ss format specifying the duration of a maintenance
- * window, for example 00:30:00 for 30 minutes.
- * @param timezone is the time zone specified as +/-hh:mm offset from UTC. For
- * example +02:00 for CET summer time and +00:00 for UTC. The
- * start time of a maintenance window calculated based on the
- * cron expression is relative to this time zone.
- * @return { @link Optional} of the next available window. In
- * case there is none, or there are maintenance window validation
+ * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last optional field: "second minute hour day-of-month month
+ * weekday year".
+ * @param duration in HH:mm:ss format specifying the duration of a maintenance window, for example 00:30:00 for 30 minutes.
+ * @param timezone is the time zone specified as +/-hh:mm offset from UTC. For example +02:00 for CET summer time and +00:00 for UTC. The
+ * start time of a maintenance window calculated based on the cron expression is relative to this time zone.
+ * @return { @link Optional} of the next available window. In case there is none, or there are maintenance window validation
* errors, returns empty value.
*/
// Exception squid:S1166 - if there are validation error(format of cron
// expression or duration is wrong), we simply return empty value
@SuppressWarnings("squid:S1166")
- public static Optional getNextMaintenanceWindow(final String cronSchedule, final String duration,
- final String timezone) {
+ public static Optional getNextMaintenanceWindow(final String cronSchedule, final String duration, final String timezone) {
try {
final ExecutionTime scheduleExecutor = ExecutionTime.forCron(getCronFromExpression(cronSchedule));
final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.of(timezone));
@@ -74,36 +63,28 @@ public final class MaintenanceScheduleHelper {
/**
* Parse the given cron expression with quartz parser.
*
- * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last
- * optional field: "second minute hour dayofmonth month weekday
- * year".
+ * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last optional field: "second minute hour day-of-month
+ * month weekday year".
* @return {@link Cron} object, that corresponds to the expression.
* @throws IllegalArgumentException if the cron expression doesn't have a valid format.
*/
public static Cron getCronFromExpression(final String cronSchedule) {
- return cronParser.parse(cronSchedule);
+ return CRON_PARSER.parse(cronSchedule);
}
/**
- * Check if the maintenance schedule definition is valid in terms of
- * validity of cron expression, duration and availability of at least one
- * valid maintenance window. Further a maintenance schedule is valid if
- * either all the parameters: schedule, duration and time zone are valid or
- * are null.
+ * Check if the maintenance schedule definition is valid in terms of validity of cron expression, duration and availability of at least one
+ * valid maintenance window. Further a maintenance schedule is valid if either all the parameters: schedule, duration and time zone are
+ * valid or are null.
*
- * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last
- * optional field: "second minute hour dayofmonth month weekday
- * year".
- * @param duration in HH:mm:ss format specifying the duration of a maintenance
- * window, for example 00:30:00 for 30 minutes.
- * @param timezone is the time zone specified as +/-hh:mm offset from UTC. For
- * example +02:00 for CET summer time and +00:00 for UTC. The
- * start time of a maintenance window calculated based on the
- * cron expression is relative to this time zone.
+ * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last optional field: "second minute hour day-of-month month
+ * weekday year".
+ * @param duration in HH:mm:ss format specifying the duration of a maintenance window, for example 00:30:00 for 30 minutes.
+ * @param timezone is the time zone specified as +/-hh:mm offset from UTC. For example +02:00 for CET summer time and +00:00 for UTC. The
+ * start time of a maintenance window calculated based on the cron expression is relative to this time zone.
* @throws InvalidMaintenanceScheduleException if the defined schedule fails the validity criteria.
*/
- public static void validateMaintenanceSchedule(final String cronSchedule, final String duration,
- final String timezone) {
+ public static void validateMaintenanceSchedule(final String cronSchedule, final String duration, final String timezone) {
if (allNotEmpty(cronSchedule, duration, timezone)) {
validateCronSchedule(cronSchedule);
validateDuration(duration);
@@ -114,18 +95,15 @@ public final class MaintenanceScheduleHelper {
"No valid maintenance window available after current time");
}
} else if (atLeastOneNotEmpty(cronSchedule, duration, timezone)) {
- throw new InvalidMaintenanceScheduleException(
- "All of schedule, duration and timezone should either be null or non empty.");
+ throw new InvalidMaintenanceScheduleException("All of schedule, duration and timezone should either be null or non empty.");
}
}
/**
- * Convert the time interval or duration specified in "HH:mm:ss" format to
- * ISO format.
+ * Convert the time interval or duration specified in "HH:mm:ss" format to ISO format.
*
- * @param timeInterval in "HH:mm:ss" string format. This format is popularly used but
- * can be confused with time of the day, hence conversion to ISO
- * specified format for time duration is required.
+ * @param timeInterval in "HH:mm:ss" string format. This format is popularly used but can be confused with time of the day,
+ * hence conversion to ISO specified format for time duration is required.
* @return {@link Duration} in ISO format.
* @throws DateTimeParseException if the text cannot be converted to ISO format.
*/
@@ -136,11 +114,9 @@ public final class MaintenanceScheduleHelper {
/**
* Validates the format of the maintenance window duration
*
- * @param duration in "HH:mm:ss" string format. This format is popularly used but
- * can be confused with time of the day, hence conversion to ISO
- * specified format for time duration is required.
- * @throws InvalidMaintenanceScheduleException if the duration doesn't have a valid format to be converted
- * to ISO.
+ * @param duration in "HH:mm:ss" string format. This format is popularly used but can be confused with time of the day, hence conversion
+ * to ISO specified format for time duration is required.
+ * @throws InvalidMaintenanceScheduleException if the duration doesn't have a valid format to be converted to ISO.
*/
public static void validateDuration(final String duration) {
try {
@@ -155,9 +131,8 @@ public final class MaintenanceScheduleHelper {
/**
* Validates the format of the maintenance window cron expression
*
- * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last
- * optional field: "second minute hour dayofmonth month weekday
- * year".
+ * @param cronSchedule is a cron expression with 6 mandatory fields and 1 last optional field: "second minute hour day-of-month month
+ * weekday year".
* @throws InvalidMaintenanceScheduleException if the cron expression doesn't have a valid quartz format.
*/
public static void validateCronSchedule(final String cronSchedule) {
@@ -181,4 +156,4 @@ public final class MaintenanceScheduleHelper {
private static LocalTime convertDurationToLocalTime(final String timeInterval) {
return LocalTime.parse(timeInterval.strip());
}
-}
+}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ValidString.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ValidString.java
index 627092b96..5086f5370 100644
--- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ValidString.java
+++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ValidString.java
@@ -21,15 +21,11 @@ import jakarta.validation.Payload;
* Constraint for strings submitted into the repository.
*/
@Constraint(validatedBy = ValidStringValidator.class)
-@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR,
- ElementType.PARAMETER, ElementType.TYPE_USE })
+@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE })
@Retention(RetentionPolicy.RUNTIME)
public @interface ValidString {
String message() default "Invalid characters in string";
-
Class>[] groups() default {};
-
Class extends Payload>[] payload() default {};
-
-}
+}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/EventPublisherHolder.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/EventPublisherHolder.java
index 1bf4e687d..4ce5ac11f 100644
--- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/EventPublisherHolder.java
+++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/EventPublisherHolder.java
@@ -49,7 +49,7 @@ public final class EventPublisherHolder {
this.serviceMatcher = serviceMatcher;
}
- @Autowired // spring setter injection
+ @Autowired(required = false) // spring setter injection
public void setBusProperties(final BusProperties bus) {
this.bus = bus;
}
diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryConfiguration.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryConfiguration.java
new file mode 100644
index 000000000..944d5e06a
--- /dev/null
+++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryConfiguration.java
@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2015 Bosch Software Innovations GmbH and others
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.hawkbit.repository;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+import org.aopalliance.intercept.MethodInvocation;
+import org.eclipse.hawkbit.im.authentication.SpRole;
+import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties;
+import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.expression.EvaluationContext;
+import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
+import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
+import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
+import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
+import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl;
+import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.util.function.SingletonSupplier;
+
+/**
+ * Default configuration that is common to all repository implementations.
+ */
+@Configuration
+@EnableMethodSecurity(proxyTargetClass = true, securedEnabled = true)
+@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class, TenantConfigurationProperties.class })
+@PropertySource("classpath:/hawkbit-repository-defaults.properties")
+public class RepositoryConfiguration {
+
+ @Bean
+ @ConditionalOnMissingBean
+ static RoleHierarchy roleHierarchy() {
+ return RoleHierarchyImpl.fromHierarchy(SpRole.DEFAULT_ROLE_HIERARCHY);
+ }
+
+ @Bean
+ @Primary
+ MethodSecurityExpressionHandler methodSecurityExpressionHandler(
+ final Optional roleHierarchy, final Optional applicationContext) {
+ final DefaultMethodSecurityExpressionHandler methodSecurityExpressionHandler = new DefaultMethodSecurityExpressionHandler() {
+
+ @Override
+ public EvaluationContext createEvaluationContext(final Supplier authentication, final MethodInvocation mi) {
+ return super.createEvaluationContext(SingletonSupplier.of(() -> new RawAuthoritiesAuthentication(authentication.get())), mi);
+ }
+
+ @Override
+ protected MethodSecurityExpressionOperations createSecurityExpressionRoot(
+ final Authentication authentication, final MethodInvocation mi) {
+ return super.createSecurityExpressionRoot(new RawAuthoritiesAuthentication(authentication), mi);
+ }
+ };
+ roleHierarchy.ifPresent(methodSecurityExpressionHandler::setRoleHierarchy);
+ applicationContext.ifPresent(methodSecurityExpressionHandler::setApplicationContext);
+ return methodSecurityExpressionHandler;
+ }
+
+ private static class RawAuthoritiesAuthentication implements Authentication {
+
+ private final Authentication authentication;
+ private final transient SingletonSupplier> rawAuthoritiesSupplier;
+
+ public RawAuthoritiesAuthentication(final Authentication authentication) {
+ this.authentication = authentication;
+ rawAuthoritiesSupplier = SingletonSupplier.of(
+ () -> authentication.getAuthorities().stream()
+ .map(GrantedAuthority::getAuthority)// get the authority
+ .map(authority -> {
+ // permissions are in the format UPDATE_TARGET(/).
+ // here we remove the rsql query - not supported by expression evaluation
+ // the rsql evaluation will be done later by the access controller
+ final int index = authority.indexOf('/');
+ return index < 0 ? authority : authority.substring(0, index);
+ })
+ .distinct() // remove duplicates if any
+ .map(SimpleGrantedAuthority::new)
+ .toList());
+ }
+
+ @Override
+ public Collection extends GrantedAuthority> getAuthorities() {
+ return rawAuthoritiesSupplier.get();
+ }
+
+ @Override
+ public Object getCredentials() {
+ return authentication.getCredentials();
+ }
+
+ @Override
+ public Object getDetails() {
+ return authentication.getDetails();
+ }
+
+ @Override
+ public Object getPrincipal() {
+ return authentication.getPrincipal();
+ }
+
+ @Override
+ public boolean isAuthenticated() {
+ return authentication.isAuthenticated();
+ }
+
+ @Override
+ public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getName() {
+ return authentication.getName();
+ }
+ }
+}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java
deleted file mode 100644
index 171f1c92c..000000000
--- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright (c) 2015 Bosch Software Innovations GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository;
-
-import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties;
-import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
-
-/**
- * Default configuration that is common to all repository implementations.
- */
-@Configuration
-@EnableMethodSecurity(proxyTargetClass = true, securedEnabled = true)
-@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class, TenantConfigurationProperties.class })
-@PropertySource("classpath:/hawkbit-repository-defaults.properties")
-public class RepositoryDefaultConfiguration {}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa-ql/src/main/java/org/eclipse/hawkbit/repository/jpa/ql/EntityMatcher.java b/hawkbit-repository/hawkbit-repository-jpa-ql/src/main/java/org/eclipse/hawkbit/repository/jpa/ql/EntityMatcher.java
index 66c14b7d0..758774ef1 100644
--- a/hawkbit-repository/hawkbit-repository-jpa-ql/src/main/java/org/eclipse/hawkbit/repository/jpa/ql/EntityMatcher.java
+++ b/hawkbit-repository/hawkbit-repository-jpa-ql/src/main/java/org/eclipse/hawkbit/repository/jpa/ql/EntityMatcher.java
@@ -63,7 +63,7 @@ public class EntityMatcher {
fieldGetter.setAccessible(true);
final Object fieldValue = fieldGetter.invoke(t);
final Operator op = comparison.getOp();
- if (Map.class.isAssignableFrom(fieldGetter.getReturnType())) {
+ if (Map.class.isAssignableFrom(getReturnType(fieldGetter))) {
if ((op == NE || op == NOT_IN || op == NOT_LIKE)
&& (fieldValue == null || !((Map, ?>) fieldValue).containsKey(split[1]))) {
// TODO / recheck - when missing entity shall it be included or not in != or =out=? - now it's not
@@ -75,19 +75,19 @@ public class EntityMatcher {
map(
comparison.getValue(),
(Class>) ((ParameterizedType) fieldGetter.getGenericReturnType()).getActualTypeArguments()[1]));
- } else if (Collection.class.isAssignableFrom(fieldGetter.getReturnType())) { // Set / List
+ } else if (Collection.class.isAssignableFrom(getReturnType(fieldGetter))) { // Set / List
final Object value;
final BiFunction