Restructuring properties (#528)
* Moved test property file to one locations Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Added missing properties Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Move property defaults to respective modules. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Moved test relevant properties in respective modules. Added missing tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * deleted security.filter-order property Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Remove empty line Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com> * Removed build properties Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
committed by
Kai Zimmermann
parent
352bfcff24
commit
f42d9b6978
@@ -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";
|
||||
|
||||
@@ -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<String, String> 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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,84 +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.=INFO
|
||||
logging.level.org.eclipse.persistence=ERROR
|
||||
logging.level.org.eclipse.hawkbit.repository.test.matcher.EventVerifier=ERROR
|
||||
|
||||
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
|
||||
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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user