From f42d9b697837f308b29bb6db2a5f46c4802f8e78 Mon Sep 17 00:00:00 2001 From: Melanie Retter Date: Thu, 8 Jun 2017 11:07:48 +0200 Subject: [PATCH] Restructuring properties (#528) * Moved test property file to one locations Signed-off-by: Jonathan Philip Knoblauch * Added missing properties Signed-off-by: Jonathan Philip Knoblauch * Move property defaults to respective modules. Signed-off-by: kaizimmerm * Moved test relevant properties in respective modules. Added missing tests. Signed-off-by: kaizimmerm * deleted security.filter-order property Signed-off-by: Jonathan Philip Knoblauch * Remove empty line Signed-off-by: Melanie Retter * Removed build properties Signed-off-by: Jonathan Philip Knoblauch --- ...MongoDBArtifactStoreAutoConfiguration.java | 2 + .../hawkbit-mongodb-defaults.properties | 11 ++ .../DefaultPropertiesAutoConfiguration.java | 28 ---- ...ertyHostnameResolverAutoConfiguration.java | 2 + .../EventPublisherAutoConfiguration.java | 2 + .../SecurityManagedConfiguration.java | 2 + .../main/resources/META-INF/spring.factories | 1 - .../hawkbit-artifactdl-defaults.properties | 24 ++++ .../hawkbit-eventbus-defaults.properties | 20 +++ .../hawkbit-security-defaults.properties | 23 ++++ .../main/resources/hawkbitdefaults.properties | 128 ------------------ .../hawkbit/HawkbitServerProperties.java | 38 ------ .../AbstractDDiApiIntegrationTest.java | 2 + .../rest/resource/DdiDeploymentBaseTest.java | 24 ++-- .../resources/application-test.properties | 57 -------- .../src/test/resources/ddi-test.properties | 22 +++ .../AmqpControllerAuthenticationTest.java | 2 +- .../resources/application-test.properties | 35 ----- .../repository/ControllerManagement.java | 2 +- ...nvalidTenantConfigurationKeyException.java | 63 +++++++++ .../tenancy/configuration/DurationHelper.java | 0 .../TenantConfigurationProperties.java | 1 + .../TenantConfigurationBooleanValidator.java | 0 ...ConfigurationPollingDurationValidator.java | 0 .../TenantConfigurationStringValidator.java | 0 .../TenantConfigurationValidator.java | 0 ...TenantConfigurationValidatorException.java | 63 +++++++++ .../RepositoryDefaultConfiguration.java | 27 ++++ .../hawkbit-repository-defaults.properties} | 49 ++----- .../RepositoryApplicationConfiguration.java | 11 +- .../resources/hawkbit-jpa-defaults.properties | 25 ++++ .../jpa/AbstractJpaIntegrationTest.java | 2 + .../jpa/ControllerManagementTest.java | 77 +++++++++++ .../TenantConfigurationManagementTest.java | 2 +- .../src/test/resources/jpa-test.properties | 13 ++ .../repository/test/TestConfiguration.java | 2 + .../hawkbit-test-defaults.properties | 55 ++++++++ .../application-cloudsandbox.properties | 2 - .../src/main/resources/application.properties | 6 - .../src/main/resources/logback-spring.xml | 5 - .../hawkbit/ui/MgmtUiConfiguration.java | 2 + .../PollingConfigurationView.java | 2 +- .../resources/hawkbit-ui-defaults.properties | 14 ++ 43 files changed, 483 insertions(+), 363 deletions(-) create mode 100644 extensions/hawkbit-extension-artifact-repository-mongo/src/main/resources/hawkbit-mongodb-defaults.properties delete mode 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/DefaultPropertiesAutoConfiguration.java create mode 100644 hawkbit-autoconfigure/src/main/resources/hawkbit-artifactdl-defaults.properties create mode 100644 hawkbit-autoconfigure/src/main/resources/hawkbit-eventbus-defaults.properties create mode 100644 hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties delete mode 100644 hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties delete mode 100644 hawkbit-ddi-resource/src/test/resources/application-test.properties create mode 100644 hawkbit-ddi-resource/src/test/resources/ddi-test.properties delete mode 100644 hawkbit-mgmt-resource/src/test/resources/application-test.properties create mode 100644 hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java rename {hawkbit-core => hawkbit-repository/hawkbit-repository-api}/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java (100%) rename {hawkbit-core => hawkbit-repository/hawkbit-repository-api}/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationProperties.java (98%) rename {hawkbit-core => hawkbit-repository/hawkbit-repository-api}/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationBooleanValidator.java (100%) rename {hawkbit-core => hawkbit-repository/hawkbit-repository-api}/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java (100%) rename {hawkbit-core => hawkbit-repository/hawkbit-repository-api}/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationStringValidator.java (100%) rename {hawkbit-core => hawkbit-repository/hawkbit-repository-api}/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidator.java (100%) create mode 100644 hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java create mode 100644 hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java rename hawkbit-repository/{hawkbit-repository-jpa/src/test/resources/application-test.properties => hawkbit-repository-core/src/main/resources/hawkbit-repository-defaults.properties} (69%) create mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties create mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/resources/jpa-test.properties create mode 100644 hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties create mode 100644 hawkbit-ui/src/main/resources/hawkbit-ui-defaults.properties diff --git a/extensions/hawkbit-extension-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreAutoConfiguration.java b/extensions/hawkbit-extension-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreAutoConfiguration.java index b204f34a1..9308600d3 100644 --- a/extensions/hawkbit-extension-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreAutoConfiguration.java +++ b/extensions/hawkbit-extension-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoDBArtifactStoreAutoConfiguration.java @@ -11,12 +11,14 @@ package org.eclipse.hawkbit.artifact.repository; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; /** * Auto configuration for the {@link MongoDBArtifactStore}. */ @Configuration @ConditionalOnProperty(prefix = "org.eclipse.hawkbit.artifact.repository.mongo", name = "enabled", matchIfMissing = true) +@PropertySource("classpath:/hawkbit-mongodb-defaults.properties") public class MongoDBArtifactStoreAutoConfiguration { /** diff --git a/extensions/hawkbit-extension-artifact-repository-mongo/src/main/resources/hawkbit-mongodb-defaults.properties b/extensions/hawkbit-extension-artifact-repository-mongo/src/main/resources/hawkbit-mongodb-defaults.properties new file mode 100644 index 000000000..b8c756fae --- /dev/null +++ b/extensions/hawkbit-extension-artifact-repository-mongo/src/main/resources/hawkbit-mongodb-defaults.properties @@ -0,0 +1,11 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# MongoDB for artifact-repository +spring.data.mongodb.uri=mongodb://localhost/artifactrepo \ No newline at end of file diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/DefaultPropertiesAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/DefaultPropertiesAutoConfiguration.java deleted file mode 100644 index 33ffc0570..000000000 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/DefaultPropertiesAutoConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.hawkbit.autoconfigure; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; - -/** - * Autoconfiguration which loads the default configuration properties for - * hawkbit. - * - * - * - */ -@Configuration -@PropertySource("classpath:/hawkbitdefaults.properties") -@Order(Ordered.HIGHEST_PRECEDENCE) -public class DefaultPropertiesAutoConfiguration { - -} diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java index c04e153af..b6ab87055 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java @@ -20,6 +20,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import com.google.common.base.Throwables; @@ -29,6 +30,7 @@ import com.google.common.base.Throwables; */ @Configuration @EnableConfigurationProperties({ HawkbitServerProperties.class, ArtifactUrlHandlerProperties.class }) +@PropertySource("classpath:/hawkbit-artifactdl-defaults.properties") public class PropertyHostnameResolverAutoConfiguration { /** diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java index f56b510d2..cd228b81f 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java @@ -23,6 +23,7 @@ import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan; import org.springframework.context.ApplicationEvent; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import org.springframework.context.event.ApplicationEventMulticaster; import org.springframework.context.event.SimpleApplicationEventMulticaster; import org.springframework.context.support.AbstractApplicationContext; @@ -38,6 +39,7 @@ import io.protostuff.Schema; */ @Configuration @RemoteApplicationEventScan(basePackages = "org.eclipse.hawkbit.repository.event.remote") +@PropertySource("classpath:/hawkbit-eventbus-defaults.properties") public class EventPublisherAutoConfiguration { @Autowired diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java index 20e8fbfa4..583ab7106 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java @@ -57,6 +57,7 @@ import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.http.HttpStatus; @@ -98,6 +99,7 @@ import org.vaadin.spring.security.web.authentication.VaadinUrlAuthenticationSucc @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true, mode = AdviceMode.ASPECTJ, proxyTargetClass = true, securedEnabled = true) @Order(value = Ordered.HIGHEST_PRECEDENCE) +@PropertySource("classpath:/hawkbit-security-defaults.properties") public class SecurityManagedConfiguration { private static final Logger LOG = LoggerFactory.getLogger(SecurityManagedConfiguration.class); diff --git a/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories b/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories index 1fefdea6c..716504d52 100644 --- a/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories @@ -14,5 +14,4 @@ org.eclipse.hawkbit.autoconfigure.scheduling.ExecutorAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.security.SecurityAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.security.InMemoryUserManagementAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.web.WebMvcAutoConfiguration,\ -org.eclipse.hawkbit.autoconfigure.DefaultPropertiesAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.PropertyHostnameResolverAutoConfiguration diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbit-artifactdl-defaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbit-artifactdl-defaults.properties new file mode 100644 index 000000000..c2696d679 --- /dev/null +++ b/hawkbit-autoconfigure/src/main/resources/hawkbit-artifactdl-defaults.properties @@ -0,0 +1,24 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# Download URL generation configuration +hawkbit.artifact.url.protocols.download-http.rel=download-http +hawkbit.artifact.url.protocols.download-http.hostname=localhost +hawkbit.artifact.url.protocols.download-http.ip=127.0.0.1 +hawkbit.artifact.url.protocols.download-http.protocol=http +hawkbit.artifact.url.protocols.download-http.port=8080 +hawkbit.artifact.url.protocols.download-http.supports=DMF,DDI +hawkbit.artifact.url.protocols.download-http.ref={protocol}://{hostnameRequest}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName} +hawkbit.artifact.url.protocols.md5sum-http.rel=md5sum-http +hawkbit.artifact.url.protocols.md5sum-http.protocol=${hawkbit.artifact.url.protocols.download-http.protocol} +hawkbit.artifact.url.protocols.md5sum-http.hostname=${hawkbit.artifact.url.protocols.download-http.hostname} +hawkbit.artifact.url.protocols.md5sum-http.ip=${hawkbit.artifact.url.protocols.download-http.ip} +hawkbit.artifact.url.protocols.md5sum-http.port=${hawkbit.artifact.url.protocols.download-http.port} +hawkbit.artifact.url.protocols.md5sum-http.supports=DDI +hawkbit.artifact.url.protocols.md5sum-http.ref=${hawkbit.artifact.url.protocols.download-http.ref}.MD5SUM \ No newline at end of file diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbit-eventbus-defaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbit-eventbus-defaults.properties new file mode 100644 index 000000000..cfdadd2ec --- /dev/null +++ b/hawkbit-autoconfigure/src/main/resources/hawkbit-eventbus-defaults.properties @@ -0,0 +1,20 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# Spring cloud bus and stream +spring.cloud.bus.enabled=false +# Disable Cloud Bus default events +spring.cloud.bus.env.enabled=false +spring.cloud.bus.ack.enabled=false +spring.cloud.bus.trace.enabled=false +spring.cloud.bus.refresh.enabled=false +# Disable Cloud Bus endpoints +endpoints.spring.cloud.bus.refresh.enabled=false +endpoints.spring.cloud.bus.env.enabled=false +# Spring cloud bus and stream END \ No newline at end of file diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties new file mode 100644 index 000000000..20e120cf7 --- /dev/null +++ b/hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties @@ -0,0 +1,23 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# Displayed basic auth realm +security.basic.realm=HawkBit + +# User Security +security.user.name=admin +security.user.password=admin + +# DDI and download security +hawkbit.server.ddi.security.authentication.header.enabled=false +hawkbit.server.ddi.security.authentication.header.authority= +hawkbit.server.ddi.security.authentication.targettoken.enabled=false +hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false +hawkbit.server.download.anonymous.enabled=false +hawkbit.server.ddi.security.authentication.gatewaytoken.key= \ No newline at end of file diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties deleted file mode 100644 index cd97b7c49..000000000 --- a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties +++ /dev/null @@ -1,128 +0,0 @@ -# -# Copyright (c) 2015 Bosch Software Innovations GmbH and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# - - -# Displayed basic auth realm -security.basic.realm=HawkBit - -# User Security -security.user.name=admin -security.user.password=admin - -# Spring cloud bus and stream -spring.cloud.bus.enabled=false -# Disable Cloud Bus default events -spring.cloud.bus.env.enabled=false -spring.cloud.bus.ack.enabled=false -spring.cloud.bus.trace.enabled=false -spring.cloud.bus.refresh.enabled=false -# Disable Cloud Bus endpoints -endpoints.spring.cloud.bus.refresh.enabled=false -endpoints.spring.cloud.bus.env.enabled=false -# Spring cloud bus and stream END - - -### JPA / Datasource - START -spring.jpa.database=H2 -spring.jpa.show-sql=false -spring.datasource.driverClassName=org.h2.Driver -spring.datasource.tomcat.defaultAutoCommit=false -# Logging -spring.datasource.eclipselink.logging.logger=JavaLogger -spring.jpa.properties.eclipselink.logging.level=off -# Cluster aware -spring.datasource.eclipselink.query-results-cache=false -spring.datasource.eclipselink.cache.shared.default=false -### JPA / Datasource - END - -# MongoDB for artifact-repository -spring.data.mongodb.uri=mongodb://localhost/artifactrepo - -# Flyway DDL -flyway.enabled=true -flyway.initOnMigrate=true -flyway.sqlMigrationSuffix=${spring.jpa.database}.sql - -# Vaadin Servlet -vaadin.servlet.productionMode=true -vaadin.servlet.urlMapping=/UI/* -vaadin.servlet.heartbeatInterval=60 -vaadin.servlet.closeIdleSessions=false - -# Defines the polling time for the controllers in HH:MM:SS notation -hawkbit.controller.pollingTime=00:05:00 -hawkbit.controller.pollingOverdueTime=00:05:00 -hawkbit.controller.maxPollingTime=23:59:59 -hawkbit.controller.minPollingTime=00:00:30 -# Attention: if you want to use a maximumPollingTime greater 23:59:59 you have to update the DurationField in the configuration window - -# Configuration for RabbitMQ integration -hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl -hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter -hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver -hawkbit.dmf.rabbitmq.authenticationReceiverQueue=authentication_receiver - -# Download URL generation configuration -hawkbit.artifact.url.protocols.download-http.rel=download-http -hawkbit.artifact.url.protocols.download-http.hostname=localhost -hawkbit.artifact.url.protocols.download-http.ip=127.0.0.1 -hawkbit.artifact.url.protocols.download-http.protocol=http -hawkbit.artifact.url.protocols.download-http.port=8080 -hawkbit.artifact.url.protocols.download-http.supports=DMF,DDI -hawkbit.artifact.url.protocols.download-http.ref={protocol}://{hostnameRequest}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName} -hawkbit.artifact.url.protocols.md5sum-http.rel=md5sum-http -hawkbit.artifact.url.protocols.md5sum-http.protocol=${hawkbit.artifact.url.protocols.download-http.protocol} -hawkbit.artifact.url.protocols.md5sum-http.hostname=${hawkbit.artifact.url.protocols.download-http.hostname} -hawkbit.artifact.url.protocols.md5sum-http.ip=${hawkbit.artifact.url.protocols.download-http.ip} -hawkbit.artifact.url.protocols.md5sum-http.port=${hawkbit.artifact.url.protocols.download-http.port} -hawkbit.artifact.url.protocols.md5sum-http.supports=DDI -hawkbit.artifact.url.protocols.md5sum-http.ref=${hawkbit.artifact.url.protocols.download-http.ref}.MD5SUM - -# DDI and download security -hawkbit.server.ddi.security.authentication.header.enabled=false -hawkbit.server.ddi.security.authentication.header.authority= -hawkbit.server.ddi.security.authentication.targettoken.enabled=false -hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false -hawkbit.server.download.anonymous.enabled=false -hawkbit.server.ddi.security.authentication.gatewaytoken.key= - -# Default tenant configuration properties -hawkbit.server.tenant.configuration.authentication-header-enabled.keyName=authentication.header.enabled -hawkbit.server.tenant.configuration.authentication-header-enabled.defaultValue=${hawkbit.server.ddi.security.authentication.header.enabled} -hawkbit.server.tenant.configuration.authentication-header-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.authentication-header-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator - -hawkbit.server.tenant.configuration.authentication-header-authority.keyName=authentication.header.authority -hawkbit.server.tenant.configuration.authentication-header-authority.defaultValue=${hawkbit.server.ddi.security.authentication.header.authority} - -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.keyName=authentication.targettoken.enabled -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.defaultValue=${hawkbit.server.ddi.security.authentication.targettoken.enabled} -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.authentication-targettoken-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator - -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.keyName=authentication.gatewaytoken.enabled -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.defaultValue=${hawkbit.server.ddi.security.authentication.gatewaytoken.enabled} -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.authentication-gatewaytoken-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator - -hawkbit.server.tenant.configuration.authentication-gatewaytoken-key.keyName=authentication.gatewaytoken.key -hawkbit.server.tenant.configuration.authentication-gatewaytoken-key.defaultValue=${hawkbit.server.ddi.security.authentication.gatewaytoken.key} - -hawkbit.server.tenant.configuration.polling-time.keyName=pollingTime -hawkbit.server.tenant.configuration.polling-time.defaultValue=${hawkbit.controller.pollingTime} -hawkbit.server.tenant.configuration.polling-time.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator - -hawkbit.server.tenant.configuration.polling-overdue-time.keyName=pollingOverdueTime -hawkbit.server.tenant.configuration.polling-overdue-time.defaultValue=${hawkbit.controller.pollingOverdueTime} -hawkbit.server.tenant.configuration.polling-overdue-time.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator - -hawkbit.server.tenant.configuration.anonymous-download-enabled.keyName=anonymous.download.enabled -hawkbit.server.tenant.configuration.anonymous-download-enabled.defaultValue=${hawkbit.server.download.anonymous.enabled} -hawkbit.server.tenant.configuration.anonymous-download-enabled.dataType=java.lang.Boolean -hawkbit.server.tenant.configuration.anonymous-download-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/HawkbitServerProperties.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/HawkbitServerProperties.java index ac2f6c506..d975b7d46 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/HawkbitServerProperties.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/HawkbitServerProperties.java @@ -73,54 +73,16 @@ public class HawkbitServerProperties { * */ public static class Build { - /** - * Project artifact ID. - */ - private String artifact = ""; - - /** - * Project name. - */ - private String name = ""; - - /** - * Project description. - */ - private String description = ""; /** * Project version. */ private String version = ""; - public String getArtifact() { - return artifact; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - public String getVersion() { return version; } - public void setArtifact(final String artifact) { - this.artifact = artifact; - } - - public void setName(final String name) { - this.name = name; - } - - public void setDescription(final String description) { - this.description = description; - } - public void setVersion(final String version) { this.version = version; } diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java index 3b9297fc6..f5cdf4146 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/AbstractDDiApiIntegrationTest.java @@ -10,8 +10,10 @@ package org.eclipse.hawkbit.ddi.rest.resource; import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest; import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.context.TestPropertySource; @SpringApplicationConfiguration(classes = { DdiApiConfiguration.class }) +@TestPropertySource(locations = "classpath:/ddi-test.properties") public abstract class AbstractDDiApiIntegrationTest extends AbstractRestIntegrationTest { } diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index 13b76aabb..238da4f53 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -181,12 +181,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { contains(artifact.getMd5Hash()))) .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0].hashes.sha1", contains(artifact.getSha1Hash()))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.download.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.download-http.href", contains( HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() + "/artifacts/test1"))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.md5sum.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.md5sum-http.href", contains( HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() @@ -201,12 +201,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { contains(artifactSignature.getSha1Hash()))) .andExpect( - jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.download.href", + jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.download-http.href", contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() + "/artifacts/test1.signature"))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.md5sum.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.md5sum-http.href", contains( HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() @@ -342,12 +342,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0].hashes.sha1", contains(artifact.getSha1Hash()))) .andExpect( - jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.download.href", + jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.download-http.href", contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction) + "/artifacts/test1"))) .andExpect( - jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.md5sum.href", + jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.md5sum-http.href", contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction) + "/artifacts/test1.MD5SUM"))) @@ -359,11 +359,11 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1].hashes.sha1", contains(artifactSignature.getSha1Hash()))) .andExpect( - jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.download.href", + jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.download-http.href", contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction) + "/artifacts/test1.signature"))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.md5sum.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.md5sum-http.href", contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction) + "/artifacts/test1.signature.MD5SUM"))) @@ -455,12 +455,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { contains(artifact.getMd5Hash()))) .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0].hashes.sha1", contains(artifact.getSha1Hash()))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.download.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.download-http.href", contains( HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() + "/artifacts/test1"))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.md5sum.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[0]._links.md5sum-http.href", contains( HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() @@ -473,12 +473,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { contains(artifactSignature.getMd5Hash()))) .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1].hashes.sha1", contains(artifactSignature.getSha1Hash()))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.download.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.download-http.href", contains( HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() + "/artifacts/test1.signature"))) - .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.md5sum.href", + .andExpect(jsonPath("$.deployment.chunks[?(@.part==os)].artifacts[1]._links.md5sum-http.href", contains( HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).get().getId() diff --git a/hawkbit-ddi-resource/src/test/resources/application-test.properties b/hawkbit-ddi-resource/src/test/resources/application-test.properties deleted file mode 100644 index c26d733a1..000000000 --- a/hawkbit-ddi-resource/src/test/resources/application-test.properties +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright (c) 2015 Bosch Software Innovations GmbH and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# - -#logging.level.org.eclipse.hawkbit.rest.util.MockMvcResultPrinter=DEBUG -logging.level.=INFO -logging.level.org.eclipse.persistence=ERROR - -spring.data.mongodb.uri=mongodb://localhost/spArtifactRepository${random.value} -spring.data.mongodb.port=28017 - -hawkbit.server.ddi.security.authentication.header.enabled=true -hawkbit.server.ddi.security.authentication.gatewaytoken.name=TestToken - -spring.http.multipart.max-file-size=5MB - -hawkbit.server.security.dos.maxStatusEntriesPerAction=100 - -hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 - -spring.jpa.database=H2 -spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE -spring.datasource.driverClassName=org.h2.Driver -spring.datasource.tomcat.defaultAutoCommit=false -spring.datasource.username=sa -spring.datasource.password=sa - -flyway.enabled=true -flyway.sqlMigrationSuffix=${spring.jpa.database}.sql -#spring.jpa.show-sql=true - -# DDI configuration -hawkbit.controller.pollingTime=00:01:00 -hawkbit.controller.pollingOverdueTime=00:01:00 - -hawkbit.server.tenant.configuration.polling-time.keyName=pollingTime -hawkbit.server.tenant.configuration.polling-time.defaultValue=${hawkbit.controller.pollingTime} -hawkbit.server.tenant.configuration.polling-time.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator - -hawkbit.server.tenant.configuration.polling-overdue-time.keyName=pollingOverdueTime -hawkbit.server.tenant.configuration.polling-overdue-time.defaultValue=${hawkbit.controller.pollingOverdueTime} -hawkbit.server.tenant.configuration.polling-overdue-time.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator - - -hawkbit.artifact.url.protocols[0].rel=download -hawkbit.artifact.url.protocols[0].protocol=http -hawkbit.artifact.url.protocols[0].supports=DMF,DDI -hawkbit.artifact.url.protocols[0].ref={protocol}://{hostname}:{port}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName} -hawkbit.artifact.url.protocols[1].rel=md5sum -hawkbit.artifact.url.protocols[1].protocol=${hawkbit.artifact.url.protocols[0].protocol} -hawkbit.artifact.url.protocols[1].supports=${hawkbit.artifact.url.protocols[0].supports} -hawkbit.artifact.url.protocols[1].ref=${hawkbit.artifact.url.protocols[0].ref}.MD5SUM \ No newline at end of file diff --git a/hawkbit-ddi-resource/src/test/resources/ddi-test.properties b/hawkbit-ddi-resource/src/test/resources/ddi-test.properties new file mode 100644 index 000000000..bc6c0764a --- /dev/null +++ b/hawkbit-ddi-resource/src/test/resources/ddi-test.properties @@ -0,0 +1,22 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# DDI configuration - START +hawkbit.controller.pollingTime=00:01:00 +hawkbit.controller.pollingOverdueTime=00:01:00 +# DDI configuration - END + +# Upload configuration - START +spring.http.multipart.max-file-size=5MB +# Upload configuration - END + +# Quota - START +hawkbit.server.security.dos.maxStatusEntriesPerAction=100 +hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 +# Quota - END diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java index f1c0abc82..f8a7d65e2 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java @@ -41,10 +41,10 @@ import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.repository.model.TenantMetaData; import org.eclipse.hawkbit.security.DdiSecurityProperties; import org.eclipse.hawkbit.security.DdiSecurityProperties.Authentication.Anonymous; +import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.security.DdiSecurityProperties.Rp; import org.eclipse.hawkbit.security.SecurityContextTenantAware; import org.eclipse.hawkbit.security.SystemSecurityContext; -import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/hawkbit-mgmt-resource/src/test/resources/application-test.properties b/hawkbit-mgmt-resource/src/test/resources/application-test.properties deleted file mode 100644 index ff1a58e82..000000000 --- a/hawkbit-mgmt-resource/src/test/resources/application-test.properties +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (c) 2015 Bosch Software Innovations GmbH and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# - -#logging.level.org.eclipse.hawkbit.rest.util.MockMvcResultPrinter=DEBUG -logging.level.=INFO -logging.level.org.eclipse.persistence=ERROR - -hawkbit.server.ddi.security.authentication.header=true - -hawkbit.server.artifact.repo.upload.maxFileSize=5MB - -hawkbit.server.security.dos.maxStatusEntriesPerAction=100 - -hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 - -spring.jpa.database=H2 -flyway.sqlMigrationSuffix=${spring.jpa.database}.sql - -# SP Controller configuration -hawkbit.controller.pollingTime=00:01:00 -hawkbit.controller.pollingOverdueTime=00:01:00 - -hawkbit.server.tenant.configuration.polling-time.keyName=pollingTime -hawkbit.server.tenant.configuration.polling-time.defaultValue=${hawkbit.controller.pollingTime} -hawkbit.server.tenant.configuration.polling-time.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator - -hawkbit.server.tenant.configuration.polling-overdue-time.keyName=pollingOverdueTime -hawkbit.server.tenant.configuration.polling-overdue-time.defaultValue=${hawkbit.controller.pollingOverdueTime} -hawkbit.server.tenant.configuration.polling-overdue-time.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index a0be62de3..d381c6b1e 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -23,11 +23,11 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.QuotaExceededException; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; +import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java new file mode 100644 index 000000000..a0b84991c --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository.exception; + +import org.eclipse.hawkbit.exception.SpServerError; +import org.eclipse.hawkbit.exception.AbstractServerRtException; + +/** + * The {@link #InvalidTenantConfigurationKeyException} is thrown when an invalid + * configuration key is used. + * + */ +public class InvalidTenantConfigurationKeyException extends AbstractServerRtException { + + private static final long serialVersionUID = 1L; + private static final SpServerError THIS_ERROR = SpServerError.SP_CONFIGURATION_KEY_INVALID; + + /** + * Default constructor. + */ + public InvalidTenantConfigurationKeyException() { + super(THIS_ERROR); + } + + /** + * Parameterized constructor. + * + * @param cause + * of the exception + */ + public InvalidTenantConfigurationKeyException(final Throwable cause) { + super(THIS_ERROR, cause); + } + + /** + * Parameterized constructor. + * + * @param message + * of the exception + * @param cause + * of the exception + */ + public InvalidTenantConfigurationKeyException(final String message, final Throwable cause) { + super(message, THIS_ERROR, cause); + } + + /** + * Parameterized constructor. + * + * @param message + * of the exception + */ + public InvalidTenantConfigurationKeyException(final String message) { + super(message, THIS_ERROR); + } + +} diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java similarity index 100% rename from hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java rename to hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationProperties.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationProperties.java similarity index 98% rename from hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationProperties.java rename to hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationProperties.java index f79cfde09..c5800e4c2 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationProperties.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationProperties.java @@ -14,6 +14,7 @@ import java.util.Map; import org.eclipse.hawkbit.ControllerPollProperties; import org.eclipse.hawkbit.HawkbitServerProperties.Anonymous.Download; +import org.eclipse.hawkbit.repository.exception.InvalidTenantConfigurationKeyException; import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationStringValidator; import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationValidator; import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationValidatorException; diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationBooleanValidator.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationBooleanValidator.java similarity index 100% rename from hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationBooleanValidator.java rename to hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationBooleanValidator.java diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java similarity index 100% rename from hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java rename to hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationStringValidator.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationStringValidator.java similarity index 100% rename from hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationStringValidator.java rename to hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationStringValidator.java diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidator.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidator.java similarity index 100% rename from hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidator.java rename to hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidator.java diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java new file mode 100644 index 000000000..4cc545287 --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.tenancy.configuration.validator; + +import org.eclipse.hawkbit.exception.SpServerError; +import org.eclipse.hawkbit.exception.AbstractServerRtException; + +/** + * Exception which is thrown, when the validation of the configuration value has + * not been successful. + * + */ +public class TenantConfigurationValidatorException extends AbstractServerRtException { + + private static final long serialVersionUID = 1L; + private static final SpServerError THIS_ERROR = SpServerError.SP_CONFIGURATION_VALUE_INVALID; + + /** + * Default constructor. + */ + public TenantConfigurationValidatorException() { + super(THIS_ERROR); + } + + /** + * Parameterized constructor. + * + * @param cause + * of the exception + */ + public TenantConfigurationValidatorException(final Throwable cause) { + super(THIS_ERROR, cause); + } + + /** + * Parameterized constructor. + * + * @param message + * of the exception + * @param cause + * of the exception + */ + public TenantConfigurationValidatorException(final String message, final Throwable cause) { + super(message, THIS_ERROR, cause); + } + + /** + * Parameterized constructor. + * + * @param message + * of the exception + */ + public TenantConfigurationValidatorException(final String message) { + super(message, THIS_ERROR); + } + +} 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 new file mode 100644 index 000000000..2638559df --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import org.eclipse.hawkbit.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; + +/** + * Default configuration that is common to all repository implementations. + * + */ +@Configuration +@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class, + TenantConfigurationProperties.class }) +@PropertySource("classpath:/hawkbit-repository-defaults.properties") +public class RepositoryDefaultConfiguration { + +} diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/resources/application-test.properties b/hawkbit-repository/hawkbit-repository-core/src/main/resources/hawkbit-repository-defaults.properties similarity index 69% rename from hawkbit-repository/hawkbit-repository-jpa/src/test/resources/application-test.properties rename to hawkbit-repository/hawkbit-repository-core/src/main/resources/hawkbit-repository-defaults.properties index 9cf054b49..287df0101 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/resources/application-test.properties +++ b/hawkbit-repository/hawkbit-repository-core/src/main/resources/hawkbit-repository-defaults.properties @@ -7,48 +7,14 @@ # http://www.eclipse.org/legal/epl-v10.html # -logging.level.=INFO -logging.level.org.eclipse.persistence=ERROR -logging.level.org.eclipse.hawkbit.repository.test.matcher.EventVerifier=ERROR +# Defines the polling time for the controllers in HH:MM:SS notation +hawkbit.controller.pollingTime=00:05:00 +hawkbit.controller.pollingOverdueTime=00:05:00 +hawkbit.controller.maxPollingTime=23:59:59 +hawkbit.controller.minPollingTime=00:00:30 +# Attention: if you want to use a maximumPollingTime greater 23:59:59 you have to update the DurationField in the configuration window -spring.data.mongodb.uri=mongodb://localhost/spArtifactRepository${random.value} -spring.data.mongodb.port=28017 - -spring.http.multipart.max-file-size=5MB - -hawkbit.server.security.dos.maxStatusEntriesPerAction=100 - -hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 - -spring.jpa.database=H2 -spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE -spring.datasource.driverClassName=org.h2.Driver -spring.datasource.tomcat.default-auto-commit=false -spring.datasource.username=sa -spring.datasource.password=sa - -spring.datasource.eclipselink.logging.logger=JavaLogger -spring.jpa.properties.eclipselink.logging.level=FINE -spring.jpa.properties.eclipselink.logging.level.sql=FINE -spring.jpa.properties.eclipselink.logging.parameters=true - -flyway.enabled=true -flyway.sqlMigrationSuffix=${spring.jpa.database}.sql - -# DDI configuration -hawkbit.controller.pollingTime=00:01:00 -hawkbit.controller.pollingOverdueTime=00:01:00 - -# DDI and download security -hawkbit.server.ddi.security.authentication.header.authority= -hawkbit.server.ddi.security.authentication.targettoken.enabled=false -hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false -hawkbit.server.download.anonymous.enabled=false -hawkbit.server.ddi.security.authentication.header.enabled=true -hawkbit.server.ddi.security.authentication.gatewaytoken.name=TestToken -hawkbit.server.ddi.security.authentication.gatewaytoken.key= - -# Default tenant configuration properties +# Default tenant configuration - START hawkbit.server.tenant.configuration.authentication-header-enabled.keyName=authentication.header.enabled hawkbit.server.tenant.configuration.authentication-header-enabled.defaultValue=${hawkbit.server.ddi.security.authentication.header.enabled} hawkbit.server.tenant.configuration.authentication-header-enabled.dataType=java.lang.Boolean @@ -82,3 +48,4 @@ hawkbit.server.tenant.configuration.anonymous-download-enabled.keyName=anonymous hawkbit.server.tenant.configuration.anonymous-download-enabled.defaultValue=${hawkbit.server.download.anonymous.enabled} hawkbit.server.tenant.configuration.anonymous-download-enabled.dataType=java.lang.Boolean hawkbit.server.tenant.configuration.anonymous-download-enabled.validator=org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator +# Default tenant configuration - END diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java index eff9cfdaa..65c89615d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java @@ -13,7 +13,6 @@ import java.util.Map; import javax.persistence.EntityManager; import javax.sql.DataSource; -import org.eclipse.hawkbit.ControllerPollProperties; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.DeploymentManagement; @@ -21,7 +20,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.PropertiesQuotaManagement; -import org.eclipse.hawkbit.repository.RepositoryProperties; +import org.eclipse.hawkbit.repository.RepositoryDefaultConfiguration; import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutStatusCache; @@ -70,7 +69,6 @@ import org.eclipse.hawkbit.security.HawkbitSecurityProperties; import org.eclipse.hawkbit.security.SecurityTokenGenerator; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.tenancy.TenantAware; -import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; import org.eclipse.persistence.config.PersistenceUnitProperties; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Autowired; @@ -78,7 +76,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.orm.jpa.EntityScan; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEventPublisher; @@ -86,7 +83,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.PropertySource; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.integration.support.locks.LockRegistry; @@ -111,11 +110,11 @@ import com.google.common.collect.Maps; @EnableAspectJAutoProxy @Configuration @ComponentScan -@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class, - TenantConfigurationProperties.class }) @EnableScheduling @EnableRetry @EntityScan("org.eclipse.hawkbit.repository.jpa.model") +@PropertySource("classpath:/hawkbit-jpa-defaults.properties") +@Import({ RepositoryDefaultConfiguration.class }) public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { @Autowired diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties new file mode 100644 index 000000000..73c7fbccf --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties @@ -0,0 +1,25 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +### JPA / Datasource - START +spring.jpa.database=H2 +spring.jpa.show-sql=false +spring.datasource.tomcat.defaultAutoCommit=false +# Logging +spring.datasource.eclipselink.logging.logger=JavaLogger +spring.jpa.properties.eclipselink.logging.level=off +# Cluster aware +spring.datasource.eclipselink.query-results-cache=false +spring.datasource.eclipselink.cache.shared.default=false +# Flyway DDL +flyway.enabled=true +flyway.initOnMigrate=true +flyway.cleanDisabled=true +flyway.sqlMigrationSuffix=${spring.jpa.database}.sql +### JPA / Datasource - END diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java index 950f8f6ee..16f90316d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java @@ -30,12 +30,14 @@ import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.context.TestPropertySource; import org.springframework.transaction.annotation.Transactional; import com.google.common.collect.Lists; @SpringApplicationConfiguration(classes = { org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration.class }) +@TestPropertySource(locations = "classpath:/jpa-test.properties") public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest { protected static final String NOT_EXIST_ID = "1234"; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java index 7e4abfe9d..a5c3fb025 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.repository.jpa; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS; import static org.junit.Assert.fail; @@ -32,7 +33,10 @@ import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedE import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; +import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException; +import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException; import org.eclipse.hawkbit.repository.model.Action; +import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.DistributionSet; @@ -622,6 +626,79 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest { .isEqualTo(testData); } + @Test + @Description("Ensures that target attribute update fails if quota hits.") + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), + @Expect(type = TargetUpdatedEvent.class, count = 2) }) + public void updateTargetAttributesFailsIfTooManyEntries() throws Exception { + final String controllerId = "test123"; + final int allowedAttributes = 10; + testdataFactory.createTarget(controllerId); + + assertThatExceptionOfType(ToManyAttributeEntriesException.class).isThrownBy(() -> securityRule + .runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> { + writeAttributes(controllerId, allowedAttributes + 1, "key", "value"); + return null; + })).withMessageContaining("" + allowedAttributes); + + // verify that no attributes have been written + assertThat(targetManagement.getControllerAttributes(controllerId)).isEmpty(); + + // Write allowed number of attributes twice with same key should result + // in update but work + securityRule.runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> { + writeAttributes(controllerId, allowedAttributes, "key", "value1"); + writeAttributes(controllerId, allowedAttributes, "key", "value2"); + return null; + }); + assertThat(targetManagement.getControllerAttributes(controllerId)).hasSize(10); + + // Now rite one more + assertThatExceptionOfType(ToManyAttributeEntriesException.class).isThrownBy(() -> securityRule + .runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> { + writeAttributes(controllerId, 1, "additional", "value1"); + return null; + })).withMessageContaining("" + allowedAttributes); + assertThat(targetManagement.getControllerAttributes(controllerId)).hasSize(10); + + } + + private void writeAttributes(final String controllerId, final int allowedAttributes, final String keyPrefix, + final String valuePrefix) { + final Map testData = Maps.newHashMapWithExpectedSize(allowedAttributes); + for (int i = 0; i < allowedAttributes; i++) { + testData.put(keyPrefix + i, valuePrefix); + } + controllerManagement.updateControllerAttributes(controllerId, testData); + } + + @Test + @Description("Controller providing status entries fails if providing more than permitted by quota.") + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), + @Expect(type = DistributionSetCreatedEvent.class, count = 1), + @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), + @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), + @Expect(type = SoftwareModuleCreatedEvent.class, count = 3) }) + public void controllerProvidesIntermediateFeedbackFailsIfQuotaHit() { + final int allowStatusEntries = 10; + final Long actionId = createTargetAndAssignDs(); + + // Fails as one entry is already in there from the assignment + assertThatExceptionOfType(TooManyStatusEntriesException.class).isThrownBy(() -> securityRule + .runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> { + writeStatus(actionId, allowStatusEntries); + return null; + })).withMessageContaining("" + allowStatusEntries); + + } + + private void writeStatus(final Long actionId, final int allowedStatusEntries) { + for (int i = 0; i < allowedStatusEntries; i++) { + controllerManagement.addInformationalActionStatus( + entityFactory.actionStatus().create(actionId).status(Status.RUNNING).message("test" + i)); + } + } + @Test @Description("Test to verify the storage and retrieval of action history.") public void findMessagesByActionStatusId() { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java index a25862f96..b124ec51a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TenantConfigurationManagementTest.java @@ -16,9 +16,9 @@ import java.time.Duration; import java.util.HashMap; import java.util.Map; +import org.eclipse.hawkbit.repository.exception.InvalidTenantConfigurationKeyException; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.tenancy.configuration.DurationHelper; -import org.eclipse.hawkbit.tenancy.configuration.InvalidTenantConfigurationKeyException; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationValidatorException; import org.junit.Assert; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/resources/jpa-test.properties b/hawkbit-repository/hawkbit-repository-jpa/src/test/resources/jpa-test.properties new file mode 100644 index 000000000..60e396007 --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/resources/jpa-test.properties @@ -0,0 +1,13 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# Quota - START +hawkbit.server.security.dos.maxStatusEntriesPerAction=10 +hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 +# Quota - END diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java index ee9b91497..0b9820e74 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java @@ -53,6 +53,7 @@ import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.PropertySource; import org.springframework.context.event.SimpleApplicationEventMulticaster; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.data.domain.AuditorAware; @@ -74,6 +75,7 @@ import org.springframework.util.AntPathMatcher; ControllerPollProperties.class, TenantConfigurationProperties.class }) @Profile("test") @EnableAutoConfiguration +@PropertySource("classpath:/hawkbit-test-defaults.properties") public class TestConfiguration implements AsyncConfigurer { /** diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties b/hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties new file mode 100644 index 000000000..4af1530be --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-test/src/main/resources/hawkbit-test-defaults.properties @@ -0,0 +1,55 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# Test utility properties for easier fault investigation - START +## Logging - START +logging.level.=INFO +logging.level.org.eclipse.persistence=ERROR +logging.level.org.eclipse.hawkbit.repository.test.matcher.EventVerifier=ERROR +spring.jpa.properties.eclipselink.logging.level=FINE +spring.jpa.properties.eclipselink.logging.level.sql=FINE +spring.jpa.properties.eclipselink.logging.parameters=true +## Logging - END +# Test utility properties for easier fault investigation - END + +# Default properties for test that can be overridden during test run - START +## JPA Repository - START +spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE +## JPA Repository - END +# Default properties for test that can be overridden during test run - END + +# Properties that are managed by autoconfigure module at runtime and not available during test - START +## DDI and download security - START +hawkbit.server.ddi.security.authentication.header.enabled=true +hawkbit.server.ddi.security.authentication.header.authority= +hawkbit.server.ddi.security.authentication.targettoken.enabled=false +hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false +hawkbit.server.download.anonymous.enabled=false +hawkbit.server.ddi.security.authentication.gatewaytoken.key= +hawkbit.server.ddi.security.authentication.gatewaytoken.name=TestToken +## DDI and download security - END + +## Download URL Generation - START +hawkbit.artifact.url.protocols.download-http.rel=download-http +hawkbit.artifact.url.protocols.download-http.hostname=localhost +hawkbit.artifact.url.protocols.download-http.ip=127.0.0.1 +hawkbit.artifact.url.protocols.download-http.protocol=http +hawkbit.artifact.url.protocols.download-http.port=8080 +hawkbit.artifact.url.protocols.download-http.supports=DMF,DDI +hawkbit.artifact.url.protocols.download-http.ref={protocol}://{hostnameRequest}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName} +hawkbit.artifact.url.protocols.md5sum-http.rel=md5sum-http +hawkbit.artifact.url.protocols.md5sum-http.protocol=${hawkbit.artifact.url.protocols.download-http.protocol} +hawkbit.artifact.url.protocols.md5sum-http.hostname=${hawkbit.artifact.url.protocols.download-http.hostname} +hawkbit.artifact.url.protocols.md5sum-http.ip=${hawkbit.artifact.url.protocols.download-http.ip} +hawkbit.artifact.url.protocols.md5sum-http.port=${hawkbit.artifact.url.protocols.download-http.port} +hawkbit.artifact.url.protocols.md5sum-http.supports=DDI +hawkbit.artifact.url.protocols.md5sum-http.ref=${hawkbit.artifact.url.protocols.download-http.ref}.MD5SUM +## Download URL Generation - END + +# Properties that are managed by autoconfigure module at runtime and not available during test - END diff --git a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application-cloudsandbox.properties b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application-cloudsandbox.properties index ec3c376f5..02b49a940 100644 --- a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application-cloudsandbox.properties +++ b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application-cloudsandbox.properties @@ -12,8 +12,6 @@ server.tomcat.protocol-header=X-Forwarded-Proto # IBM Adresses unpredictable server.tomcat.internal-proxies=.* -vaadin.servlet.productionMode=true - # Sandbox, small files only spring.http.multipart.max-file-size=100KB spring.http.multipart.max-request-size=-1 diff --git a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties index 399a386c9..9d648e7fe 100644 --- a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties +++ b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties @@ -16,9 +16,6 @@ hawkbit.server.ddi.security.authentication.anonymous.enabled=true hawkbit.server.ddi.security.authentication.targettoken.enabled=true hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=true -## Vaadin configuration -vaadin.servlet.productionMode=false - ## Configuration for DMF/RabbitMQ integration spring.profiles.active=amqp spring.rabbitmq.username=guest @@ -26,9 +23,6 @@ spring.rabbitmq.password=guest spring.rabbitmq.virtualHost=/ spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 -hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl -hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter -hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver # UI demo account hawkbit.server.ui.demo.password=admin diff --git a/hawkbit-runtime/hawkbit-update-server/src/main/resources/logback-spring.xml b/hawkbit-runtime/hawkbit-update-server/src/main/resources/logback-spring.xml index 2f64ef001..a1d8e6e8a 100644 --- a/hawkbit-runtime/hawkbit-update-server/src/main/resources/logback-spring.xml +++ b/hawkbit-runtime/hawkbit-update-server/src/main/resources/logback-spring.xml @@ -17,11 +17,6 @@ - - - - - diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java index dd993e5f6..fd9d27c50 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java @@ -17,6 +17,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; /** * Enables UI components for the Management UI. @@ -26,6 +27,7 @@ import org.springframework.context.annotation.Import; @ComponentScan @Import(AsyncVaadinServletConfiguration.class) @EnableConfigurationProperties(UiProperties.class) +@PropertySource("classpath:/hawkbit-ui-defaults.properties") public class MgmtUiConfiguration { @Bean diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java index f6ed2850f..ab2535b46 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java @@ -27,7 +27,7 @@ import com.vaadin.ui.VerticalLayout; * View to configure the polling interval and the overdue time. */ public class PollingConfigurationView extends BaseConfigurationView - implements ConfigurationGroup, ConfigurationItem.ConfigurationItemChangeListener { + implements ConfigurationItem.ConfigurationItemChangeListener { private static final long serialVersionUID = 1L; diff --git a/hawkbit-ui/src/main/resources/hawkbit-ui-defaults.properties b/hawkbit-ui/src/main/resources/hawkbit-ui-defaults.properties new file mode 100644 index 000000000..00b6cebd1 --- /dev/null +++ b/hawkbit-ui/src/main/resources/hawkbit-ui-defaults.properties @@ -0,0 +1,14 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# Vaadin Servlet +vaadin.servlet.productionMode=true +vaadin.servlet.urlMapping=/UI/* +vaadin.servlet.heartbeatInterval=60 +vaadin.servlet.closeIdleSessions=false \ No newline at end of file