Skip to content

Commit

Permalink
Increase target name to 128 and target controller id to 256 (eclipse-…
Browse files Browse the repository at this point in the history
…hawkbit#849)

* Increase target name to 128 and target controller id to 256
* Fix test failures by using constant NamedEntity.NAME_MAX_SIZE + 1
* Use constant NamedEntity.NAME_MAX_SIZE + 1 for mgmt-resource tests
* Add db migration scripts to increase the controllerId and name limit
* Fix review issues
* Use correct constant field for junit tests
* Change Hawkbit documentation url of application-<db>.properties
* Add new line at the end of db migration scripts
* Update assertion description
* Revert copyright years to its creator year
* Add DDI-, AMQP- and controller management-tests

Signed-off-by: Florian Ruschbaschan <[email protected]>
  • Loading branch information
floruschbaschan authored and stefbehl committed Jun 18, 2019
1 parent 54bc6ce commit 52bc266
Show file tree
Hide file tree
Showing 21 changed files with 427 additions and 337 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface NamedEntity extends TenantAwareBaseEntity {
/**
* Maximum length of name.
*/
int NAME_MAX_SIZE = 64;
int NAME_MAX_SIZE = 128;

/**
* Maximum length of description.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface Target extends NamedEntity {
/**
* Maximum length of controllerId.
*/
int CONTROLLER_ID_MAX_SIZE = 64;
int CONTROLLER_ID_MAX_SIZE = 256;

/**
* Maximum length of securityToken.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALTER TABLE sp_distribution_set ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_distribution_set_type ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_distributionset_tag ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_base_software_module ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_rollout ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_rolloutgroup ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_software_module_type ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_target ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_target_filter_query ALTER COLUMN name SET DATA TYPE VARCHAR(128);
ALTER TABLE sp_target_tag ALTER COLUMN name SET DATA TYPE VARCHAR(128);


ALTER TABLE sp_target ALTER COLUMN controller_id SET DATA TYPE VARCHAR(256);
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ CREATE TABLE sp_action
maintenance_duration VARCHAR(40),
maintenance_time_zone VARCHAR(40),
PRIMARY KEY (id)
);

ALTER TABLE sp_action ADD column maintenance_cron_schedule VARCHAR(40);
ALTER TABLE sp_action ADD column maintenance_duration VARCHAR(40);
ALTER TABLE sp_action ADD column maintenance_time_zone VARCHAR(40);
);

CREATE INDEX sp_idx_action_01
ON sp_action (tenant, distribution_set);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALTER TABLE sp_distribution_set ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_distribution_set_type ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_distributionset_tag ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_base_software_module ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_rollout ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_rolloutgroup ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_software_module_type ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_target ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_target_filter_query ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_target_tag ALTER COLUMN name VARCHAR(128);


ALTER TABLE sp_target ALTER COLUMN controller_id VARCHAR(256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALTER TABLE sp_distribution_set MODIFY name VARCHAR(128);
ALTER TABLE sp_distribution_set_type MODIFY name VARCHAR(128);
ALTER TABLE sp_distributionset_tag MODIFY name VARCHAR(128);
ALTER TABLE sp_base_software_module MODIFY name VARCHAR(128);
ALTER TABLE sp_rollout MODIFY name VARCHAR(128);
ALTER TABLE sp_rolloutgroup MODIFY name VARCHAR(128);
ALTER TABLE sp_software_module_type MODIFY name VARCHAR(128);
ALTER TABLE sp_target MODIFY name VARCHAR(128);
ALTER TABLE sp_target_filter_query MODIFY name VARCHAR(128);
ALTER TABLE sp_target_tag MODIFY name VARCHAR(128);


ALTER TABLE sp_target MODIFY controller_id VARCHAR(256);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALTER TABLE sp_distribution_set ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_distribution_set_type ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_distributionset_tag ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_base_software_module ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_rollout ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_rolloutgroup ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_software_module_type ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_target ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_target_filter_query ALTER COLUMN name VARCHAR(128);
ALTER TABLE sp_target_tag ALTER COLUMN name VARCHAR(128);


ALTER TABLE sp_target ALTER COLUMN controller_id VARCHAR(256);

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
Expand Down Expand Up @@ -218,7 +220,7 @@ private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a")
.name(RandomStringUtils.randomAlphanumeric(65))))
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))))
.as("entity with too long name should not be created");

assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
Expand All @@ -232,7 +234,7 @@ private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
.name(RandomStringUtils.randomAlphanumeric(65))))
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))))
.as("entity with too long name should not be updated");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -251,21 +253,21 @@ private void createAndUpdateDistributionSetWithInvalidVersion(final Distribution

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
.version(RandomStringUtils.randomAlphanumeric(65))))
.as("entity with too long name should not be created");
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))))
.as("entity with too long version should not be created");

assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a").version("")))
.as("entity with too long name should not be created");
.as("entity with too short version should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
.version(RandomStringUtils.randomAlphanumeric(65))))
.as("entity with too long name should not be updated");
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))))
.as("entity with too long version should not be updated");

assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()).version("")))
.as("entity with too short name should not be updated");
.as("entity with too short version should not be updated");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.junit.Test;
Expand Down Expand Up @@ -128,7 +130,7 @@ private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a")
.name(RandomStringUtils.randomAlphanumeric(65))))
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))))
.as("set with too long name should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -147,7 +149,7 @@ private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
.name(RandomStringUtils.randomAlphanumeric(65))))
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))))
.as("set with too long name should not be updated");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -165,7 +167,7 @@ private void createAndUpdateDistributionSetWithInvalidVersion(final Distribution

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
.version(RandomStringUtils.randomAlphanumeric(65))))
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))))
.as("set with too long version should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -184,7 +186,7 @@ private void createAndUpdateDistributionSetWithInvalidVersion(final Distribution

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
.version(RandomStringUtils.randomAlphanumeric(65))))
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))))
.as("set with too long version should not be updated");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetMetadata;
Expand Down Expand Up @@ -251,7 +252,7 @@ private void createAndUpdateTargetWithInvalidName(final Target target) {

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
.name(RandomStringUtils.randomAlphanumeric(65))))
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))))
.as("target with too long name should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -261,7 +262,7 @@ private void createAndUpdateTargetWithInvalidName(final Target target) {

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
.name(RandomStringUtils.randomAlphanumeric(65))))
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))))
.as("target with too long name should not be updated");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -281,7 +282,7 @@ private void createAndUpdateTargetWithInvalidSecurityToken(final Target target)

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
.securityToken(RandomStringUtils.randomAlphanumeric(129))))
.securityToken(RandomStringUtils.randomAlphanumeric(Target.SECURITY_TOKEN_MAX_SIZE + 1))))
.as("target with too long token should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -291,7 +292,7 @@ private void createAndUpdateTargetWithInvalidSecurityToken(final Target target)

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
.securityToken(RandomStringUtils.randomAlphanumeric(129))))
.securityToken(RandomStringUtils.randomAlphanumeric(Target.SECURITY_TOKEN_MAX_SIZE + 1))))
.as("target with too long token should not be updated");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand Down Expand Up @@ -340,8 +341,8 @@ private void createTargetWithInvalidControllerId() {
.as("target with null controller id should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> targetManagement
.create(entityFactory.target().create().controllerId(RandomStringUtils.randomAlphanumeric(65))))
.isThrownBy(() -> targetManagement.create(entityFactory.target().create()
.controllerId(RandomStringUtils.randomAlphanumeric(Target.CONTROLLER_ID_MAX_SIZE + 1))))
.as("target with too long controller id should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag;
Expand Down Expand Up @@ -132,7 +133,8 @@ private void createAndUpdateTagWithInvalidName(final Tag tag) {

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> targetTagManagement
.create(entityFactory.tag().create().name(RandomStringUtils.randomAlphanumeric(65))))
.create(entityFactory.tag().create().name(RandomStringUtils.randomAlphanumeric(
NamedEntity.NAME_MAX_SIZE + 1))))
.as("tag with too long name should not be created");

assertThatExceptionOfType(ConstraintViolationException.class)
Expand All @@ -141,7 +143,8 @@ private void createAndUpdateTagWithInvalidName(final Tag tag) {

assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> targetTagManagement
.update(entityFactory.tag().update(tag.getId()).name(RandomStringUtils.randomAlphanumeric(65))))
.update(entityFactory.tag().update(tag.getId()).name(RandomStringUtils.randomAlphanumeric(
NamedEntity.NAME_MAX_SIZE + 1))))
.as("tag with too long name should not be updated");

assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
Expand Down
Loading

0 comments on commit 52bc266

Please sign in to comment.