From 0f0b9eab1f0f2b605a12ba1fb2d1ba443270f356 Mon Sep 17 00:00:00 2001 From: Melanie Retter Date: Tue, 12 Apr 2016 18:09:27 +0200 Subject: [PATCH 01/16] Create filter has different layout than rollout and the other widgets --> fixed In addition I add a constant for the header caption Signed-off-by: Melanie Retter --- .../ui/filtermanagement/TargetFilterHeader.java | 15 ++++++++++----- .../hawkbit/ui/utils/SPUIComponetIdProvider.java | 5 +++++ .../eclipse/hawkbit/ui/utils/SPUIDefinitions.java | 6 +++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java index 08592f20c..12b4311f1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java @@ -13,7 +13,6 @@ import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; -import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; @@ -79,7 +78,7 @@ public class TargetFilterHeader extends VerticalLayout { } private Label createHeaderCaption() { - final Label captionLabel = SPUIComponentProvider.getLabel("Custom Filters", + final Label captionLabel = SPUIComponentProvider.getLabel(getHeaderCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION); return captionLabel; } @@ -110,10 +109,9 @@ public class TargetFilterHeader extends VerticalLayout { } private Button createAddButton() { - final Button button = SPUIComponentProvider.getButton("camp.search.add.Id", "Create Filter", "Create Filter", - "", false, null, SPUIButtonStyleSmall.class); + final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS, + SPUIButtonStyleSmallNoBorder.class); button.addClickListener(event -> addNewFilter()); - button.addStyleName("on-focus-no-border link"); return button; } @@ -187,4 +185,11 @@ public class TargetFilterHeader extends VerticalLayout { eventBus.publish(this, CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE); } + protected String getAddIconId() { + return SPUIComponetIdProvider.TARGET_FILTER_ADD_ICON_ID; + } + + protected String getHeaderCaption() { + return SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java index 48e501e1d..f2f94ce59 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java @@ -75,6 +75,11 @@ public final class SPUIComponetIdProvider { */ public static final String TARGET_TEXT_FIELD = "target.search.textfield"; + /** + * ID for add target filter icon + */ + public static final String TARGET_FILTER_ADD_ICON_ID = "target.filter.add.id"; + /** * ID-Dist. */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java index b29283ef8..75ea912a9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java @@ -922,6 +922,11 @@ public final class SPUIDefinitions { */ public static final String CUSTOM_FILTER_ASSIGNED_DS = "Assigned DS"; + /** + * TARGET_FILTER_MANAGEMENT - header caption . + */ + public static final String TARGET_FILTER_LIST_HEADER_CAPTION = "Custom Filters"; + /** * CUSTOM_FILTER_STATUS. */ @@ -1001,7 +1006,6 @@ public final class SPUIDefinitions { */ public static final String ROLLOUT_GROUP_STARTED_DATE = "Started date"; - /** * Rollout group status column property. */ From 7d81054d4c7ddb6bad743d5589ae8d8052a6885c Mon Sep 17 00:00:00 2001 From: Melanie Retter Date: Tue, 10 May 2016 10:21:40 +0200 Subject: [PATCH 02/16] remove methods and use the constant name. Signed-off-by: Melanie Retter --- .../ui/filtermanagement/TargetFilterHeader.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java index 12b4311f1..79877f299 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java @@ -78,9 +78,8 @@ public class TargetFilterHeader extends VerticalLayout { } private Label createHeaderCaption() { - final Label captionLabel = SPUIComponentProvider.getLabel(getHeaderCaption(), + return SPUIComponentProvider.getLabel(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION, SPUILabelDefinitions.SP_WIDGET_CAPTION); - return captionLabel; } private void buildLayout() { @@ -109,8 +108,8 @@ public class TargetFilterHeader extends VerticalLayout { } private Button createAddButton() { - final Button button = SPUIComponentProvider.getButton(getAddIconId(), "", "", null, false, FontAwesome.PLUS, - SPUIButtonStyleSmallNoBorder.class); + final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.TARGET_FILTER_ADD_ICON_ID, "", "", + null, false, FontAwesome.PLUS, SPUIButtonStyleSmallNoBorder.class); button.addClickListener(event -> addNewFilter()); return button; } @@ -185,11 +184,4 @@ public class TargetFilterHeader extends VerticalLayout { eventBus.publish(this, CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE); } - protected String getAddIconId() { - return SPUIComponetIdProvider.TARGET_FILTER_ADD_ICON_ID; - } - - protected String getHeaderCaption() { - return SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION; - } } From 7a281a8236d2440984ebf7c71e40a787cd19ac3e Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 13 May 2016 15:38:52 +0200 Subject: [PATCH 03/16] allow the getTargetSecurityToken can be called as system code Signed-off-by: Michael Hirsch --- .../repository/DeploymentManagement.java | 9 ++++++- .../hawkbit/repository/model/Target.java | 9 +++++-- .../security/SystemSecurityContext.java | 26 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 805b66d75..1e58ea938 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -54,6 +54,7 @@ import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetInfo; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.specifications.TargetSpecifications; +import org.eclipse.hawkbit.security.SystemSecurityContext; import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -118,6 +119,9 @@ public class DeploymentManagement { @Autowired private AfterTransactionCommitExecutor afterCommit; + @Autowired + private SystemSecurityContext systemSecurityContext; + /** * method assigns the {@link DistributionSet} to all {@link Target}s. * @@ -422,11 +426,14 @@ public class DeploymentManagement { private void assignDistributionSetEvent(final Target target, final Long actionId, final List softwareModules) { target.getTargetInfo().setUpdateStatus(TargetUpdateStatus.PENDING); + final String targetSecurityToken = systemSecurityContext.runAsSystem(() -> { + return target.getSecurityToken(); + }); afterCommit.afterCommit(() -> { eventBus.post(new TargetInfoUpdateEvent(target.getTargetInfo())); eventBus.post(new TargetAssignDistributionSetEvent(target.getOptLockRevision(), target.getTenant(), target.getControllerId(), actionId, softwareModules, target.getTargetInfo().getAddress(), - target.getSecurityToken())); + targetSecurityToken)); }); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java index 5f37fb653..8947ea6c3 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java @@ -38,6 +38,7 @@ import javax.validation.constraints.Size; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.model.helper.SecurityChecker; import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder; +import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder; import org.eclipse.persistence.annotations.CascadeOnDelete; import org.springframework.data.domain.Persistable; @@ -193,10 +194,14 @@ public class Target extends NamedEntity implements Persistable { } /** - * @return the securityToken + * @return the securityToken if the current security context contains the + * necessary permission {@link SpPermission#READ_TARGET_SEC_TOKEN} + * or the current context is executed as system code, otherwise + * {@code null}. */ public String getSecurityToken() { - if (SecurityChecker.hasPermission(SpPermission.READ_TARGET_SEC_TOKEN)) { + if (SystemSecurityContextHolder.getInstance().getSystemSecurityContext().isCurrentThreadSystemCode() + || SecurityChecker.hasPermission(SpPermission.READ_TARGET_SEC_TOKEN)) { return securityToken; } return null; diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java index b22b54e39..409e714a0 100644 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java @@ -49,6 +49,21 @@ public class SystemSecurityContext { this.tenantAware = tenantAware; } + /** + * Runs a given {@link Callable} within a system security context, which is + * permitted to call secured system code. Often the system needs to call + * secured methods by it's own without relying on the current security + * context e.g. if the current security context does not contain the + * necessary permission it's necessary to execute code as system code to + * execute necessary methods and functionality. + * + * The security context will be switched to the system code and back after + * the callable is called. + * + * @param callable + * the callable to call within the system security context + * @return the return value of the {@link Callable#call()} method. + */ public T runAsSystem(final Callable callable) { final SecurityContext oldContext = SecurityContextHolder.getContext(); try { @@ -68,6 +83,17 @@ public class SystemSecurityContext { } } + /** + * @return {@code true} if the current running code is running as system + * code block. + */ + public boolean isCurrentThreadSystemCode() { + if (SecurityContextHolder.getContext().getAuthentication() instanceof SystemCodeAuthentication) { + return true; + } + return false; + } + private static void setSystemContext() { final SecurityContextImpl securityContextImpl = new SecurityContextImpl(); securityContextImpl.setAuthentication(new SystemCodeAuthentication()); From dcbf27e3ed3a076e9e5a6c94fc9df9a862b1d370 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 17 May 2016 08:04:33 +0200 Subject: [PATCH 04/16] add junit tests to security of getTargetSecurityToken Signed-off-by: Michael Hirsch --- .../hawkbit/AbstractIntegrationTest.java | 7 +++-- .../hawkbit/WithSpringAuthorityRule.java | 14 ++++++--- .../repository/TargetManagementTest.java | 31 +++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java index b7091edf8..ddd850df1 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java @@ -48,6 +48,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.utils.RepositoryDataGenerator.DatabaseCleanupUtil; import org.eclipse.hawkbit.security.DosFilter; +import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.tenancy.TenantAware; import org.junit.After; import org.junit.AfterClass; @@ -181,11 +182,10 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Autowired protected TenantAwareCacheManager cacheManager; - + @Autowired protected TenantConfigurationManagement tenantConfigurationManagement; - @Autowired protected RolloutManagement rolloutManagement; @@ -198,6 +198,9 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Autowired protected RolloutRepository rolloutRepository; + @Autowired + protected SystemSecurityContext systemSecurityContext; + protected MockMvc mvc; @Autowired diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithSpringAuthorityRule.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithSpringAuthorityRule.java index 15fda51b4..40f6a64c2 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithSpringAuthorityRule.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithSpringAuthorityRule.java @@ -160,19 +160,23 @@ public class WithSpringAuthorityRule implements TestRule { } public static WithUser withUser(final String principal, final String... authorities) { - return withUserAndTenant(principal, "default", true, authorities); + return withUserAndTenant(principal, "default", true, true, authorities); + } + + public static WithUser withUser(final String principal, final boolean allSpPermision, final String... authorities) { + return withUserAndTenant(principal, "default", true, allSpPermision, authorities); } public static WithUser withUser(final boolean autoCreateTenant) { - return withUserAndTenant("bumlux", "default", autoCreateTenant, new String[] {}); + return withUserAndTenant("bumlux", "default", autoCreateTenant, true, new String[] {}); } public static WithUser withUserAndTenant(final String principal, final String tenant, final String... authorities) { - return withUserAndTenant(principal, tenant, true, new String[] {}); + return withUserAndTenant(principal, tenant, true, true, new String[] {}); } public static WithUser withUserAndTenant(final String principal, final String tenant, - final boolean autoCreateTenant, final String... authorities) { + final boolean autoCreateTenant, final boolean allSpPermission, final String... authorities) { return new WithUser() { @Override @@ -197,7 +201,7 @@ public class WithSpringAuthorityRule implements TestRule { @Override public boolean allSpPermissions() { - return true; + return allSpPermission; } @Override diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java index a223c25b4..1c039c8c8 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -32,6 +32,7 @@ import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithSpringAuthorityRule; import org.eclipse.hawkbit.WithUser; +import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.TenantNotExistException; import org.eclipse.hawkbit.repository.model.Action; @@ -56,6 +57,36 @@ import ru.yandex.qatools.allure.annotations.Stories; @Stories("Target Management") public class TargetManagementTest extends AbstractIntegrationTest { + @Test + @Description("Ensures that retrieving the target security is only permitted with the necessary permissions.") + public void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception { + final Target createdTarget = targetManagement.createTarget(new Target("targetWithSecurityToken")); + + // retrieve security token only with READ_TARGET_SEC_TOKEN permission + final String securityTokenWithReadPermission = securityRule.runAs(WithSpringAuthorityRule + .withUser("OnlyTargetReadPermission", false, SpPermission.READ_TARGET_SEC_TOKEN.toString()), () -> { + return createdTarget.getSecurityToken(); + }); + + // retrieve security token as system code execution + final String securityTokenAsSystemCode = systemSecurityContext.runAsSystem(() -> { + return createdTarget.getSecurityToken(); + }); + + // retrieve security token without any permissions + final String securityTokenWithoutPermission = securityRule + .runAs(WithSpringAuthorityRule.withUser("NoPermission", false), () -> { + return createdTarget.getSecurityToken(); + }); + + assertThat(createdTarget.getSecurityToken()).isNotNull(); + assertThat(securityTokenWithReadPermission).isNotNull(); + assertThat(securityTokenAsSystemCode).isNotNull(); + + assertThat(securityTokenWithoutPermission).isNull(); + + } + @Test @Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists.") @WithUser(tenantId = "tenantWhichDoesNotExists", allSpPermissions = true, autoCreateTenant = false) From 56487ad1b78af39487811fc8c99de4833a411519 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 17 May 2016 10:57:08 +0200 Subject: [PATCH 05/16] remove if-statement and return immediately the instanceof result Signed-off-by: Michael Hirsch --- .../org/eclipse/hawkbit/security/SystemSecurityContext.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java index 409e714a0..f849eb541 100644 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java @@ -88,10 +88,7 @@ public class SystemSecurityContext { * code block. */ public boolean isCurrentThreadSystemCode() { - if (SecurityContextHolder.getContext().getAuthentication() instanceof SystemCodeAuthentication) { - return true; - } - return false; + return SecurityContextHolder.getContext().getAuthentication() instanceof SystemCodeAuthentication; } private static void setSystemContext() { From 9d6527a3e29567c0c0b55951121d1356a65d7a3b Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 18 May 2016 09:03:58 +0200 Subject: [PATCH 06/16] Switched back to Boots default logger: logback Signed-off-by: Kai Zimmermann --- examples/hawkbit-device-simulator/pom.xml | 26 +++++++++++++------ .../src/main/resources/logback.xml | 22 ++++++++++++++++ examples/hawkbit-example-app/pom.xml | 26 +++++++++++++------ .../src/main/resources/logback.xml | 22 ++++++++++++++++ pom.xml | 23 ---------------- 5 files changed, 80 insertions(+), 39 deletions(-) create mode 100644 examples/hawkbit-device-simulator/src/main/resources/logback.xml create mode 100644 examples/hawkbit-example-app/src/main/resources/logback.xml diff --git a/examples/hawkbit-device-simulator/pom.xml b/examples/hawkbit-device-simulator/pom.xml index 728fe0595..99ed154d9 100644 --- a/examples/hawkbit-device-simulator/pom.xml +++ b/examples/hawkbit-device-simulator/pom.xml @@ -82,16 +82,26 @@ org.springframework.boot spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - + - org.springframework.boot - spring-boot-starter-log4j2 + org.apache.logging.log4j + log4j-api + + + + org.slf4j + jul-to-slf4j + + + + org.slf4j + jcl-over-slf4j + + + + org.slf4j + log4j-over-slf4j com.vaadin diff --git a/examples/hawkbit-device-simulator/src/main/resources/logback.xml b/examples/hawkbit-device-simulator/src/main/resources/logback.xml new file mode 100644 index 000000000..0cdbf8ff6 --- /dev/null +++ b/examples/hawkbit-device-simulator/src/main/resources/logback.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/hawkbit-example-app/pom.xml b/examples/hawkbit-example-app/pom.xml index a5c0f864d..2f37a510e 100644 --- a/examples/hawkbit-example-app/pom.xml +++ b/examples/hawkbit-example-app/pom.xml @@ -96,16 +96,26 @@ org.springframework.boot spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - + - org.springframework.boot - spring-boot-starter-log4j2 + org.apache.logging.log4j + log4j-api + + + + org.slf4j + jul-to-slf4j + + + + org.slf4j + jcl-over-slf4j + + + + org.slf4j + log4j-over-slf4j org.springframework.security diff --git a/examples/hawkbit-example-app/src/main/resources/logback.xml b/examples/hawkbit-example-app/src/main/resources/logback.xml new file mode 100644 index 000000000..7470bb201 --- /dev/null +++ b/examples/hawkbit-example-app/src/main/resources/logback.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index b6d09758e..4ecf2497b 100644 --- a/pom.xml +++ b/pom.xml @@ -445,39 +445,16 @@ org.springframework.boot spring-boot-starter-actuator ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - ${spring.boot.version} org.springframework.boot spring-boot-starter-web ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-logging - - org.springframework.boot spring-boot-starter ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-logging - - org.springframework.boot From fd6de4496d30a67903e525c116be8149865649d0 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 18 May 2016 09:05:01 +0200 Subject: [PATCH 07/16] Improved simulator download case a bit. Added missing test asserts for target token in DMF. Signed-off-by: Kai Zimmermann --- .../eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java | 6 ++++++ .../hawkbit/amqp/AmqpMessageDispatcherServiceTest.java | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java index e7b81b017..5c6c0a3ea 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java @@ -149,6 +149,8 @@ public class DeviceSimulatorUpdater { eventbus.post(new ProgressUpdate(device)); return; } + // download is 80% of the game after all + device.setProgress(0.8); } final double newProgress = device.getProgress() + 0.2; @@ -272,6 +274,10 @@ public class DeviceSimulatorUpdater { } private static String hideTokenDetails(final String targetToken) { + if (targetToken == null) { + return ""; + } + if (targetToken.isEmpty()) { return ""; } diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index c5cea9e05..9164e655d 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -100,6 +100,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); final Message sendMessage = createArgumentCapture(targetAssignDistributionSetEvent.getTargetAdress()); final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage); + assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN); assertTrue("No softwaremmodule should be contained in the request", downloadAndUpdateRequest.getSoftwareModules().isEmpty()); } @@ -116,6 +117,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage); assertEquals("Expecting a size of 3 software modules in the reuqest", 3, downloadAndUpdateRequest.getSoftwareModules().size()); + assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN); for (final org.eclipse.hawkbit.dmf.json.model.SoftwareModule softwareModule : downloadAndUpdateRequest .getSoftwareModules()) { assertTrue("Artifact list for softwaremodule should be empty", softwareModule.getArtifacts().isEmpty()); @@ -155,6 +157,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage); assertEquals("DownloadAndUpdateRequest event should contains 3 software modules", 3, downloadAndUpdateRequest.getSoftwareModules().size()); + assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN); + for (final org.eclipse.hawkbit.dmf.json.model.SoftwareModule softwareModule : downloadAndUpdateRequest .getSoftwareModules()) { if (!softwareModule.getModuleId().equals(module.getId())) { From 40fa1325bde5308e0fc18f25540408e74263e86c Mon Sep 17 00:00:00 2001 From: venu1278 Date: Wed, 18 May 2016 14:07:52 +0530 Subject: [PATCH 08/16] fix_display_DSNameVersion_actionhistory_table. Signed-off-by: venu1278 --- .../actionhistory/ActionHistoryTable.java | 8 +++---- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 22 +------------------ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java index 834566f7e..be1a96c37 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -296,8 +296,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { * add distribution name to the item which will be displayed in the * table. The name should not exceed certain limit. */ - item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(HawkbitCommonUtil - .getFormattedText(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion())); + item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(actionWithStatusCount.getDsName() + ":" + + actionWithStatusCount.getDsVersion()); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action); /* Default no child */ @@ -442,8 +442,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue(""); childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST) - .setValue(HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":" - + action.getDistributionSet().getVersion())); + .setValue(action.getDistributionSet().getName() + ":" + + action.getDistributionSet().getVersion()); childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME) .setValue(SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt())); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index 0e71567af..a1091cd8a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -431,27 +431,7 @@ public final class HawkbitCommonUtil { return trimAndNullIfEmpty(orgText) == null ? SPUIDefinitions.SPACE : orgText; } - /** - * Format the lengthy text. - * - * @param orgText - * text to be formatted - * @return String formatted text - */ - public static String getFormattedText(final String orgText) { - if (orgText == null) { - return StringUtils.EMPTY; - } - - final int txtLengthAllowed = SPUIDefinitions.NAME_DESCRIPTION_LENGTH; - if (orgText.length() > txtLengthAllowed) { - return new StringBuilder(orgText.substring(0, txtLengthAllowed)).append("...").toString(); - } - - return orgText; - } - - /** + /** * Find extra height required to increase by all the components to utilize * the full height of browser for the responsive UI. * From b8936409fe60edfa3ddda3e0a8b4b3f1cdece1e5 Mon Sep 17 00:00:00 2001 From: venu1278 Date: Wed, 18 May 2016 14:17:29 +0530 Subject: [PATCH 09/16] fix_flashing_whitepage_on_login_application Signed-off-by: venu1278 --- .../resources/VAADIN/themes/hawkbit/hawkbittheme.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss index a344cb5ae..550a0479b 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss @@ -132,4 +132,14 @@ $v-included-components: remove($v-included-components, form); left: 50%; margin-left: -20px; } + .v-generated-body &.v-app , .v-generated-body .v-app { + background-color: rgba(0, 0, 0, 0); + background-image: $app-background-image, linear-gradient(to bottom, $app-background-image-gradient) !important; + background-image: $app-background-image, -webkit-linear-gradient(top, $app-background-image-gradient) !important; + background-image: $app-background-image, -moz-linear-gradient(top, $app-background-image-gradient) !important; + background-position: bottom; + background-repeat: no-repeat; + height:100%; + width:100%; + } } From b8a3dbdf62764b5719ee79b4fe54596af80f5941 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 18 May 2016 11:12:27 +0200 Subject: [PATCH 10/16] Fixed sonar issues. Signed-off-by: Kai Zimmermann --- .../org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java | 2 +- .../eclipse/hawkbit/api/PropertyBasedArtifactUrlHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java index 5c6c0a3ea..34c5f548e 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java @@ -264,7 +264,7 @@ public class DeviceSimulatorUpdater { } } catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { - LOGGER.error("Failed to download {} with {}", url, e.getMessage()); + LOGGER.error("Failed to download" + url, e); return new UpdateStatus(ResponseStatus.ERROR, "Failed to download " + url + ": " + e.getMessage()); } diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandler.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandler.java index 0072f2fbd..d43d660ca 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandler.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandler.java @@ -61,7 +61,7 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler { for (final Entry entry : entrySet) { if (entry.getKey().equals(PORT_PLACEHOLDER)) { urlPattern = urlPattern.replace(":{" + entry.getKey() + "}", - Strings.isNullOrEmpty(entry.getValue()) ? "" : ":" + entry.getValue()); + Strings.isNullOrEmpty(entry.getValue()) ? "" : (":" + entry.getValue())); } else { urlPattern = urlPattern.replace("{" + entry.getKey() + "}", entry.getValue()); } From b58ba745652e4fb435ddf0f5e3cacc2a85c4c8c9 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Wed, 18 May 2016 12:45:09 +0200 Subject: [PATCH 11/16] the column name must be the same as the bean attribute name otherwise NPE Signed-off-by: Michael Hirsch --- .../eclipse/hawkbit/simulator/ui/SimulatorView.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/ui/SimulatorView.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/ui/SimulatorView.java index bd6ecbe8b..4834bece9 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/ui/SimulatorView.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/ui/SimulatorView.java @@ -53,11 +53,13 @@ import com.vaadin.ui.renderers.ProgressBarRenderer; * */ @SpringView(name = "") +// The inheritance comes from Vaadin +@SuppressWarnings("squid:MaximumInheritanceDepth") public class SimulatorView extends VerticalLayout implements View { private static final String NEXT_POLL_COUNTER_SEC_COL = "nextPollCounterSec"; - private static final String RESPONSE_STATUS_COL = "responseStatus"; + private static final String RESPONSE_STATUS_COL = "updateStatus"; private static final String PROTOCOL_COL = "protocol"; @@ -141,10 +143,9 @@ public class SimulatorView extends VerticalLayout implements View { responseComboBox.setItemIcon(ResponseStatus.ERROR, FontAwesome.EXCLAMATION_CIRCLE); responseComboBox.setNullSelectionAllowed(false); responseComboBox.setValue(ResponseStatus.SUCCESSFUL); - responseComboBox.addValueChangeListener(valueChangeEvent -> { - beanContainer.getItemIds().forEach(itemId -> beanContainer.getItem(itemId) - .getItemProperty(RESPONSE_STATUS_COL).setValue(valueChangeEvent.getProperty().getValue())); - }); + responseComboBox.addValueChangeListener( + valueChangeEvent -> beanContainer.getItemIds().forEach(itemId -> beanContainer.getItem(itemId) + .getItemProperty(RESPONSE_STATUS_COL).setValue(valueChangeEvent.getProperty().getValue()))); // add all components addComponent(caption); From f345d5068fd96a9b4d9c38ab0167c0b1b430220e Mon Sep 17 00:00:00 2001 From: venu1278 Date: Thu, 19 May 2016 15:56:19 +0530 Subject: [PATCH 12/16] fix_flashing_whitepage_on_login_application Signed-off-by: venu1278 --- .../main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss index 550a0479b..128c66e55 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss @@ -132,14 +132,12 @@ $v-included-components: remove($v-included-components, form); left: 50%; margin-left: -20px; } - .v-generated-body &.v-app , .v-generated-body .v-app { - background-color: rgba(0, 0, 0, 0); + .v-generated-body &.v-app { background-image: $app-background-image, linear-gradient(to bottom, $app-background-image-gradient) !important; background-image: $app-background-image, -webkit-linear-gradient(top, $app-background-image-gradient) !important; background-image: $app-background-image, -moz-linear-gradient(top, $app-background-image-gradient) !important; background-position: bottom; background-repeat: no-repeat; - height:100%; - width:100%; } + } From 5f8a2bebef54cdf8d88873cbc7bc2d89facfbc33 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 19 May 2016 12:57:32 +0200 Subject: [PATCH 13/16] add license header to logback.xml Signed-off-by: Michael Hirsch --- .../src/main/resources/logback.xml | 10 ++++++++++ .../hawkbit-example-app/src/main/resources/logback.xml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/examples/hawkbit-device-simulator/src/main/resources/logback.xml b/examples/hawkbit-device-simulator/src/main/resources/logback.xml index 0cdbf8ff6..da64e62d1 100644 --- a/examples/hawkbit-device-simulator/src/main/resources/logback.xml +++ b/examples/hawkbit-device-simulator/src/main/resources/logback.xml @@ -1,4 +1,14 @@ + diff --git a/examples/hawkbit-example-app/src/main/resources/logback.xml b/examples/hawkbit-example-app/src/main/resources/logback.xml index 7470bb201..a76e39683 100644 --- a/examples/hawkbit-example-app/src/main/resources/logback.xml +++ b/examples/hawkbit-example-app/src/main/resources/logback.xml @@ -1,4 +1,14 @@ + From 57153b12441e11a4aac35a5a0fb7f84d5d94521d Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 24 May 2016 10:45:07 +0200 Subject: [PATCH 14/16] Remove commons.lang 2.3 Signed-off-by: SirWayne --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index 851fa44d8..98227857c 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,6 @@ 1.1 1.1.1 3.4 - 2.3 20141113 2.0.0 @@ -557,11 +556,6 @@ commons-lang3 ${commons-lang3.version} - - commons-lang - commons-lang - ${commons.lang} - org.springframework.boot spring-boot-starter-test From ee6566081b1e0db6aa7eb1a957f47d17eadfc252 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 24 May 2016 10:48:17 +0200 Subject: [PATCH 15/16] adding or fix javadoc Signed-off-by: Michael Hirsch --- .../hawkbit/feign/core/client/FeignClientConfiguration.java | 4 ++-- .../client/resource/MgmtDownloadArtifactClientResource.java | 3 ++- .../client/resource/MgmtSoftwareModuleTypeClientResource.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/hawkbit-example-core-feign-client/src/main/java/org/eclipse/hawkbit/feign/core/client/FeignClientConfiguration.java b/examples/hawkbit-example-core-feign-client/src/main/java/org/eclipse/hawkbit/feign/core/client/FeignClientConfiguration.java index 2723a251e..1512b7f9e 100644 --- a/examples/hawkbit-example-core-feign-client/src/main/java/org/eclipse/hawkbit/feign/core/client/FeignClientConfiguration.java +++ b/examples/hawkbit-example-core-feign-client/src/main/java/org/eclipse/hawkbit/feign/core/client/FeignClientConfiguration.java @@ -18,8 +18,8 @@ import feign.Contract; import feign.Feign; /** - * - * + * Spring annotated java configuration class which defines necessary beans for + * configure the feign-client. */ @Configuration @ConditionalOnClass(Feign.class) diff --git a/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtDownloadArtifactClientResource.java b/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtDownloadArtifactClientResource.java index f32e448ac..d25a609b2 100644 --- a/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtDownloadArtifactClientResource.java +++ b/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtDownloadArtifactClientResource.java @@ -13,7 +13,8 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.springframework.cloud.netflix.feign.FeignClient; /** - * + * A feign-client interface declaration which allows to build a feign-client + * stub. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) public interface MgmtDownloadArtifactClientResource extends MgmtDownloadArtifactRestApi { diff --git a/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtSoftwareModuleTypeClientResource.java b/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtSoftwareModuleTypeClientResource.java index 766ec215f..1e9462c47 100644 --- a/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtSoftwareModuleTypeClientResource.java +++ b/examples/hawkbit-example-mgmt-feign-client/src/main/java/org/eclipse/hawkbit/mgmt/client/resource/MgmtSoftwareModuleTypeClientResource.java @@ -13,7 +13,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.springframework.cloud.netflix.feign.FeignClient; /** - * Client binding for the oftwareModuleType resource of the management API. + * Client binding for the SoftwareModuleType resource of the management API. */ @FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) public interface MgmtSoftwareModuleTypeClientResource extends MgmtSoftwareModuleTypeRestApi { From dc74ec8889564d31ea7052734d99bad676742ac4 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 24 May 2016 15:08:07 +0200 Subject: [PATCH 16/16] Some rework for the pull request Signed-off-by: SirWayne --- .../hawkbit-example-ddi-feign-client/pom.xml | 1 - .../rest/resource/DdiDeploymentBaseTest.java | 57 ++++++++----------- .../PropertyBasedArtifactUrlHandlerTest.java | 9 +-- .../mgmt/rest/api/MgmtSystemRestApi.java | 2 +- .../mgmt/rest/api/MgmtTargetRestApi.java | 2 +- .../rest/resource/MgmtSystemResource.java | 2 +- 6 files changed, 33 insertions(+), 40 deletions(-) diff --git a/examples/hawkbit-example-ddi-feign-client/pom.xml b/examples/hawkbit-example-ddi-feign-client/pom.xml index 8256b5b30..5388544db 100644 --- a/examples/hawkbit-example-ddi-feign-client/pom.xml +++ b/examples/hawkbit-example-ddi-feign-client/pom.xml @@ -55,7 +55,6 @@ com.netflix.feign feign-core - com.netflix.feign 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 df75bc6b3..eb3ed8844 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 @@ -57,6 +57,9 @@ import ru.yandex.qatools.allure.annotations.Stories; @Stories("Deployment Action Resource") public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoDB { + private static final String HTTP_LOCALHOST = "http://localhost:8080/"; + private static final String HTTPS_LOCALHOST = "https://localhost:8080/"; + @Test() @Description("Ensures that artifacts are not found, when softare module does not exists.") public void artifactsNotFound() throws Exception { @@ -171,24 +174,22 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0].hashes.sha1", equalTo(artifact.getSha1Hash()))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.download.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.md5sum.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.download-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.md5sum-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.MD5SUM"))) @@ -201,23 +202,21 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1].hashes.sha1", equalTo(artifactSignature.getSha1Hash()))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.download.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.md5sum.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.download-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.md5sum-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==bApp)][0].version", @@ -316,12 +315,12 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0].hashes.sha1", equalTo(artifact.getSha1Hash()))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.download.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.md5sum.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.MD5SUM"))) @@ -334,23 +333,21 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1].hashes.sha1", equalTo(artifactSignature.getSha1Hash()))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.download.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.md5sum.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.download-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.md5sum-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==bApp)][0].version", @@ -446,23 +443,21 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD equalTo(artifact.getSha1Hash()))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.download.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.md5sum.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.download-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[0]._links.md5sum-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1].size", equalTo(5 * 1024))) @@ -474,24 +469,22 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1].hashes.sha1", equalTo(artifactSignature.getSha1Hash()))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.download.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.md5sum.href", - equalTo("https://localhost:8080/" + tenantAware.getCurrentTenant() + equalTo(HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature.MD5SUM"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.download-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature"))) .andExpect(jsonPath("$deployment.chunks[?(@.part==os)][0].artifacts[1]._links.md5sum-http.href", - equalTo("http://localhost:8080/" + tenantAware.getCurrentTenant() - + "/controller/v1/4712/softwaremodules/" + equalTo(HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/4712/softwaremodules/" + findDistributionSetByAction.findFirstModuleByType(osType).getId() + "/artifacts/test1.signature.MD5SUM"))) diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java index 27021d265..f9a2ea316 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java @@ -39,6 +39,8 @@ import ru.yandex.qatools.allure.annotations.Stories; AmqpTestConfiguration.class }) public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTestWithMongoDB { + private static final String HTTPS_LOCALHOST = "https://localhost:8080/"; + private static final String HTTP_LOCALHOST = "http://localhost:8080/"; @Autowired private ArtifactUrlHandler urlHandlerProperties; @Autowired @@ -69,9 +71,8 @@ public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest final String url = urlHandlerProperties.getUrl(controllerId, softwareModuleId, fileName, sha1Hash, UrlProtocol.HTTP); assertEquals("http is build incorrect", - "http://localhost:8080/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId - + "/softwaremodules/" + localArtifact.getSoftwareModule().getId() + "/artifacts/" - + localArtifact.getFilename(), + HTTP_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId + "/softwaremodules/" + + localArtifact.getSoftwareModule().getId() + "/artifacts/" + localArtifact.getFilename(), url); } @@ -81,7 +82,7 @@ public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest final String url = urlHandlerProperties.getUrl(controllerId, softwareModuleId, fileName, sha1Hash, UrlProtocol.HTTPS); assertEquals("https is build incorrect", - "https://localhost:8080/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId + HTTPS_LOCALHOST + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId + "/softwaremodules/" + localArtifact.getSoftwareModule().getId() + "/artifacts/" + localArtifact.getFilename(), url); diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java index 92c732c96..d120759b2 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java @@ -85,4 +85,4 @@ public interface MgmtSystemRestApi { @PathVariable("keyName") final String keyName, @RequestBody final MgmtSystemTenantConfigurationValueRequest configurationValueRest); -} \ No newline at end of file +} diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java index d44d473b1..bf4e169a0 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java @@ -260,4 +260,4 @@ public interface MgmtTargetRestApi { MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getInstalledDistributionSet(@PathVariable("targetId") final String targetId); -} \ No newline at end of file +} diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java index 5aac17318..24a3f275e 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java @@ -122,4 +122,4 @@ public class MgmtSystemResource implements MgmtSystemRestApi { return new ResponseEntity<>(MgmtSystemMapper.toResponse(keyName, updatedValue), HttpStatus.OK); } -} \ No newline at end of file +}