Improvements repository validation constraints (#626)

* Add html tag Validator on strings. Add string trim.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Revert unintended changes. Sonar issues.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Remove weired comment.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Raise EclipseLink due to validation problem.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix permission.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Colour field test.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix sonar issues.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2018-02-12 14:56:36 +01:00
committed by GitHub
parent 1a6ab123e3
commit d3cb9bb24d
89 changed files with 812 additions and 495 deletions

View File

@@ -22,10 +22,10 @@ import org.eclipse.hawkbit.security.ControllerPreAuthenticatedAnonymousFilter;
import org.eclipse.hawkbit.security.ControllerPreAuthenticatedGatewaySecurityTokenFilter;
import org.eclipse.hawkbit.security.ControllerPreAuthenticatedSecurityHeaderFilter;
import org.eclipse.hawkbit.security.DdiSecurityProperties;
import org.eclipse.hawkbit.security.DmfTenantSecurityToken;
import org.eclipse.hawkbit.security.PreAuthTokenSourceTrustAuthenticationProvider;
import org.eclipse.hawkbit.security.PreAuthenticationFilter;
import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.security.DmfTenantSecurityToken;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -40,7 +40,7 @@ public class DelayedRequeueExceptionStrategy extends ConditionalRejectingErrorHa
* @param delay
* in {@link TimeUnit#MILLISECONDS} before requeue.
*/
public DelayedRequeueExceptionStrategy(final long delay) {
DelayedRequeueExceptionStrategy(final long delay) {
this.delay = delay;
}
@@ -62,23 +62,23 @@ public class DelayedRequeueExceptionStrategy extends ConditionalRejectingErrorHa
return false;
}
private boolean invalidMessage(final Throwable cause) {
private static boolean invalidMessage(final Throwable cause) {
return doesNotExist(cause) || quotaHit(cause) || invalidContent(cause) || invalidState(cause);
}
private boolean invalidState(final Throwable cause) {
private static boolean invalidState(final Throwable cause) {
return cause instanceof CancelActionNotAllowedException;
}
private boolean quotaHit(final Throwable cause) {
private static boolean quotaHit(final Throwable cause) {
return cause instanceof QuotaExceededException;
}
private boolean doesNotExist(final Throwable cause) {
private static boolean doesNotExist(final Throwable cause) {
return cause instanceof TenantNotExistException || cause instanceof EntityNotFoundException;
}
private boolean invalidContent(final Throwable cause) {
private static boolean invalidContent(final Throwable cause) {
return cause instanceof ConstraintViolationException || cause instanceof InvalidTargetAddressException
|| cause instanceof MessageConversionException || cause instanceof MessageHandlingException;
}

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.amqp;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -277,7 +277,7 @@ public class AmqpMessageHandlerServiceTest {
@Test
@Description("Tests the update of an action of a target without a exist action id")
public void updateActionStatusWithoutActionId() {
when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty());
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty());
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.DOWNLOAD);
@@ -297,7 +297,7 @@ public class AmqpMessageHandlerServiceTest {
public void updateActionStatusWithoutExistActionId() {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty());
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty());
final DmfActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(DmfActionStatus.DOWNLOAD);
final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(actionUpdateStatus,
@@ -342,7 +342,7 @@ public class AmqpMessageHandlerServiceTest {
final Artifact localArtifactMock = mock(Artifact.class);
when(artifactManagementMock.findFirstBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock));
when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyObject(), anyObject()))
when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyString(), anyLong()))
.thenThrow(EntityNotFoundException.class);
// test
@@ -396,7 +396,7 @@ public class AmqpMessageHandlerServiceTest {
// Mock
final Action action = createActionWithTarget(22L, Status.FINISHED);
when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.of(action));
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action));
when(controllerManagementMock.addUpdateActionStatus(any())).thenReturn(action);
final ActionStatusBuilder builder = mock(ActionStatusBuilder.class);
final ActionStatusCreate create = mock(ActionStatusCreate.class);

View File

@@ -59,7 +59,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq
@Before
public void testSetup() {
enableTargetTokenAuthentification();
enableTargetTokenAuthentication();
}
@Test
@@ -393,7 +393,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq
TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, false);
}
private void enableTargetTokenAuthentification() {
private void enableTargetTokenAuthentication() {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED,
false);
tenantConfigurationManagement.addOrUpdateConfiguration(