Fix new line after @Test (#2486)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -27,7 +27,8 @@ class ArtifactEncryptionServiceTest {
|
||||
/**
|
||||
* Verify that no artifact encryption support is given
|
||||
*/
|
||||
@Test void verifyNoArtifactEncryptionSupport() {
|
||||
@Test
|
||||
void verifyNoArtifactEncryptionSupport() {
|
||||
final ArtifactEncryptionService artifactEncryptionService = ArtifactEncryptionService.getInstance();
|
||||
|
||||
assertThat(artifactEncryptionService.isEncryptionSupported()).isFalse();
|
||||
|
||||
@@ -28,7 +28,8 @@ class MaintenanceScheduleHelperTest {
|
||||
/**
|
||||
* Verifies that the Cron object is returned for valid cron expression
|
||||
*/
|
||||
@Test void getCronFromExpressionValid() {
|
||||
@Test
|
||||
void getCronFromExpressionValid() {
|
||||
final String validCron = "0 0 0 ? * 6"; // at 00:00 every Saturday
|
||||
assertThat(MaintenanceScheduleHelper.getCronFromExpression(validCron)).isNotNull().isInstanceOf(Cron.class);
|
||||
}
|
||||
@@ -36,7 +37,8 @@ class MaintenanceScheduleHelperTest {
|
||||
/**
|
||||
* Verifies that the Duration object is returned for valid duration format (hh:mm or hh:mm:ss)
|
||||
*/
|
||||
@Test void convertToISODurationValid() {
|
||||
@Test
|
||||
void convertToISODurationValid() {
|
||||
final String duration = "00:10";
|
||||
assertThat(MaintenanceScheduleHelper.convertToISODuration(duration)).isNotNull().isInstanceOf(Duration.class);
|
||||
}
|
||||
@@ -44,7 +46,8 @@ class MaintenanceScheduleHelperTest {
|
||||
/**
|
||||
* Verifies that the InvalidMaintenanceScheduleException is thrown for invalid duration format
|
||||
*/
|
||||
@Test void validateDurationInvalid() {
|
||||
@Test
|
||||
void validateDurationInvalid() {
|
||||
final String duration = "10";
|
||||
assertThatThrownBy(() -> MaintenanceScheduleHelper.validateDuration(duration))
|
||||
.isInstanceOf(InvalidMaintenanceScheduleException.class).hasMessage("Provided duration is not valid")
|
||||
@@ -54,7 +57,8 @@ class MaintenanceScheduleHelperTest {
|
||||
/**
|
||||
* Verifies that the InvalidMaintenanceScheduleException is thrown for invalid cron expression
|
||||
*/
|
||||
@Test void validateCronScheduleInvalid() {
|
||||
@Test
|
||||
void validateCronScheduleInvalid() {
|
||||
final String invalidCron = "0 0 0 * * 6";
|
||||
assertThatThrownBy(() -> MaintenanceScheduleHelper.validateCronSchedule(invalidCron))
|
||||
.isInstanceOf(InvalidMaintenanceScheduleException.class)
|
||||
@@ -64,7 +68,8 @@ class MaintenanceScheduleHelperTest {
|
||||
/**
|
||||
* Verifies that there is a maintenance window available for correct schedule, duration and timezone
|
||||
*/
|
||||
@Test void getNextMaintenanceWindowValid() {
|
||||
@Test
|
||||
void getNextMaintenanceWindowValid() {
|
||||
final ZonedDateTime currentTime = ZonedDateTime.now();
|
||||
final String cronSchedule = String.format("0 %d %d %d %d ? %d", currentTime.getMinute(), currentTime.getHour(),
|
||||
currentTime.getDayOfMonth(), currentTime.getMonthValue(), currentTime.getYear());
|
||||
@@ -76,7 +81,8 @@ class MaintenanceScheduleHelperTest {
|
||||
/**
|
||||
* Verifies the maintenance schedule when only one required field is present
|
||||
*/
|
||||
@Test void validateMaintenanceScheduleAtLeastOneNotEmpty() {
|
||||
@Test
|
||||
void validateMaintenanceScheduleAtLeastOneNotEmpty() {
|
||||
final String duration = "00:10";
|
||||
assertThatThrownBy(() -> MaintenanceScheduleHelper.validateMaintenanceSchedule(null, duration, null))
|
||||
.isInstanceOf(InvalidMaintenanceScheduleException.class)
|
||||
@@ -86,7 +92,8 @@ class MaintenanceScheduleHelperTest {
|
||||
/**
|
||||
* Verifies that there is no valid maintenance window available, scheduled before current time
|
||||
*/
|
||||
@Test void validateMaintenanceScheduleBeforeCurrentTime() {
|
||||
@Test
|
||||
void validateMaintenanceScheduleBeforeCurrentTime() {
|
||||
ZonedDateTime currentTime = ZonedDateTime.now();
|
||||
currentTime = currentTime.plusMinutes(-30);
|
||||
final String cronSchedule = String.format("0 %d %d %d %d ? %d", currentTime.getMinute(), currentTime.getHour(),
|
||||
|
||||
@@ -27,7 +27,8 @@ class RegexCharTest {
|
||||
/**
|
||||
* Verifies every RegexChar can be used to exclusively find the desired characters in a String.
|
||||
*/
|
||||
@Test void allRegexCharsOnlyFindExpectedChars() {
|
||||
@Test
|
||||
void allRegexCharsOnlyFindExpectedChars() {
|
||||
for (final RegexChar character : RegexChar.values()) {
|
||||
switch (character) {
|
||||
case DIGITS:
|
||||
@@ -52,7 +53,8 @@ class RegexCharTest {
|
||||
/**
|
||||
* Verifies that combinations of RegexChars can be used to find the desired characters in a String.
|
||||
*/
|
||||
@Test void combinedRegexCharsFindExpectedChars() {
|
||||
@Test
|
||||
void combinedRegexCharsFindExpectedChars() {
|
||||
final RegexCharacterCollection greaterAndLessThan = new RegexCharacterCollection(RegexChar.GREATER_THAN,
|
||||
RegexChar.LESS_THAN);
|
||||
final RegexCharacterCollection equalsAndQuestionMark = new RegexCharacterCollection(RegexChar.EQUALS_SYMBOL,
|
||||
|
||||
@@ -35,7 +35,8 @@ class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
|
||||
/**
|
||||
* Verifies that repository methods are @PreAuthorize annotated
|
||||
*/
|
||||
@Test void repositoryManagementMethodsArePreAuthorizedAnnotated() {
|
||||
@Test
|
||||
void repositoryManagementMethodsArePreAuthorizedAnnotated() {
|
||||
final String packageName = getClass().getPackage().getName();
|
||||
try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) {
|
||||
final List<? extends Class<?>> matchingClasses = scanResult.getAllClasses()
|
||||
|
||||
@@ -71,7 +71,8 @@ class TotalTargetCountStatusTest {
|
||||
/**
|
||||
* DownloadOnly actions should be displayed as FINISHED when they have ActionStatus.DOWNLOADED
|
||||
*/
|
||||
@Test void shouldCorrectlyMapActionStatusesInDownloadOnlyCase() {
|
||||
@Test
|
||||
void shouldCorrectlyMapActionStatusesInDownloadOnlyCase() {
|
||||
TotalTargetCountStatus status = new TotalTargetCountStatus(targetCountActionStatuses, 55L,
|
||||
Action.ActionType.DOWNLOAD_ONLY);
|
||||
assertThat(status.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.SCHEDULED)).isEqualTo(1L);
|
||||
|
||||
@@ -47,7 +47,8 @@ class BusProtoStuffMessageConverterTest {
|
||||
/**
|
||||
* Verifies that the TargetCreatedEvent can be successfully serialized and deserialized
|
||||
*/
|
||||
@Test void successfullySerializeAndDeserializeEvent() {
|
||||
@Test
|
||||
void successfullySerializeAndDeserializeEvent() {
|
||||
final TargetCreatedEvent targetCreatedEvent = new TargetCreatedEvent(targetMock, "1");
|
||||
// serialize
|
||||
final Object serializedEvent = underTest.convertToInternal(targetCreatedEvent,
|
||||
@@ -65,7 +66,8 @@ class BusProtoStuffMessageConverterTest {
|
||||
/**
|
||||
* Verifies that a MessageConversationException is thrown on missing event-type information encoding
|
||||
*/
|
||||
@Test void missingEventTypeMappingThrowsMessageConversationException() {
|
||||
@Test
|
||||
void missingEventTypeMappingThrowsMessageConversationException() {
|
||||
final DummyRemoteEntityEvent dummyEvent = new DummyRemoteEntityEvent(targetMock, "applicationId");
|
||||
final MessageHeaders messageHeaders = new MessageHeaders(new HashMap<>());
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ class HawkBitEclipseLinkJpaDialectTest {
|
||||
/**
|
||||
* Use Case: PersistenceException that can be mapped by EclipseLinkJpaDialect into corresponding DataAccessException.
|
||||
*/
|
||||
@Test void jpaOptimisticLockExceptionIsConcurrencyFailureException() {
|
||||
@Test
|
||||
void jpaOptimisticLockExceptionIsConcurrencyFailureException() {
|
||||
assertThat(hawkBitEclipseLinkJpaDialectUnderTest.translateExceptionIfPossible(mock(OptimisticLockException.class)))
|
||||
.isInstanceOf(ConcurrencyFailureException.class);
|
||||
}
|
||||
|
||||
@@ -37,21 +37,24 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
|
||||
/**
|
||||
* Verifies that the ds id is correct reloaded
|
||||
*/
|
||||
@Test void testDistributionSetDeletedEvent() {
|
||||
@Test
|
||||
void testDistributionSetDeletedEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetDeletedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the ds tag id is correct reloaded
|
||||
*/
|
||||
@Test void testDistributionSetTagDeletedEvent() {
|
||||
@Test
|
||||
void testDistributionSetTagDeletedEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetTagDeletedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the target id is correct reloaded
|
||||
*/
|
||||
@Test void testTargetDeletedEvent() {
|
||||
@Test
|
||||
void testTargetDeletedEvent() {
|
||||
final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, CONTROLLER_ID, ADDRESS,
|
||||
ENTITY_CLASS, NODE);
|
||||
assertEntity(deletedEvent);
|
||||
@@ -60,21 +63,24 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
|
||||
/**
|
||||
* Verifies that the target tag id is correct reloaded
|
||||
*/
|
||||
@Test void testTargetTagDeletedEvent() {
|
||||
@Test
|
||||
void testTargetTagDeletedEvent() {
|
||||
assertAndCreateRemoteEvent(TargetTagDeletedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the software module id is correct reloaded
|
||||
*/
|
||||
@Test void testSoftwareModuleDeletedEvent() {
|
||||
@Test
|
||||
void testSoftwareModuleDeletedEvent() {
|
||||
assertAndCreateRemoteEvent(SoftwareModuleDeletedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the rollout id is correct reloaded
|
||||
*/
|
||||
@Test void testRolloutDeletedEvent() {
|
||||
@Test
|
||||
void testRolloutDeletedEvent() {
|
||||
assertAndCreateRemoteEvent(RolloutDeletedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
/**
|
||||
* Verifies that a testMultiActionAssignEvent can be properly serialized and deserialized
|
||||
*/
|
||||
@Test void testMultiActionAssignEvent() {
|
||||
@Test
|
||||
void testMultiActionAssignEvent() {
|
||||
final List<String> controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng");
|
||||
final List<Action> actions = controllerIds.stream().map(this::createAction).toList();
|
||||
|
||||
@@ -52,7 +53,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
/**
|
||||
* Verifies that a MultiActionCancelEvent can be properly serialized and deserialized
|
||||
*/
|
||||
@Test void testMultiActionCancelEvent() {
|
||||
@Test
|
||||
void testMultiActionCancelEvent() {
|
||||
final List<String> controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng");
|
||||
final List<Action> actions = controllerIds.stream().map(this::createAction).toList();
|
||||
|
||||
@@ -71,7 +73,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
/**
|
||||
* Verifies that a DownloadProgressEvent can be properly serialized and deserialized
|
||||
*/
|
||||
@Test void reloadDownloadProgressByRemoteEvent() {
|
||||
@Test
|
||||
void reloadDownloadProgressByRemoteEvent() {
|
||||
final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent(TENANT_DEFAULT, 1L, 3L,
|
||||
APPLICATION_ID_DEFAULT);
|
||||
|
||||
@@ -85,7 +88,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
/**
|
||||
* Verifies that a TargetAssignDistributionSetEvent can be properly serialized and deserialized
|
||||
*/
|
||||
@Test void testTargetAssignDistributionSetEvent() {
|
||||
@Test
|
||||
void testTargetAssignDistributionSetEvent() {
|
||||
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
@@ -113,7 +117,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
/**
|
||||
* Verifies that a TargetAssignDistributionSetEvent can be properly serialized and deserialized
|
||||
*/
|
||||
@Test void testCancelTargetAssignmentEvent() {
|
||||
@Test
|
||||
void testCancelTargetAssignmentEvent() {
|
||||
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
|
||||
@@ -30,14 +30,16 @@ class ActionEventTest extends AbstractRemoteEntityEventTest<Action> {
|
||||
/**
|
||||
* Verifies that the action entity reloading by remote created works
|
||||
*/
|
||||
@Test void testActionCreatedEvent() {
|
||||
@Test
|
||||
void testActionCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(ActionCreatedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the action entity reloading by remote updated works
|
||||
*/
|
||||
@Test void testActionUpdatedEvent() {
|
||||
@Test
|
||||
void testActionUpdatedEvent() {
|
||||
assertAndCreateRemoteEvent(ActionUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTest<Dist
|
||||
/**
|
||||
* Verifies that the distribution set entity reloading by remote created event works
|
||||
*/
|
||||
@Test void testDistributionSetCreatedEvent() {
|
||||
@Test
|
||||
void testDistributionSetCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetCreatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,16 @@ class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest<Distribu
|
||||
/**
|
||||
* Verifies that the distribution set tag entity reloading by remote created event works
|
||||
*/
|
||||
@Test void testDistributionSetTagCreatedEvent() {
|
||||
@Test
|
||||
void testDistributionSetTagCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetTagCreatedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the distribution set tag entity reloading by remote updated event works
|
||||
*/
|
||||
@Test void testDistributionSetTagUpdateEvent() {
|
||||
@Test
|
||||
void testDistributionSetTagUpdateEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetTagUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTest<Dist
|
||||
/**
|
||||
* Verifies that the distribution set entity reloading by remote updated event works
|
||||
*/
|
||||
@Test void testDistributionSetUpdateEvent() {
|
||||
@Test
|
||||
void testDistributionSetUpdateEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ class RolloutEventTest extends AbstractRemoteEntityEventTest<Rollout> {
|
||||
/**
|
||||
* Verifies that the rollout entity reloading by remote updated event works
|
||||
*/
|
||||
@Test void testRolloutUpdatedEvent() {
|
||||
@Test
|
||||
void testRolloutUpdatedEvent() {
|
||||
assertAndCreateRemoteEvent(RolloutUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<RolloutGroup>
|
||||
/**
|
||||
* Verifies that the rollout group entity reloading by remote created event works
|
||||
*/
|
||||
@Test void testRolloutGroupCreatedEvent() {
|
||||
@Test
|
||||
void testRolloutGroupCreatedEvent() {
|
||||
final RolloutGroupCreatedEvent createdEvent = (RolloutGroupCreatedEvent) assertAndCreateRemoteEvent(
|
||||
RolloutGroupCreatedEvent.class);
|
||||
assertThat(createdEvent.getRolloutId()).isNotNull();
|
||||
@@ -42,7 +43,8 @@ class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<RolloutGroup>
|
||||
/**
|
||||
* Verifies that the rollout group entity reloading by remote updated event works
|
||||
*/
|
||||
@Test void testRolloutGroupUpdatedEvent() {
|
||||
@Test
|
||||
void testRolloutGroupUpdatedEvent() {
|
||||
assertAndCreateRemoteEvent(RolloutGroupUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,16 @@ class SoftwareModuleEventTest extends AbstractRemoteEntityEventTest<SoftwareModu
|
||||
/**
|
||||
* Verifies that the software module entity reloading by remote created event works
|
||||
*/
|
||||
@Test void testTargetCreatedEvent() {
|
||||
@Test
|
||||
void testTargetCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(SoftwareModuleCreatedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the software module entity reloading by remote updated event works
|
||||
*/
|
||||
@Test void testTargetUpdatedEvent() {
|
||||
@Test
|
||||
void testTargetUpdatedEvent() {
|
||||
assertAndCreateRemoteEvent(SoftwareModuleUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,16 @@ class TargetEventTest extends AbstractRemoteEntityEventTest<Target> {
|
||||
/**
|
||||
* Verifies that the target entity reloading by remote created event works
|
||||
*/
|
||||
@Test void testTargetCreatedEvent() {
|
||||
@Test
|
||||
void testTargetCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(TargetCreatedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the target entity reloading by remote updated event works
|
||||
*/
|
||||
@Test void testTargetUpdatedEvent() {
|
||||
@Test
|
||||
void testTargetUpdatedEvent() {
|
||||
assertAndCreateRemoteEvent(TargetUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,16 @@ class TargetTagEventTest extends AbstractRemoteEntityEventTest<TargetTag> {
|
||||
/**
|
||||
* Verifies that the target tag entity reloading by remote created event works
|
||||
*/
|
||||
@Test void testTargetTagCreatedEvent() {
|
||||
@Test
|
||||
void testTargetTagCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(TargetTagCreatedEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the target tag entity reloading by remote updated event works
|
||||
*/
|
||||
@Test void testTargetTagUpdateEventt() {
|
||||
@Test
|
||||
void testTargetTagUpdateEventt() {
|
||||
assertAndCreateRemoteEvent(TargetTagUpdatedEvent.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,28 +36,32 @@ public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createCollectionPermissionCheck() {
|
||||
@Test
|
||||
void createCollectionPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().create(List.of(getCreateObject())), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createPermissionCheck() {
|
||||
@Test
|
||||
void createPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().create(getCreateObject()), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updatePermissionCheck() {
|
||||
@Test
|
||||
void updatePermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().update(getUpdateObject()), List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deletePermissionCheck() {
|
||||
@Test
|
||||
void deletePermissionCheck() {
|
||||
assertPermissions(() -> {
|
||||
getRepositoryManagement().delete(1L);
|
||||
return null;
|
||||
@@ -67,7 +71,8 @@ public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test public void countPermissionCheck() {
|
||||
@Test
|
||||
void countPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().count(), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -75,7 +80,8 @@ public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test public void deleteCollectionRepositoryManagement() {
|
||||
@Test
|
||||
void deleteCollectionRepositoryManagement() {
|
||||
assertPermissions(() -> {
|
||||
getRepositoryManagement().delete(List.of(1L));
|
||||
return null;
|
||||
@@ -85,35 +91,40 @@ public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test public void getPermissionCheck() {
|
||||
@Test
|
||||
void getPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().get(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test public void getCollectionPermissionCheck() {
|
||||
@Test
|
||||
void getCollectionPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().get(List.of(1L)), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test public void existsCollectionPermissionCheck() {
|
||||
@Test
|
||||
void existsCollectionPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().exists(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test public void findAllPermissionCheck() {
|
||||
@Test
|
||||
void findAllPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().findAll(Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test public void findByRsqlPermissionCheck() {
|
||||
@Test
|
||||
void findByRsqlPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ class ConcurrentDistributionSetInvalidationTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify that a large rollout causes a timeout when trying to invalidate a distribution set
|
||||
*/
|
||||
@Test void verifyInvalidateDistributionSetWithLargeRolloutThrowsException() {
|
||||
@Test
|
||||
void verifyInvalidateDistributionSetWithLargeRolloutThrowsException() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final Rollout rollout = createRollout(distributionSet);
|
||||
final String tenant = tenantAware.getCurrentTenant();
|
||||
|
||||
@@ -53,7 +53,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies acm context is persisted when creating Rollout
|
||||
*/
|
||||
@Test void verifyAcmContextIsPersistedInCreatedRollout() {
|
||||
@Test
|
||||
void verifyAcmContextIsPersistedInCreatedRollout() {
|
||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
assertThat(securityContext).isNotNull();
|
||||
|
||||
@@ -66,7 +67,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies acm context is reused when handling a rollout
|
||||
*/
|
||||
@Test void verifyContextIsReusedWhenHandlingRollout() {
|
||||
@Test
|
||||
void verifyContextIsReusedWhenHandlingRollout() {
|
||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
assertThat(securityContext).isNotNull();
|
||||
|
||||
@@ -78,7 +80,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies acm context is persisted when activating auto assignment
|
||||
*/
|
||||
@Test void verifyContextIsPersistedInActiveAutoAssignment() {
|
||||
@Test
|
||||
void verifyContextIsPersistedInActiveAutoAssignment() {
|
||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
assertThat(securityContext).isNotNull();
|
||||
|
||||
@@ -91,7 +94,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies acm context is used when performing auto assign check on all target
|
||||
*/
|
||||
@Test void verifyContextIsReusedWhenCheckingForAutoAssignmentAllTargets() {
|
||||
@Test
|
||||
void verifyContextIsReusedWhenCheckingForAutoAssignmentAllTargets() {
|
||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
assertThat(securityContext).isNotNull();
|
||||
|
||||
@@ -103,7 +107,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies acm context is used when performing auto assign check on single target
|
||||
*/
|
||||
@Test void verifyContextIsReusedWhenCheckingForAutoAssignmentSingleTarget() {
|
||||
@Test
|
||||
void verifyContextIsReusedWhenCheckingForAutoAssignmentSingleTarget() {
|
||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
assertThat(securityContext).isNotNull();
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies read access rules for distribution sets
|
||||
*/
|
||||
@Test void verifyDistributionSetReadOperations() {
|
||||
@Test
|
||||
void verifyDistributionSetReadOperations() {
|
||||
permitAllOperations(AccessController.Operation.READ);
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
permitAllOperations(AccessController.Operation.UPDATE);
|
||||
@@ -119,7 +120,8 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies read access rules for distribution sets
|
||||
*/
|
||||
@Test void verifyDistributionSetUpdates() {
|
||||
@Test
|
||||
void verifyDistributionSetUpdates() {
|
||||
// permit all operations first to prepare test setup
|
||||
permitAllOperations(AccessController.Operation.READ);
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
|
||||
@@ -51,7 +51,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies read access rules for targets
|
||||
*/
|
||||
@Test void verifyTargetReadOperations() {
|
||||
@Test
|
||||
void verifyTargetReadOperations() {
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
|
||||
final Target permittedTarget = targetManagement
|
||||
@@ -206,7 +207,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies rules for target assignment
|
||||
*/
|
||||
@Test void verifyTargetAssignment() {
|
||||
@Test
|
||||
void verifyTargetAssignment() {
|
||||
permitAllOperations(AccessController.Operation.READ);
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
permitAllOperations(AccessController.Operation.UPDATE);
|
||||
@@ -253,7 +255,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies rules for target assignment
|
||||
*/
|
||||
@Test void verifyTargetAssignmentOnNonUpdatableTarget() {
|
||||
@Test
|
||||
void verifyTargetAssignmentOnNonUpdatableTarget() {
|
||||
permitAllOperations(AccessController.Operation.READ);
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
permitAllOperations(AccessController.Operation.UPDATE);
|
||||
@@ -294,7 +297,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies only manageable targets are part of the rollout
|
||||
*/
|
||||
@Test void verifyRolloutTargetScope() {
|
||||
@Test
|
||||
void verifyRolloutTargetScope() {
|
||||
permitAllOperations(AccessController.Operation.READ);
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
permitAllOperations(AccessController.Operation.UPDATE);
|
||||
@@ -336,7 +340,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies only manageable targets are part of an auto assignment.
|
||||
*/
|
||||
@Test void verifyAutoAssignmentTargetScope() {
|
||||
@Test
|
||||
void verifyAutoAssignmentTargetScope() {
|
||||
permitAllOperations(AccessController.Operation.READ);
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
permitAllOperations(AccessController.Operation.UPDATE);
|
||||
|
||||
@@ -37,7 +37,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies read access rules for target types
|
||||
*/
|
||||
@Test void verifyTargetTypeReadOperations() {
|
||||
@Test
|
||||
void verifyTargetTypeReadOperations() {
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
final TargetType permittedTargetType = targetTypeManagement.create(entityFactory.targetType().create().name("type1"));
|
||||
final TargetType hiddenTargetType = targetTypeManagement.create(entityFactory.targetType().create().name("type2"));
|
||||
@@ -99,7 +100,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies delete access rules for target types
|
||||
*/
|
||||
@Test void verifyTargetTypeDeleteOperations() {
|
||||
@Test
|
||||
void verifyTargetTypeDeleteOperations() {
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
final TargetType manageableTargetType = targetTypeManagement.create(entityFactory.targetType().create().name("type1"));
|
||||
|
||||
@@ -123,7 +125,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies update operation for target types
|
||||
*/
|
||||
@Test void verifyTargetTypeUpdateOperations() {
|
||||
@Test
|
||||
void verifyTargetTypeUpdateOperations() {
|
||||
permitAllOperations(AccessController.Operation.CREATE);
|
||||
final TargetType manageableTargetType = targetTypeManagement
|
||||
.create(entityFactory.targetType().create().name("type1"));
|
||||
@@ -151,7 +154,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest {
|
||||
/**
|
||||
* Verifies create operation blocked by controller
|
||||
*/
|
||||
@Test void verifyTargetTypeCreationBlockedByAccessController() {
|
||||
@Test
|
||||
void verifyTargetTypeCreationBlockedByAccessController() {
|
||||
defineAccess(AccessController.Operation.CREATE); // allows for none
|
||||
// verify targetTypeManagement#create for any type
|
||||
final TargetTypeCreate targetTypeCreate = entityFactory.targetType().create().name("type1");
|
||||
|
||||
@@ -62,7 +62,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a running action is auto canceled by a AutoAssignment which assigns another distribution-set.
|
||||
*/
|
||||
@Test void autoAssignDistributionSetAndAutoCloseOldActions() {
|
||||
@Test
|
||||
void autoAssignDistributionSetAndAutoCloseOldActions() {
|
||||
|
||||
tenantConfigurationManagement
|
||||
.addOrUpdateConfiguration(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, true);
|
||||
@@ -107,7 +108,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test auto assignment of a DS to filtered targets
|
||||
*/
|
||||
@Test void checkAutoAssign() {
|
||||
@Test
|
||||
void checkAutoAssign() {
|
||||
// will be auto assigned
|
||||
final DistributionSet setA = testdataFactory.createDistributionSet("dsA");
|
||||
final DistributionSet setB = testdataFactory.createDistributionSet("dsB");
|
||||
@@ -160,7 +162,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test auto assignment of a DS for a specific device
|
||||
*/
|
||||
@Test void checkAutoAssignmentForDevice() {
|
||||
@Test
|
||||
void checkAutoAssignmentForDevice() {
|
||||
|
||||
final DistributionSet toAssignDs = testdataFactory.createDistributionSet();
|
||||
|
||||
@@ -244,7 +247,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test auto assignment of an incomplete DS to filtered targets, that causes failures
|
||||
*/
|
||||
@Test void checkAutoAssignWithFailures() {
|
||||
@Test
|
||||
void checkAutoAssignWithFailures() {
|
||||
|
||||
// incomplete distribution set that will be assigned
|
||||
final DistributionSet setF = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
@@ -294,7 +298,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test auto assignment of a distribution set with FORCED, SOFT and DOWNLOAD_ONLY action types
|
||||
*/
|
||||
@Test void checkAutoAssignWithDifferentActionTypes() {
|
||||
@Test
|
||||
void checkAutoAssignWithDifferentActionTypes() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final String targetDsAIdPref = "A";
|
||||
final String targetDsBIdPref = "B";
|
||||
@@ -324,7 +329,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* An auto assignment target filter with weight creates actions with weights
|
||||
*/
|
||||
@Test void actionsWithWeightAreCreated() {
|
||||
@Test
|
||||
void actionsWithWeightAreCreated() {
|
||||
final int amountOfTargets = 5;
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
final int weight = 32;
|
||||
@@ -344,7 +350,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* An auto assignment target filter without weight still works after multi assignment is enabled
|
||||
*/
|
||||
@Test void filterWithoutWeightWorksInMultiAssignmentMode() {
|
||||
@Test
|
||||
void filterWithoutWeightWorksInMultiAssignmentMode() {
|
||||
final int amountOfTargets = 5;
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
targetFilterQueryManagement.create(
|
||||
@@ -363,7 +370,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies an auto assignment only creates actions for compatible targets
|
||||
*/
|
||||
@Test void checkAutoAssignmentWithIncompatibleTargets() {
|
||||
@Test
|
||||
void checkAutoAssignmentWithIncompatibleTargets() {
|
||||
final int TARGET_COUNT = 5;
|
||||
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet();
|
||||
|
||||
@@ -68,7 +68,8 @@ class AutoAssignCheckerTest {
|
||||
/**
|
||||
* Single device check triggers update for matching auto assignment filter.
|
||||
*/
|
||||
@Test void checkForDevice() {
|
||||
@Test
|
||||
void checkForDevice() {
|
||||
mockRunningAsNonSystem();
|
||||
final String target = getRandomString();
|
||||
final long ds = getRandomLong();
|
||||
|
||||
@@ -40,7 +40,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that running actions are not cleaned up.
|
||||
*/
|
||||
@Test void runningActionsAreNotCleanedUp() {
|
||||
@Test
|
||||
void runningActionsAreNotCleanedUp() {
|
||||
// cleanup config for this test case
|
||||
setupCleanupConfiguration(true, 0, Action.Status.CANCELED, Action.Status.ERROR);
|
||||
|
||||
@@ -64,7 +65,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that nothing is cleaned up if the cleanup is disabled.
|
||||
*/
|
||||
@Test void cleanupDisabled() {
|
||||
@Test
|
||||
void cleanupDisabled() {
|
||||
// cleanup config for this test case
|
||||
setupCleanupConfiguration(false, 0, Action.Status.CANCELED);
|
||||
|
||||
@@ -90,7 +92,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that canceled and failed actions are cleaned up.
|
||||
*/
|
||||
@Test void canceledAndFailedActionsAreCleanedUp() {
|
||||
@Test
|
||||
void canceledAndFailedActionsAreCleanedUp() {
|
||||
// cleanup config for this test case
|
||||
setupCleanupConfiguration(true, 0, Action.Status.CANCELED, Action.Status.ERROR);
|
||||
|
||||
@@ -122,7 +125,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that canceled actions are cleaned up.
|
||||
*/
|
||||
@Test void canceledActionsAreCleanedUp() {
|
||||
@Test
|
||||
void canceledActionsAreCleanedUp() {
|
||||
// cleanup config for this test case
|
||||
setupCleanupConfiguration(true, 0, Action.Status.CANCELED);
|
||||
|
||||
@@ -155,7 +159,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that canceled and failed actions are cleaned up once they expired.
|
||||
*/
|
||||
@Test @SuppressWarnings("squid:S2925")
|
||||
@Test
|
||||
@SuppressWarnings("squid:S2925")
|
||||
void canceledAndFailedActionsAreCleanedUpWhenExpired() throws InterruptedException {
|
||||
// cleanup config for this test case
|
||||
setupCleanupConfiguration(true, 500, Action.Status.CANCELED, Action.Status.ERROR);
|
||||
|
||||
@@ -42,7 +42,8 @@ class AutoCleanupSchedulerTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that all cleanup handlers are executed regardless if one of them throws an error
|
||||
*/
|
||||
@Test void executeHandlerChain() {
|
||||
@Test
|
||||
void executeHandlerChain() {
|
||||
|
||||
new AutoCleanupScheduler(systemManagement, systemSecurityContext, lockRegistry, Arrays.asList(
|
||||
new SuccessfulCleanup(), new SuccessfulCleanup(), new FailingCleanup(), new SuccessfulCleanup())).run();
|
||||
|
||||
@@ -63,7 +63,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the target created event is published when a target has been created
|
||||
*/
|
||||
@Test void targetCreatedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void targetCreatedEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
|
||||
final TargetCreatedEvent targetCreatedEvent = eventListener.waitForEvent(TargetCreatedEvent.class);
|
||||
@@ -74,7 +75,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the target update event is published when a target has been updated
|
||||
*/
|
||||
@Test void targetUpdateEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void targetUpdateEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
targetManagement.update(entityFactory.target().update(createdTarget.getControllerId()).name("updateName"));
|
||||
|
||||
@@ -86,7 +88,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the target deleted event is published when a target has been deleted
|
||||
*/
|
||||
@Test void targetDeletedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void targetDeletedEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
|
||||
targetManagement.deleteByControllerID("12345");
|
||||
@@ -99,7 +102,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the target type created event is published when a target type has been created
|
||||
*/
|
||||
@Test void targetTypeCreatedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void targetTypeCreatedEventIsPublished() throws InterruptedException {
|
||||
final TargetType createdTargetType = testdataFactory.findOrCreateTargetType("targettype");
|
||||
|
||||
final TargetTypeCreatedEvent targetTypeCreatedEvent = eventListener.waitForEvent(TargetTypeCreatedEvent.class);
|
||||
@@ -110,7 +114,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the target type updated event is published when a target type has been updated
|
||||
*/
|
||||
@Test void targetTypeUpdatedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void targetTypeUpdatedEventIsPublished() throws InterruptedException {
|
||||
final TargetType createdTargetType = testdataFactory.findOrCreateTargetType("targettype");
|
||||
targetTypeManagement
|
||||
.update(entityFactory.targetType().update(createdTargetType.getId()).name("updatedtargettype"));
|
||||
@@ -123,7 +128,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the target type deleted event is published when a target type has been deleted
|
||||
*/
|
||||
@Test void targetTypeDeletedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void targetTypeDeletedEventIsPublished() throws InterruptedException {
|
||||
final TargetType createdTargetType = testdataFactory.findOrCreateTargetType("targettype");
|
||||
targetTypeManagement.delete(createdTargetType.getId());
|
||||
|
||||
@@ -135,7 +141,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the rollout deleted event is published when a rollout has been deleted
|
||||
*/
|
||||
@Test void rolloutDeletedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void rolloutDeletedEventIsPublished() throws InterruptedException {
|
||||
final int amountTargetsForRollout = 50;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
@@ -159,7 +166,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the distribution set created event is published when a distribution set has been created
|
||||
*/
|
||||
@Test void distributionSetCreatedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void distributionSetCreatedEventIsPublished() throws InterruptedException {
|
||||
final DistributionSet createDistributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
final DistributionSetCreatedEvent dsCreatedEvent = eventListener
|
||||
@@ -171,7 +179,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the distribution set deleted event is published when a distribution set has been deleted
|
||||
*/
|
||||
@Test void distributionSetDeletedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void distributionSetDeletedEventIsPublished() throws InterruptedException {
|
||||
final DistributionSet createDistributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
distributionSetManagement.delete(createDistributionSet.getId());
|
||||
@@ -185,7 +194,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the software module created event is published when a software module has been created
|
||||
*/
|
||||
@Test void softwareModuleCreatedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void softwareModuleCreatedEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
final SoftwareModuleCreatedEvent softwareModuleCreatedEvent = eventListener
|
||||
@@ -197,7 +207,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the software module update event is published when a software module has been updated
|
||||
*/
|
||||
@Test void softwareModuleUpdateEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void softwareModuleUpdateEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
softwareModuleManagement
|
||||
.update(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
@@ -211,7 +222,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the software module deleted event is published when a software module has been deleted
|
||||
*/
|
||||
@Test void softwareModuleDeletedEventIsPublished() throws InterruptedException {
|
||||
@Test
|
||||
void softwareModuleDeletedEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
softwareModuleManagement.delete(softwareModule.getId());
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ class ActionTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that timeforced moded switch from soft to forces after defined timeframe.
|
||||
*/
|
||||
@Test void timeForcedHitNewHasCodeIsGenerated() {
|
||||
@Test
|
||||
void timeForcedHitNewHasCodeIsGenerated() {
|
||||
// current time + 1 seconds
|
||||
final long sleepTime = 1000;
|
||||
final long timeForceTimeAt = System.currentTimeMillis() + sleepTime;
|
||||
@@ -53,7 +54,8 @@ class ActionTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the action type mapping.
|
||||
*/
|
||||
@Test void testActionTypeConvert() {
|
||||
@Test
|
||||
void testActionTypeConvert() {
|
||||
final long id = createAction().getId();
|
||||
for (final ActionType actionType : ActionType.values()) {
|
||||
final JpaAction action = actionRepository.findById(id).orElseThrow(() -> new IllegalStateException("Action not found"));
|
||||
@@ -67,7 +69,8 @@ class ActionTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the status mapping.
|
||||
*/
|
||||
@Test void testStatusConvert() {
|
||||
@Test
|
||||
void testStatusConvert() {
|
||||
final long id = createAction().getId();
|
||||
for (final Status status : Status.values()) {
|
||||
final JpaAction action = actionRepository.findById(id).orElseThrow(() -> new IllegalStateException("Action not found"));
|
||||
@@ -81,7 +84,8 @@ class ActionTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the action status status mapping.
|
||||
*/
|
||||
@Test void testActionsStatusStatusConvert() {
|
||||
@Test
|
||||
void testActionsStatusStatusConvert() {
|
||||
for (final Status status : Status.values()) {
|
||||
final long id = createAction().getId();
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(id).status(status));
|
||||
|
||||
@@ -27,7 +27,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#count() method
|
||||
*/
|
||||
@Test @WithUser(principal = "user", authorities = { SpPermission.READ_REPOSITORY })
|
||||
@Test
|
||||
@WithUser(principal = "user", authorities = { SpPermission.READ_REPOSITORY })
|
||||
void countPermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.count(), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -35,7 +36,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#create() method
|
||||
*/
|
||||
@Test void createPermissionCheck() {
|
||||
@Test
|
||||
void createPermissionCheck() {
|
||||
ArtifactUpload artifactUpload = new ArtifactUpload(new ByteArrayInputStream("RandomString".getBytes()), 1L, "filename", false, 1024);
|
||||
assertPermissions(() -> artifactManagement.create(artifactUpload), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
}
|
||||
@@ -43,7 +45,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#delete() method
|
||||
*/
|
||||
@Test void deletePermissionCheck() {
|
||||
@Test
|
||||
void deletePermissionCheck() {
|
||||
assertPermissions(() -> {
|
||||
artifactManagement.delete(1);
|
||||
return null;
|
||||
@@ -53,7 +56,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#get() method
|
||||
*/
|
||||
@Test void getPermissionCheck() {
|
||||
@Test
|
||||
void getPermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.get(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> artifactManagement.get(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
}
|
||||
@@ -61,7 +65,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#getByFilenameAndSoftwareModule() method
|
||||
*/
|
||||
@Test void getByFilenameAndSoftwareModulePermissionCheck() {
|
||||
@Test
|
||||
void getByFilenameAndSoftwareModulePermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.getByFilenameAndSoftwareModule("filename", 1L),
|
||||
List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
assertPermissions(() -> artifactManagement.getByFilenameAndSoftwareModule("filename", 1L),
|
||||
@@ -71,7 +76,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#findFirstBySHA1() method
|
||||
*/
|
||||
@Test void findFirstBySHA1PermissionCheck() {
|
||||
@Test
|
||||
void findFirstBySHA1PermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.findFirstBySHA1("sha1"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> artifactManagement.findFirstBySHA1("sha1"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
}
|
||||
@@ -79,7 +85,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#getByFilename() method
|
||||
*/
|
||||
@Test void getByFilenamePermissionCheck() {
|
||||
@Test
|
||||
void getByFilenamePermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.getByFilename("filename"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> artifactManagement.getByFilename("filename"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
}
|
||||
@@ -87,21 +94,24 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ArtifactManagement#findBySoftwareModule() method
|
||||
*/
|
||||
@Test void findBySoftwareModulePermissionCheck() {
|
||||
@Test
|
||||
void findBySoftwareModulePermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.findBySoftwareModule(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ArtifactManagement#countBySoftwareModule() method
|
||||
*/
|
||||
@Test void countBySoftwareModulePermissionCheck() {
|
||||
@Test
|
||||
void countBySoftwareModulePermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.countBySoftwareModule(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ArtifactManagement#loadArtifactBinary() method
|
||||
*/
|
||||
@Test void loadArtifactBinaryPermissionCheck() {
|
||||
@Test
|
||||
void loadArtifactBinaryPermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpPermission.DOWNLOAD_REPOSITORY_ARTIFACT), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that management get access react as specfied on calls for non existing entities by means of Optional not present.
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
|
||||
void nonExistingEntityAccessReturnsNotPresent() {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
@@ -104,7 +105,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test if a local artifact can be created by API including metadata.
|
||||
*/
|
||||
@Test void createArtifact() throws IOException {
|
||||
@Test
|
||||
void createArtifact() throws IOException {
|
||||
// check baseline
|
||||
assertThat(softwareModuleRepository.findAll()).isEmpty();
|
||||
assertThat(artifactRepository.findAll()).isEmpty();
|
||||
@@ -148,7 +150,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that artifact management does not create artifacts with illegal filename.
|
||||
*/
|
||||
@Test void entityQueryWithIllegalFilenameThrowsException() {
|
||||
@Test
|
||||
void entityQueryWithIllegalFilenameThrowsException() {
|
||||
final String illegalFilename = "<img src=ernw onerror=alert(1)>.xml";
|
||||
final String artifactData = "test";
|
||||
final int artifactSize = artifactData.length();
|
||||
@@ -163,7 +166,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the quota specifying the maximum number of artifacts per software module is enforced.
|
||||
*/
|
||||
@Test void createArtifactsUntilQuotaIsExceeded() throws IOException {
|
||||
@Test
|
||||
void createArtifactsUntilQuotaIsExceeded() throws IOException {
|
||||
// create a software module
|
||||
final long smId = softwareModuleRepository.save(new JpaSoftwareModule(osType, "sm1", "1.0")).getId();
|
||||
|
||||
@@ -193,7 +197,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the quota specifying the maximum artifact storage is enforced (across software modules).
|
||||
*/
|
||||
@Test void createArtifactsUntilStorageQuotaIsExceeded() throws IOException {
|
||||
@Test
|
||||
void createArtifactsUntilStorageQuotaIsExceeded() throws IOException {
|
||||
// create as many small artifacts as possible w/o violating the storage quota
|
||||
final long maxBytes = quotaManagement.getMaxArtifactStorage();
|
||||
final List<Long> artifactIds = new ArrayList<>();
|
||||
@@ -221,7 +226,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that you cannot create artifacts which exceed the configured maximum size.
|
||||
*/
|
||||
@Test void createArtifactFailsIfTooLarge() {
|
||||
@Test
|
||||
void createArtifactFailsIfTooLarge() {
|
||||
// create a software module
|
||||
final long smId = softwareModuleRepository.save(new JpaSoftwareModule(osType, "sm1", "1.0")).getId();
|
||||
|
||||
@@ -234,7 +240,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests hard delete directly on repository.
|
||||
*/
|
||||
@Test void hardDeleteSoftwareModule() throws IOException {
|
||||
@Test
|
||||
void hardDeleteSoftwareModule() throws IOException {
|
||||
final JpaSoftwareModule sm = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 1", "version 1"));
|
||||
|
||||
createArtifactForSoftwareModule("file1", sm.getId(), 5 * 1024);
|
||||
@@ -250,7 +257,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the deletion of a local artifact including metadata.
|
||||
*/
|
||||
@Test void deleteArtifact() throws IOException {
|
||||
@Test
|
||||
void deleteArtifact() throws IOException {
|
||||
final JpaSoftwareModule sm = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 1", "version 1"));
|
||||
final JpaSoftwareModule sm2 = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 2", "version 2"));
|
||||
|
||||
@@ -322,7 +330,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that you cannot delete an artifact which exists with the same hash, in the same tenant and the SoftwareModule is not deleted .
|
||||
*/
|
||||
@Test void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInSameTenants() throws IOException {
|
||||
@Test
|
||||
void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInSameTenants() throws IOException {
|
||||
final JpaSoftwareModule sm = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 1", "version 1"));
|
||||
final JpaSoftwareModule sm2 = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 2", "version 2"));
|
||||
|
||||
@@ -360,7 +369,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that you can not delete artifacts from another tenant which exists in another tenant with the same hash and the SoftwareModule is not deleted
|
||||
*/
|
||||
@Test void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInDifferentTenants() throws Exception {
|
||||
@Test
|
||||
void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInDifferentTenants() throws Exception {
|
||||
final String tenant1 = "mytenant";
|
||||
final String tenant2 = "tenant2";
|
||||
|
||||
@@ -388,7 +398,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Loads an local artifact based on given ID.
|
||||
*/
|
||||
@Test void findArtifact() throws IOException {
|
||||
@Test
|
||||
void findArtifact() throws IOException {
|
||||
final int artifactSize = 5 * 1024;
|
||||
try (final InputStream inputStream = new RandomGeneratedInputStream(artifactSize)) {
|
||||
final Artifact artifact = createArtifactForSoftwareModule(
|
||||
@@ -400,7 +411,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Loads an artifact binary based on given ID.
|
||||
*/
|
||||
@Test void loadStreamOfArtifact() throws IOException {
|
||||
@Test
|
||||
void loadStreamOfArtifact() throws IOException {
|
||||
final int artifactSize = 5 * 1024;
|
||||
final byte[] randomBytes = randomBytes(artifactSize);
|
||||
try (final InputStream input = new ByteArrayInputStream(randomBytes)) {
|
||||
@@ -425,7 +437,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Searches an artifact through the relations of a software module.
|
||||
*/
|
||||
@Test void findArtifactBySoftwareModule() throws IOException {
|
||||
@Test
|
||||
void findArtifactBySoftwareModule() throws IOException {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).isEmpty();
|
||||
|
||||
@@ -439,7 +452,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Searches an artifact through the relations of a software module and the filename.
|
||||
*/
|
||||
@Test void findByFilenameAndSoftwareModule() throws IOException {
|
||||
@Test
|
||||
void findByFilenameAndSoftwareModule() throws IOException {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
|
||||
@@ -456,7 +470,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that creation of an artifact with none matching hashes fails.
|
||||
*/
|
||||
@Test void createArtifactWithNoneMatchingHashes() throws IOException, NoSuchAlgorithmException {
|
||||
@Test
|
||||
void createArtifactWithNoneMatchingHashes() throws IOException, NoSuchAlgorithmException {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte[] testData = randomBytes(100);
|
||||
@@ -490,7 +505,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that creation of an artifact with matching hashes works.
|
||||
*/
|
||||
@Test void createArtifactWithMatchingHashes() throws IOException, NoSuchAlgorithmException {
|
||||
@Test
|
||||
void createArtifactWithMatchingHashes() throws IOException, NoSuchAlgorithmException {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte[] testData = randomBytes(100);
|
||||
@@ -513,7 +529,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that creation of an existing artifact returns a full hash list.
|
||||
*/
|
||||
@Test void createExistingArtifactReturnsFullHashList() throws IOException, NoSuchAlgorithmException {
|
||||
@Test
|
||||
void createExistingArtifactReturnsFullHashList() throws IOException, NoSuchAlgorithmException {
|
||||
final SoftwareModule smOs = testdataFactory.createSoftwareModuleOs();
|
||||
final SoftwareModule smApp = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
|
||||
@@ -24,14 +24,16 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ConfirmationManagement#findActiveActionsWaitingConfirmation() method
|
||||
*/
|
||||
@Test void findActiveActionsWaitingConfirmationPermissionsCheck() {
|
||||
@Test
|
||||
void findActiveActionsWaitingConfirmationPermissionsCheck() {
|
||||
assertPermissions(() -> confirmationManagement.findActiveActionsWaitingConfirmation("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ConfirmationManagement#activateAutoConfirmation() method
|
||||
*/
|
||||
@Test void activateAutoConfirmationPermissionsCheck() {
|
||||
@Test
|
||||
void activateAutoConfirmationPermissionsCheck() {
|
||||
assertPermissions(() -> confirmationManagement.activateAutoConfirmation("controllerId", "initiator", "remark"),
|
||||
List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
@@ -39,7 +41,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ConfirmationManagement#getStatus() method
|
||||
*/
|
||||
@Test void getStatusPermissionsCheck() {
|
||||
@Test
|
||||
void getStatusPermissionsCheck() {
|
||||
assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpPermission.READ_TARGET),
|
||||
List.of(SpPermission.CREATE_TARGET));
|
||||
assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_TARGET));
|
||||
@@ -48,7 +51,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ConfirmationManagement#confirmAction() method
|
||||
*/
|
||||
@Test void confirmActionPermissionsCheck() {
|
||||
@Test
|
||||
void confirmActionPermissionsCheck() {
|
||||
assertPermissions(() -> confirmationManagement.confirmAction(1L, null, null),
|
||||
List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
@@ -56,7 +60,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ConfirmationManagement#denyAction() method
|
||||
*/
|
||||
@Test void denyActionPermissionsCheck() {
|
||||
@Test
|
||||
void denyActionPermissionsCheck() {
|
||||
assertPermissions(() -> confirmationManagement.denyAction(1L, null, null),
|
||||
List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
@@ -64,7 +69,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ConfirmationManagement#deactivateAutoConfirmation() method
|
||||
*/
|
||||
@Test void deactivateAutoConfirmationPermissionsCheck() {
|
||||
@Test
|
||||
void deactivateAutoConfirmationPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
confirmationManagement.deactivateAutoConfirmation("controllerId");
|
||||
return null;
|
||||
|
||||
@@ -44,7 +44,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify 'findActiveActionsWaitingConfirmation' method is filtering like expected
|
||||
*/
|
||||
@Test void retrieveActionsWithConfirmationState() {
|
||||
@Test
|
||||
void retrieveActionsWithConfirmationState() {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
@@ -67,7 +68,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify 'findActiveActionsWaitingConfirmation' method is filtering like expected with multi assignment active
|
||||
*/
|
||||
@Test void retrieveActionsWithConfirmationStateInMultiAssignment() {
|
||||
@Test
|
||||
void retrieveActionsWithConfirmationStateInMultiAssignment() {
|
||||
enableMultiAssignments();
|
||||
enableConfirmationFlow();
|
||||
|
||||
@@ -97,7 +99,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify confirming an action will put it to the running state
|
||||
*/
|
||||
@Test void confirmedActionWillSwitchToRunningState() {
|
||||
@Test
|
||||
void confirmedActionWillSwitchToRunningState() {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
@@ -126,7 +129,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify confirming an confirmed action will lead to a specific failure
|
||||
*/
|
||||
@Test void confirmedActionCannotBeConfirmedAgain() {
|
||||
@Test
|
||||
void confirmedActionCannotBeConfirmedAgain() {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
@@ -148,7 +152,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify confirming a closed action will lead to a specific failure
|
||||
*/
|
||||
@Test void confirmedActionCannotBeGivenOnFinishedAction() {
|
||||
@Test
|
||||
void confirmedActionCannotBeGivenOnFinishedAction() {
|
||||
enableConfirmationFlow();
|
||||
final Long actionId = prepareFinishedUpdate().getId();
|
||||
assertThatThrownBy(() -> confirmationManagement.confirmAction(actionId, null, null))
|
||||
@@ -160,7 +165,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify denying an action will leave it in WFC state
|
||||
*/
|
||||
@Test void deniedActionWillStayInWfcState() {
|
||||
@Test
|
||||
void deniedActionWillStayInWfcState() {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
@@ -189,7 +195,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify multiple actions in WFC state will be transferred in RUNNING state in case auto-confirmation is activated.
|
||||
*/
|
||||
@Test void activateAutoConfirmationInMultiAssignment() {
|
||||
@Test
|
||||
void activateAutoConfirmationInMultiAssignment() {
|
||||
enableMultiAssignments();
|
||||
enableConfirmationFlow();
|
||||
|
||||
@@ -216,7 +223,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify action in WFC state will be transferred in RUNNING state in case auto-confirmation is activated.
|
||||
*/
|
||||
@Test void activateAutoConfirmationOnActiveAction() {
|
||||
@Test
|
||||
void activateAutoConfirmationOnActiveAction() {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
@@ -239,7 +247,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify created action after activating auto confirmation is directly in running state.
|
||||
*/
|
||||
@Test void activateAutoConfirmationAndCreateAction() {
|
||||
@Test
|
||||
void activateAutoConfirmationAndCreateAction() {
|
||||
enableConfirmationFlow();
|
||||
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
@@ -284,7 +293,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify activating already active auto confirmation will throw exception.
|
||||
*/
|
||||
@Test void verifyActivateAlreadyActiveAutoConfirmationThrowException() {
|
||||
@Test
|
||||
void verifyActivateAlreadyActiveAutoConfirmationThrowException() {
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
|
||||
confirmationManagement.activateAutoConfirmation(controllerId, "any", "any");
|
||||
@@ -298,7 +308,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify disabling already disabled auto confirmation will not have any affect.
|
||||
*/
|
||||
@Test void disableAlreadyDisabledAutoConfirmationHaveNoAffect() {
|
||||
@Test
|
||||
void disableAlreadyDisabledAutoConfirmationHaveNoAffect() {
|
||||
final String controllerId = testdataFactory.createTarget().getControllerId();
|
||||
|
||||
verifyAutoConfirmationIsDisabled(controllerId);
|
||||
|
||||
@@ -30,7 +30,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#cancelActionStatus() method
|
||||
*/
|
||||
@Test void addCancelActionStatusPermissionsCheck() {
|
||||
@Test
|
||||
void addCancelActionStatusPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.addCancelActionStatus(entityFactory.actionStatus().create(0L)),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -38,14 +39,16 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getSoftwareModule() method
|
||||
*/
|
||||
@Test void getSoftwareModulePermissionsCheck() {
|
||||
@Test
|
||||
void getSoftwareModulePermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getSoftwareModule(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ControllerManagement#findTargetVisibleMetaDataBySoftwareModuleId() method
|
||||
*/
|
||||
@Test void findTargetVisibleMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||
@Test
|
||||
void findTargetVisibleMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.findTargetVisibleMetaDataBySoftwareModuleId(List.of(1L)),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -53,7 +56,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#addInformationalActionStatus() method
|
||||
*/
|
||||
@Test void addInformationalActionStatusPermissionsCheck() {
|
||||
@Test
|
||||
void addInformationalActionStatusPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.addInformationalActionStatus(entityFactory.actionStatus().create(0L)),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -61,7 +65,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#addUpdateActionStatus() method
|
||||
*/
|
||||
@Test void addUpdateActionStatusPermissionsCheck() {
|
||||
@Test
|
||||
void addUpdateActionStatusPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(0L)),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -69,7 +74,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#findActiveActionWithHighestWeight() method
|
||||
*/
|
||||
@Test void findActiveActionWithHighestWeightPermissionsCheck() {
|
||||
@Test
|
||||
void findActiveActionWithHighestWeightPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.findActiveActionWithHighestWeight("controllerId"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -77,7 +83,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#findActiveActionsWithHighestWeight() method
|
||||
*/
|
||||
@Test void findActiveActionsWithHighestWeightPermissionsCheck() {
|
||||
@Test
|
||||
void findActiveActionsWithHighestWeightPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.findActiveActionsWithHighestWeight("controllerId", 1),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -85,14 +92,16 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#findActionWithDetails() method
|
||||
*/
|
||||
@Test void findActionWithDetailsPermissionsCheck() {
|
||||
@Test
|
||||
void findActionWithDetailsPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.findActionWithDetails(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ControllerManagement#findActionStatusByAction() method
|
||||
*/
|
||||
@Test void findActionStatusByActionPermissionsCheck() {
|
||||
@Test
|
||||
void findActionStatusByActionPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.findActionStatusByAction(1L, Pageable.unpaged()),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -100,7 +109,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#findOrRegisterTargetIfItDoesNotExist() method
|
||||
*/
|
||||
@Test void findOrRegisterTargetIfItDoesNotExistPermissionsCheck() {
|
||||
@Test
|
||||
void findOrRegisterTargetIfItDoesNotExistPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist("controllerId", URI.create("someaddress")),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -108,7 +118,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#findOrRegisterTargetIfItDoesNotExist() method
|
||||
*/
|
||||
@Test void findOrRegisterTargetIfItDoesNotExistWithDetailsPermissionsCheck() {
|
||||
@Test
|
||||
void findOrRegisterTargetIfItDoesNotExistWithDetailsPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist("controllerId", URI.create("someaddress"), "name", "type"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
@@ -117,7 +128,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getActionForDownloadByTargetAndSoftwareModule() method
|
||||
*/
|
||||
@Test void getActionForDownloadByTargetAndSoftwareModulePermissionsCheck() {
|
||||
@Test
|
||||
void getActionForDownloadByTargetAndSoftwareModulePermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getActionForDownloadByTargetAndSoftwareModule("controllerId", 1L),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -125,21 +137,24 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getPollingTime() method
|
||||
*/
|
||||
@Test void getPollingTimePermissionsCheck() {
|
||||
@Test
|
||||
void getPollingTimePermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getPollingTime(), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ControllerManagement#getMinPollingTime() method
|
||||
*/
|
||||
@Test void getMinPollingTimePermissionsCheck() {
|
||||
@Test
|
||||
void getMinPollingTimePermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getMinPollingTime(), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ControllerManagement#getMaxPollingTime() method
|
||||
*/
|
||||
@Test void getMaintenanceWindowPollCountPermissionsCheck() {
|
||||
@Test
|
||||
void getMaintenanceWindowPollCountPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getMaintenanceWindowPollCount(),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -147,7 +162,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getPollingTimeForAction() method
|
||||
*/
|
||||
@Test void getPollingTimeForActionPermissionsCheck() {
|
||||
@Test
|
||||
void getPollingTimeForActionPermissionsCheck() {
|
||||
final JpaAction action = new JpaAction();
|
||||
action.setId(1L);
|
||||
assertPermissions(() -> {
|
||||
@@ -163,7 +179,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#hasTargetArtifactAssigned() method
|
||||
*/
|
||||
@Test void hasTargetArtifactAssignedPermissionsCheck() {
|
||||
@Test
|
||||
void hasTargetArtifactAssignedPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.hasTargetArtifactAssigned("controllerId", "sha1Hash"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -171,7 +188,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#hasTargetArtifactAssigned() method
|
||||
*/
|
||||
@Test void hasTargetArtifactAssignedByIdPermissionsCheck() {
|
||||
@Test
|
||||
void hasTargetArtifactAssignedByIdPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.hasTargetArtifactAssigned(1L, "sha1Hash"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -179,7 +197,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#updateControllerAttributes() method
|
||||
*/
|
||||
@Test void updateControllerAttributesPermissionsCheck() {
|
||||
@Test
|
||||
void updateControllerAttributesPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.updateControllerAttributes("controllerId", Map.of(), null),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -187,7 +206,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getByControllerId() method
|
||||
*/
|
||||
@Test void getByControllerIdPermissionsCheck() {
|
||||
@Test
|
||||
void getByControllerIdPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getByControllerId("controllerId"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
assertPermissions(() -> controllerManagement.getByControllerId("controllerId"),
|
||||
@@ -197,7 +217,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#get() method
|
||||
*/
|
||||
@Test void getPermissionsCheck() {
|
||||
@Test
|
||||
void getPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.get(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
assertPermissions(() -> controllerManagement.get(1L), List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE));
|
||||
}
|
||||
@@ -205,7 +226,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getActionHistoryMessages() method
|
||||
*/
|
||||
@Test void getActionHistoryMessagesPermissionsCheck() {
|
||||
@Test
|
||||
void getActionHistoryMessagesPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getActionHistoryMessages(1L, 1),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -213,7 +235,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#cancelAction() method
|
||||
*/
|
||||
@Test void cancelActionPermissionsCheck() {
|
||||
@Test
|
||||
void cancelActionPermissionsCheck() {
|
||||
final JpaAction action = new JpaAction();
|
||||
action.setId(1L);
|
||||
assertPermissions(() -> {
|
||||
@@ -229,7 +252,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#updateActionExternalRef() method
|
||||
*/
|
||||
@Test void updateActionExternalRefPermissionsCheck() {
|
||||
@Test
|
||||
void updateActionExternalRefPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
controllerManagement.updateActionExternalRef(1L, "externalRef");
|
||||
return null;
|
||||
@@ -239,7 +263,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getActionByExternalRef() method
|
||||
*/
|
||||
@Test void getActionByExternalRefPermissionsCheck() {
|
||||
@Test
|
||||
void getActionByExternalRefPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.getActionByExternalRef("externalRef"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
@@ -247,7 +272,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#deleteExistingTarget() method
|
||||
*/
|
||||
@Test void deleteExistingTargetPermissionsCheck() {
|
||||
@Test
|
||||
void deleteExistingTargetPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
controllerManagement.deleteExistingTarget("controllerId");
|
||||
return null;
|
||||
@@ -257,7 +283,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#getInstalledActionByTarget() method
|
||||
*/
|
||||
@Test void getInstalledActionByTargetPermissionsCheck() {
|
||||
@Test
|
||||
void getInstalledActionByTargetPermissionsCheck() {
|
||||
final Target target = testdataFactory.createTarget();
|
||||
assertPermissions(
|
||||
() -> controllerManagement.getInstalledActionByTarget(target),
|
||||
@@ -267,7 +294,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#activateAutoConfirmation() method
|
||||
*/
|
||||
@Test void activateAutoConfirmationPermissionsCheck() {
|
||||
@Test
|
||||
void activateAutoConfirmationPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> controllerManagement.activateAutoConfirmation("controllerId", "initiator", "remark"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
@@ -276,7 +304,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#deactivateAutoConfirmation() method
|
||||
*/
|
||||
@Test void deactivateAutoConfirmationPermissionsCheck() {
|
||||
@Test
|
||||
void deactivateAutoConfirmationPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
controllerManagement.deactivateAutoConfirmation("controllerId");
|
||||
return null;
|
||||
@@ -286,7 +315,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ControllerManagement#updateOfflineAssignedVersion() method
|
||||
*/
|
||||
@Test void updateOfflineAssignedVersionPermissionsCheck() {
|
||||
@Test
|
||||
void updateOfflineAssignedVersionPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.updateOfflineAssignedVersion("controllerId", "distributionName", "version"),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
|
||||
@@ -97,7 +97,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that target attribute update fails if quota hits.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 2) })
|
||||
void updateTargetAttributesFailsIfTooManyEntries() throws Exception {
|
||||
@@ -137,7 +138,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks if invalid values of attribute-key and attribute-value are handled correctly
|
||||
*/
|
||||
@Test void updateTargetAttributesFailsForInvalidAttributes() {
|
||||
@Test
|
||||
void updateTargetAttributesFailsForInvalidAttributes() {
|
||||
final String controllerId = "targetId123";
|
||||
testdataFactory.createTarget(controllerId);
|
||||
|
||||
@@ -168,7 +170,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Controller providing status entries fails if providing more than permitted by quota.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -194,7 +197,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test to verify the storage and retrieval of action history.
|
||||
*/
|
||||
@Test void findMessagesByActionStatusId() {
|
||||
@Test
|
||||
void findMessagesByActionStatusId() {
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet("1");
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
|
||||
@@ -220,7 +224,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the quota specifying the maximum number of status entries per action is enforced.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 2),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
|
||||
@@ -259,7 +264,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the quota specifying the maximum number of messages per action status is enforced.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -290,7 +296,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a DOWNLOAD_ONLY action is not marked complete when the controller reports DOWNLOAD
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -380,7 +387,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Controller confirms successful update with FINISHED status.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -408,7 +416,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Controller confirmation fails with invalid messages.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -471,7 +480,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Update server rejects cancellation feedback if action is not in CANCELING state.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -497,7 +507,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Controller confirms action cancellation with FINISHED status.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -529,7 +540,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Controller confirms action cancellation with FINISHED status.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -670,7 +682,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller which does not exist
|
||||
*/
|
||||
@Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@Test
|
||||
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 2) })
|
||||
@@ -686,7 +699,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller with name which does not exist and update its name
|
||||
*/
|
||||
@Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@Test
|
||||
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 2),
|
||||
@@ -704,7 +718,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller which does not exist with existing target type and update its target type to another existing one
|
||||
*/
|
||||
@Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@Test
|
||||
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetTypeCreatedEvent.class, count = 2),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@@ -728,7 +743,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller which does not exist with existing target type and update its target type to non existing one
|
||||
*/
|
||||
@Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@Test
|
||||
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@@ -748,7 +764,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller which does not exist with existing target type and unassign its target type
|
||||
*/
|
||||
@Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@Test
|
||||
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@@ -769,7 +786,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller which does not exist without target type and update its target type to existing one
|
||||
*/
|
||||
@Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@Test
|
||||
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@@ -792,7 +810,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller which does not exist with non existing target type and update its target type to existing one
|
||||
*/
|
||||
@Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@Test
|
||||
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@@ -815,7 +834,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tries to register a target with an invalid controller id
|
||||
*/
|
||||
@Test void findOrRegisterTargetIfItDoesNotExistThrowsExceptionForInvalidControllerIdParam() {
|
||||
@Test
|
||||
void findOrRegisterTargetIfItDoesNotExistThrowsExceptionForInvalidControllerIdParam() {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("register target with null as controllerId should fail")
|
||||
.isThrownBy(() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist(null, LOCALHOST));
|
||||
@@ -890,7 +910,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Register a controller which does not exist, then update the controller twice, first time by providing a name property and second time without a new name
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 3),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 1) })
|
||||
@@ -961,7 +982,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that targetVisible metadata is returned from repository
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6) })
|
||||
@@ -979,7 +1001,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that controller registration does not result in a TargetPollEvent if feature is disabled
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
@SuppressWarnings("java:S2699")
|
||||
// java:S2699 - test tests the fired events, no need for assert
|
||||
void targetPollEventNotSendIfDisabled() {
|
||||
@@ -991,7 +1014,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Controller tries to finish an update process after it has been finished by an error action status.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1033,7 +1057,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Controller tries to finish an update process after it has been finished by an FINISHED action status.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1127,7 +1152,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that target attribute update is reflected by the repository.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 3) })
|
||||
void updateTargetAttributes() throws Exception {
|
||||
@@ -1154,7 +1180,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that target attributes can be updated using different update modes.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 4) })
|
||||
void updateTargetAttributesWithDifferentUpdateModes() {
|
||||
@@ -1177,7 +1204,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a DOWNLOAD_ONLY action is marked complete once the controller reports DOWNLOADED
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1204,7 +1232,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a controller can report a FINISHED event for a DOWNLOAD_ONLY non-active action.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1232,7 +1261,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that multiple DOWNLOADED events for a DOWNLOAD_ONLY action are handled.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1289,7 +1319,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that quota is enforced for UpdateActionStatus events for DOWNLOAD_ONLY assignments.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1337,7 +1368,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that quota is enforced for UpdateActionStatus events for FORCED assignments.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1384,7 +1416,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the attaching externalRef to an action is properly stored
|
||||
*/
|
||||
@Test void updatedExternalRefOnActionIsReallyUpdated() {
|
||||
@Test
|
||||
void updatedExternalRefOnActionIsReallyUpdated() {
|
||||
final List<String> allExternalRef = new ArrayList<>();
|
||||
final List<Long> allActionId = new ArrayList<>();
|
||||
final int numberOfActions = 3;
|
||||
@@ -1416,7 +1449,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that getting a single action using externalRef works
|
||||
*/
|
||||
@Test void getActionUsingSingleExternalRef() {
|
||||
@Test
|
||||
void getActionUsingSingleExternalRef() {
|
||||
|
||||
final String knownControllerId = "controllerId";
|
||||
final String knownExternalRef = "externalRefId";
|
||||
@@ -1440,7 +1474,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that assigning version form target works
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 1),
|
||||
@@ -1473,7 +1508,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a null externalRef cannot be assigned to an action
|
||||
*/
|
||||
@Test void externalRefCannotBeNull() {
|
||||
@Test
|
||||
void externalRefCannotBeNull() {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("No ConstraintViolationException thrown when a null externalRef was set on an action")
|
||||
.isThrownBy(() -> controllerManagement.updateActionExternalRef(1L, null));
|
||||
@@ -1573,7 +1609,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Actions are exposed according to thier weight in multi assignment mode.
|
||||
*/
|
||||
@Test void actionsAreExposedAccordingToTheirWeight() {
|
||||
@Test
|
||||
void actionsAreExposedAccordingToTheirWeight() {
|
||||
final String targetId = testdataFactory.createTarget().getControllerId();
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
final Long actionWeightNull = assignDistributionSet(ds.getId(), targetId).getAssignedEntity().get(0).getId();
|
||||
@@ -1607,7 +1644,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Delete a target on requested target deletion from client side
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 1),
|
||||
@Expect(type = TargetDeletedEvent.class, count = 1) })
|
||||
@@ -1624,7 +1662,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Delete a target with a non existing thingId
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetDeletedEvent.class, count = 0) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetDeletedEvent.class, count = 0) })
|
||||
void deleteTargetWithInvalidThingId() {
|
||||
assertThatExceptionOfType(EntityNotFoundException.class)
|
||||
.as("No EntityNotFoundException thrown when deleting a non-existing target")
|
||||
@@ -1635,7 +1674,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Delete a target after it has been deleted already
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 1),
|
||||
@Expect(type = TargetDeletedEvent.class, count = 1) })
|
||||
@@ -1656,7 +1696,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* When action status code is provided in feedback it is also stored in the action field lastActionStatusCode
|
||||
*/
|
||||
@Test void lastActionStatusCodeIsSet() {
|
||||
@Test
|
||||
void lastActionStatusCodeIsSet() {
|
||||
final Long actionId = createTargetAndAssignDs();
|
||||
|
||||
addUpdateActionStatusAndAssert(actionId, Action.Status.RUNNING, 10);
|
||||
|
||||
@@ -29,7 +29,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignDistributionSetsPermissionsCheck() {
|
||||
@Test
|
||||
void assignDistributionSetsPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.assignDistributionSets(
|
||||
List.of(new DeploymentRequest("controllerId", 1L, Action.ActionType.SOFT, 1L, 1, "maintenanceSchedule",
|
||||
"maintenanceWindowDuration", "maintenanceWindowTimeZone", true))),
|
||||
@@ -39,7 +40,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignDistributionSetsWithInitiatedByPermissionsCheck() {
|
||||
@Test
|
||||
void assignDistributionSetsWithInitiatedByPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.assignDistributionSets("initiator",
|
||||
List.of(new DeploymentRequest("controllerId", 1L, Action.ActionType.SOFT, 1L, 1, "maintenanceSchedule",
|
||||
"maintenanceWindowDuration", "maintenanceWindowTimeZone", true)), "message"),
|
||||
@@ -49,14 +51,16 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void offlineAssignedDistributionSetsPermissionsCheck() {
|
||||
@Test
|
||||
void offlineAssignedDistributionSetsPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.offlineAssignedDistributionSets(List.of()), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void offlineAssignedDistributionSetsWithInitiatedByPermissionsCheck() {
|
||||
@Test
|
||||
void offlineAssignedDistributionSetsWithInitiatedByPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.offlineAssignedDistributionSets(List.of(), "initiator"),
|
||||
List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
@@ -64,42 +68,48 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void cancelActionPermissionsCheck() {
|
||||
@Test
|
||||
void cancelActionPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.cancelAction(1L), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countActionsByTargetWithFilterPermissionsCheck() {
|
||||
@Test
|
||||
void countActionsByTargetWithFilterPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.countActionsByTarget("rsqlParam", "controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countActionsByTargetPermissionsCheck() {
|
||||
@Test
|
||||
void countActionsByTargetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.countActionsByTarget("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countActionsAllPermissionsCheck() {
|
||||
@Test
|
||||
void countActionsAllPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.countActionsAll(), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countActionsPermissionsCheck() {
|
||||
@Test
|
||||
void countActionsPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.countActions("id==1"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActionPermissionsCheck() {
|
||||
@Test
|
||||
void findActionPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findAction(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@@ -111,14 +121,16 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActionsPermissionsCheck() {
|
||||
@Test
|
||||
void findActionsPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActions("id==1", Pageable.unpaged()), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActionsByTargetPermissionsCheck() {
|
||||
@Test
|
||||
void findActionsByTargetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActionsByTarget("rsql==param", "controllerId", Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -126,7 +138,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActionsByTargetWithControllerIdPermissionsCheck() {
|
||||
@Test
|
||||
void findActionsByTargetWithControllerIdPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActionsByTarget("controllerId", Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -134,35 +147,40 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActionStatusByActionPermissionsCheck() {
|
||||
@Test
|
||||
void findActionStatusByActionPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActionStatusByAction(1L, Pageable.unpaged()), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countActionStatusByActionPermissionsCheck() {
|
||||
@Test
|
||||
void countActionStatusByActionPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.countActionStatusByAction(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findMessagesByActionStatusIdPermissionsCheck() {
|
||||
@Test
|
||||
void findMessagesByActionStatusIdPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActionWithDetailsPermissionsCheck() {
|
||||
@Test
|
||||
void findActionWithDetailsPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActionWithDetails(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActiveActionsByTargetPermissionsCheck() {
|
||||
@Test
|
||||
void findActiveActionsByTargetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActiveActionsByTarget("controllerId", Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -170,7 +188,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findInActiveActionsByTargetPermissionsCheck() {
|
||||
@Test
|
||||
void findInActiveActionsByTargetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget("controllerId", Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -178,28 +197,32 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActiveActionsWithHighestWeightPermissionsCheck() {
|
||||
@Test
|
||||
void findActiveActionsWithHighestWeightPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActiveActionsWithHighestWeight("controllerId", 1), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void forceQuitActionPermissionsCheck() {
|
||||
@Test
|
||||
void forceQuitActionPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.forceQuitAction(1L), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void forceTargetActionPermissionsCheck() {
|
||||
@Test
|
||||
void forceTargetActionPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.forceTargetAction(1L), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void cancelInactiveScheduledActionsForTargetsPermissionsCheck() {
|
||||
@Test
|
||||
void cancelInactiveScheduledActionsForTargetsPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
deploymentManagement.cancelInactiveScheduledActionsForTargets(List.of(1L));
|
||||
return null;
|
||||
@@ -209,7 +232,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void startScheduledActionsByRolloutGroupParentPermissionsCheck() {
|
||||
@Test
|
||||
void startScheduledActionsByRolloutGroupParentPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
deploymentManagement.startScheduledActionsByRolloutGroupParent(1L, 1L, 1L);
|
||||
return null;
|
||||
@@ -219,7 +243,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void startScheduledActionsPermissionsCheck() {
|
||||
@Test
|
||||
void startScheduledActionsPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
deploymentManagement.startScheduledActions(List.of());
|
||||
return null;
|
||||
@@ -229,21 +254,24 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getAssignedDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void getAssignedDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.getAssignedDistributionSet("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getInstalledDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void getInstalledDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.getInstalledDistributionSet("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteActionsByStatusAndLastModifiedBeforePermissionsCheck() {
|
||||
@Test
|
||||
void deleteActionsByStatusAndLastModifiedBeforePermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.deleteActionsByStatusAndLastModifiedBefore(Set.of(Action.Status.CANCELED), 1L),
|
||||
List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE));
|
||||
}
|
||||
@@ -251,14 +279,16 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void hasPendingCancellationsPermissionsCheck() {
|
||||
@Test
|
||||
void hasPendingCancellationsPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.hasPendingCancellations(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void cancelActionsForDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void cancelActionsForDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
deploymentManagement.cancelActionsForDistributionSet(DistributionSetInvalidation.CancelationType.FORCE,
|
||||
entityFactory.distributionSet().create().build());
|
||||
|
||||
@@ -105,7 +105,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests that an exception is thrown when a target is assigned to an incomplete distribution set
|
||||
*/
|
||||
@Test void verifyAssignTargetsToIncompleteDistribution() {
|
||||
@Test
|
||||
void verifyAssignTargetsToIncompleteDistribution() {
|
||||
final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet();
|
||||
final Target target = testdataFactory.createTarget();
|
||||
|
||||
@@ -117,7 +118,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests that an exception is thrown when a target is assigned to an invalidated distribution set
|
||||
*/
|
||||
@Test void verifyAssignTargetsToInvalidDistribution() {
|
||||
@Test
|
||||
void verifyAssignTargetsToInvalidDistribution() {
|
||||
final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet();
|
||||
final Target target = testdataFactory.createTarget();
|
||||
|
||||
@@ -167,7 +169,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test verifies that the repistory retrieves the action including all defined (lazy) details.
|
||||
*/
|
||||
@Test void findActionWithLazyDetails() {
|
||||
@Test
|
||||
void findActionWithLazyDetails() {
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0",
|
||||
new ArrayList<>());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
@@ -185,7 +188,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test verifies that actions of a target are found by using id-based search.
|
||||
*/
|
||||
@Test void findActionByTargetId() {
|
||||
@Test
|
||||
void findActionByTargetId() {
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", new ArrayList<>());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
// one action with one action status is generated
|
||||
@@ -202,7 +206,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test verifies that the 'max actions per target' quota is enforced.
|
||||
*/
|
||||
@Test void assertMaxActionsPerTargetQuotaIsEnforced() {
|
||||
@Test
|
||||
void assertMaxActionsPerTargetQuotaIsEnforced() {
|
||||
enableMultiAssignments();
|
||||
|
||||
final int maxActions = quotaManagement.getMaxActionsPerTarget();
|
||||
@@ -221,7 +226,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* An assignment request with more assignments than allowed by 'maxTargetDistributionSetAssignmentsPerManualAssignment' quota throws an exception.
|
||||
*/
|
||||
@Test void assignmentRequestThatIsTooLarge() {
|
||||
@Test
|
||||
void assignmentRequestThatIsTooLarge() {
|
||||
final int maxActions = quotaManagement.getMaxTargetDistributionSetAssignmentsPerManualAssignment();
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("1");
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("2");
|
||||
@@ -236,7 +242,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test verifies that action-states of an action are found by using id-based search.
|
||||
*/
|
||||
@Test void findActionStatusByActionId() {
|
||||
@Test
|
||||
void findActionStatusByActionId() {
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", Collections.emptyList());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
// one action with one action status is generated
|
||||
@@ -254,7 +261,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test verifies that messages of an action-status are found by using id-based search.
|
||||
*/
|
||||
@Test void findMessagesByActionStatusId() {
|
||||
@Test
|
||||
void findMessagesByActionStatusId() {
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", new ArrayList<>());
|
||||
final List<Target> testTarget = testdataFactory.createTargets(1);
|
||||
// one action with one action status is generated
|
||||
@@ -281,7 +289,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that tag to distribution set assignment that does not exist will cause EntityNotFoundException.
|
||||
*/
|
||||
@Test void assignDistributionSetToTagThatDoesNotExistThrowsException() {
|
||||
@Test
|
||||
void assignDistributionSetToTagThatDoesNotExistThrowsException() {
|
||||
final List<Long> assignDS = new ArrayList<>(5);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
||||
@@ -300,7 +309,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 20),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 40),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
||||
@@ -428,7 +438,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Force Quit an Assignment. Expected behaviour is that the action is canceled and is marked as deleted. The assigned Software module
|
||||
*/
|
||||
@Test void forceQuitSetActionToInactive() {
|
||||
@Test
|
||||
void forceQuitSetActionToInactive() {
|
||||
final Action action = prepareFinishedUpdate("4712", "installed", true);
|
||||
final Target target = action.getTarget();
|
||||
final DistributionSet dsInstalled = action.getDistributionSet();
|
||||
@@ -464,7 +475,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Force Quit an not canceled Assignment. Expected behaviour is that the action can not be force quit and there is thrown an exception.
|
||||
*/
|
||||
@Test void forceQuitNotAllowedThrowsException() {
|
||||
@Test
|
||||
void forceQuitNotAllowedThrowsException() {
|
||||
final Action action = prepareFinishedUpdate("4712", "installed", true);
|
||||
// verify initial status
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
@@ -533,7 +545,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Offline assign multiple DSs to a single Target in multiassignment mode.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 4),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 4),
|
||||
@@ -570,7 +583,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that if an account is set to action autoclose running actions in case of a new assigned set get closed and set to CANCELED.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 10),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 20),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 20),
|
||||
@@ -614,7 +628,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* If multi-assignment is enabled, verify that the previous Distribution Set assignment is not canceled when a new one is assigned.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 10),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 20),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 20),
|
||||
@@ -646,7 +661,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Assign multiple DSs to a single Target in one request in multiassignment mode.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 4),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 4),
|
||||
@@ -684,7 +700,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Assign multiple DSs to single Target in one request in multiAssignment mode and cancel each created action afterwards.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 4),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 4),
|
||||
@@ -721,7 +738,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* A Request resulting in multiple assignments to a single target is only allowed when multiassignment is enabled.
|
||||
*/
|
||||
@Test void multipleAssignmentsToTargetOnlyAllowedInMultiAssignMode() {
|
||||
@Test
|
||||
void multipleAssignmentsToTargetOnlyAllowedInMultiAssignMode() {
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final List<DistributionSet> distributionSets = testdataFactory.createDistributionSets(2);
|
||||
|
||||
@@ -743,7 +761,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Assigning distribution set to the list of targets with a non-existing one leads to successful assignment of valid targets, while not found targets are silently ignored.
|
||||
*/
|
||||
@Test void assignDistributionSetToNotExistingTarget() {
|
||||
@Test
|
||||
void assignDistributionSetToNotExistingTarget() {
|
||||
final String notExistingId = "notExistingTarget";
|
||||
|
||||
final DistributionSet createdDs = testdataFactory.createDistributionSet();
|
||||
@@ -848,7 +867,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Multiple assignments with confirmation flow active will result in correct cancel behaviour
|
||||
*/
|
||||
@Test void multipleAssignmentWithConfirmationFlowActiveVerifyCancelBehaviour() {
|
||||
@Test
|
||||
void multipleAssignmentWithConfirmationFlowActiveVerifyCancelBehaviour() {
|
||||
final Target target = testdataFactory.createTarget("firstDevice");
|
||||
final DistributionSet firstDs = testdataFactory.createDistributionSet();
|
||||
final DistributionSet secondDs = testdataFactory.createDistributionSet();
|
||||
@@ -885,7 +905,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Assignments with confirmation flow deactivated will result in actions in only in 'RUNNING' state
|
||||
*/
|
||||
@Test void verifyConfirmationRequiredFlagHaveNoInfluenceIfFlowIsDeactivated() {
|
||||
@Test
|
||||
void verifyConfirmationRequiredFlagHaveNoInfluenceIfFlowIsDeactivated() {
|
||||
final List<String> targets1 = testdataFactory.createTargets("group1", 1).stream().map(Target::getControllerId).toList();
|
||||
final List<String> targets2 = testdataFactory.createTargets("group2", 1).stream().map(Target::getControllerId).toList();
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
@@ -911,7 +932,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Duplicate Assignments are removed from a request when multiassignment is disabled, otherwise not
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -942,7 +964,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* An assignment request is not accepted if it would lead to a target exceeding the max actions per target quota.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 21), // max actions per target are 20 for test
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3 * 21),
|
||||
@@ -972,7 +995,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* An assignment request without a weight is ok when multi assignment in enabled.
|
||||
*/
|
||||
@Test void weightNotRequiredInMultiAssignmentMode() {
|
||||
@Test
|
||||
void weightNotRequiredInMultiAssignmentMode() {
|
||||
final String targetId = testdataFactory.createTarget().getControllerId();
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
|
||||
@@ -986,7 +1010,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* An assignment request containing a weight don't causes an error when multi assignment in disabled.
|
||||
*/
|
||||
@Test void weightAllowedWhenMultiAssignmentModeNotEnabled() {
|
||||
@Test
|
||||
void weightAllowedWhenMultiAssignmentModeNotEnabled() {
|
||||
final String targetId = testdataFactory.createTarget().getControllerId();
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
|
||||
@@ -997,7 +1022,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Weights are validated and contained in the resulting Action.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1041,7 +1067,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Simple deployment or distribution set to target assignment test.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@@ -1098,7 +1125,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test that it is not possible to assign a distribution set that is not complete.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 2),
|
||||
@@ -1350,7 +1378,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Deletes multiple targets and verifies that all related metadata is also deleted.
|
||||
*/
|
||||
@Test void deletesTargetsAndVerifyCascadeDeletes() {
|
||||
@Test
|
||||
void deletesTargetsAndVerifyCascadeDeletes() {
|
||||
final String undeployedTargetPrefix = "undep-T";
|
||||
final int noOfUndeployedTargets = 2;
|
||||
|
||||
@@ -1377,7 +1406,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Testing if changing target and the status without refreshing the entities from the DB (e.g. concurrent changes from UI and from controller) works
|
||||
*/
|
||||
@Test void alternatingAssignmentAndAddUpdateActionStatus() {
|
||||
@Test
|
||||
void alternatingAssignmentAndAddUpdateActionStatus() {
|
||||
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("a");
|
||||
final DistributionSet dsB = testdataFactory.createDistributionSet("b");
|
||||
@@ -1471,7 +1501,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the switch from a soft to hard update by API
|
||||
*/
|
||||
@Test void forceSoftAction() {
|
||||
@Test
|
||||
void forceSoftAction() {
|
||||
// prepare
|
||||
final Target target = testdataFactory.createTarget("knownControllerId");
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("a");
|
||||
@@ -1494,7 +1525,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the switch from a hard to hard update by API, e.g. which in fact should not change anything.
|
||||
*/
|
||||
@Test void forceAlreadyForcedActionNothingChanges() {
|
||||
@Test
|
||||
void forceAlreadyForcedActionNothingChanges() {
|
||||
// prepare
|
||||
final Target target = testdataFactory.createTarget("knownControllerId");
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("a");
|
||||
@@ -1518,7 +1550,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the computation of already assigned entities returned as a result of an assignment
|
||||
*/
|
||||
@Test void testAlreadyAssignedAndAssignedActionsInAssignmentResult() {
|
||||
@Test
|
||||
void testAlreadyAssignedAndAssignedActionsInAssignmentResult() {
|
||||
// create target1, distributionSet, assign ds to target1 and finish
|
||||
// update (close all actions)
|
||||
final Action action = prepareFinishedUpdate("target1", "ds", false);
|
||||
@@ -1548,7 +1581,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the DistributionSetAssignmentResult not contains already assigned targets.
|
||||
*/
|
||||
@Test void verifyDistributionSetAssignmentResultNotContainsAlreadyAssignedTargets() {
|
||||
@Test
|
||||
void verifyDistributionSetAssignmentResultNotContainsAlreadyAssignedTargets() {
|
||||
final DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3");
|
||||
|
||||
// create assigned DS
|
||||
@@ -1566,7 +1600,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the DistributionSet assignments work for multiple targets of the same target type within the same request.
|
||||
*/
|
||||
@Test void verifyDSAssignmentForMultipleTargetsWithSameTargetType() {
|
||||
@Test
|
||||
void verifyDSAssignmentForMultipleTargetsWithSameTargetType() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("test-ds");
|
||||
final TargetType targetType = testdataFactory.createTargetType("test-type",
|
||||
Collections.singletonList(ds.getType()));
|
||||
@@ -1592,7 +1627,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the DistributionSet assignments work for multiple targets of different target types.
|
||||
*/
|
||||
@Test void verifyDSAssignmentForMultipleTargetsWithDifferentTargetTypes() {
|
||||
@Test
|
||||
void verifyDSAssignmentForMultipleTargetsWithDifferentTargetTypes() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("test-ds");
|
||||
final TargetType targetType1 = testdataFactory.createTargetType("test-type1", Collections.singletonList(ds.getType()));
|
||||
final TargetType targetType2 = testdataFactory.createTargetType("test-type2", Collections.singletonList(ds.getType()));
|
||||
@@ -1618,7 +1654,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the DistributionSet assignment fails for target with incompatible target type.
|
||||
*/
|
||||
@Test void verifyDSAssignmentFailsForTargetsWithIncompatibleTargetTypes() {
|
||||
@Test
|
||||
void verifyDSAssignmentFailsForTargetsWithIncompatibleTargetTypes() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("test-ds");
|
||||
final DistributionSetType dsType = testdataFactory.findOrCreateDistributionSetType("test-ds-type", "dsType");
|
||||
final TargetType targetType = testdataFactory.createTargetType("target-type",
|
||||
@@ -1636,7 +1673,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the DistributionSet assignment fails for target with target type that is not compatible with any dsType.
|
||||
*/
|
||||
@Test void verifyDSAssignmentFailsForTargetsWithTargetTypesThatAreNotCompatibleWithAnyDs() {
|
||||
@Test
|
||||
void verifyDSAssignmentFailsForTargetsWithTargetTypesThatAreNotCompatibleWithAnyDs() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("test-ds");
|
||||
final TargetType emptyTargetType = testdataFactory.createTargetType("target-type", Collections.emptyList());
|
||||
final Target targetWithEmptyType = testdataFactory.createTarget("test-target", "test-target",
|
||||
|
||||
@@ -47,7 +47,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify invalidation of distribution sets that only removes distribution sets from auto assignments
|
||||
*/
|
||||
@Test void verifyInvalidateDistributionSetStopAutoAssignment() {
|
||||
@Test
|
||||
void verifyInvalidateDistributionSetStopAutoAssignment() {
|
||||
final InvalidationTestData invalidationTestData = createInvalidationTestData("verifyInvalidateDistributionSetStopAutoAssignment");
|
||||
|
||||
final DistributionSetInvalidation distributionSetInvalidation = new DistributionSetInvalidation(
|
||||
@@ -76,7 +77,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify invalidation of distribution sets that removes distribution sets from auto assignments and stops rollouts
|
||||
*/
|
||||
@Test void verifyInvalidateDistributionSetStopRollouts() {
|
||||
@Test
|
||||
void verifyInvalidateDistributionSetStopRollouts() {
|
||||
final InvalidationTestData invalidationTestData = createInvalidationTestData(
|
||||
"verifyInvalidateDistributionSetStopRollouts");
|
||||
|
||||
@@ -109,7 +111,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify invalidation of distribution sets that removes distribution sets from auto assignments, stops rollouts and force cancels assignments
|
||||
*/
|
||||
@Test void verifyInvalidateDistributionSetStopAllAndForceCancel() {
|
||||
@Test
|
||||
void verifyInvalidateDistributionSetStopAllAndForceCancel() {
|
||||
final InvalidationTestData invalidationTestData = createInvalidationTestData(
|
||||
"verifyInvalidateDistributionSetStopAllAndForceCancel");
|
||||
|
||||
@@ -140,7 +143,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify invalidation of distribution sets that removes distribution sets from auto assignments, stops rollouts and cancels assignments
|
||||
*/
|
||||
@Test void verifyInvalidateDistributionSetStopAll() {
|
||||
@Test
|
||||
void verifyInvalidateDistributionSetStopAll() {
|
||||
final InvalidationTestData invalidationTestData = createInvalidationTestData(
|
||||
"verifyInvalidateDistributionSetStopAll");
|
||||
|
||||
@@ -168,7 +172,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify that invalidating an incomplete distribution set throws an exception
|
||||
*/
|
||||
@Test void verifyInvalidateIncompleteDistributionSetThrowsException() {
|
||||
@Test
|
||||
void verifyInvalidateIncompleteDistributionSetThrowsException() {
|
||||
final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet();
|
||||
|
||||
final DistributionSetInvalidation distributionSetInvalidation = new DistributionSetInvalidation(
|
||||
@@ -194,7 +199,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify that a user that has authority READ_REPOSITORY and UPDATE_REPOSITORY is allowed to invalidate a distribution set
|
||||
*/
|
||||
@Test @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY" })
|
||||
@Test
|
||||
@WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY" })
|
||||
void verifyInvalidateWithReadAndUpdateRepoAuthority() {
|
||||
final InvalidationTestData invalidationTestData = systemSecurityContext
|
||||
.runAsSystem(() -> createInvalidationTestData("verifyInvalidateWithUpdateRepoAuthority"));
|
||||
@@ -210,7 +216,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify that a user that has authority READ_REPOSITORY, UPDATE_REPOSITORY and UPDATE_TARGET is allowed to invalidate a distribution set only without canceling rollouts
|
||||
*/
|
||||
@Test @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET" })
|
||||
@Test
|
||||
@WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET" })
|
||||
void verifyInvalidateWithReadAndUpdateRepoAndUpdateTargetAuthority() {
|
||||
final InvalidationTestData invalidationTestData = systemSecurityContext.runAsSystem(
|
||||
() -> createInvalidationTestData("verifyInvalidateWithUpdateRepoAndUpdateTargetAuthority"));
|
||||
@@ -232,7 +239,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Verify that a user that has authority READ_REPOSITORY, UPDATE_REPOSITORY, UPDATE_ROLLOUT and UPDATE_TARGET is allowed to invalidate a distribution
|
||||
*/
|
||||
@Test @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET", "UPDATE_ROLLOUT" })
|
||||
@Test
|
||||
@WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET", "UPDATE_ROLLOUT" })
|
||||
void verifyInvalidateWithReadAndUpdateRepoAndUpdateTargetAndUpdateRolloutAuthority() {
|
||||
final InvalidationTestData invalidationTestData = systemSecurityContext.runAsSystem(
|
||||
() -> createInvalidationTestData("verifyInvalidateWithUpdateRepoAndUpdateTargetAuthority"));
|
||||
|
||||
@@ -47,14 +47,16 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignSoftwareModulesPermissionsCheck() {
|
||||
@Test
|
||||
void assignSoftwareModulesPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.assignSoftwareModules(1L, List.of(1L)), List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignTagPermissionsCheck() {
|
||||
@Test
|
||||
void assignTagPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.assignTag(List.of(1L), 1L),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -62,7 +64,8 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests that the method throws InsufficientPermissionException when the user does not have the correct permission
|
||||
*/
|
||||
@Test void unassignTagPermissionsCheck() {
|
||||
@Test
|
||||
void unassignTagPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.unassignTag(List.of(1L), 1L),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -70,7 +73,8 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void createMetadataPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> {
|
||||
distributionSetManagement.createMetadata(1L, Map.of("key", "value"));
|
||||
@@ -82,14 +86,16 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getMetadataPermissiosCheck() {
|
||||
@Test
|
||||
void getMetadataPermissiosCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getMetadata(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updateMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void updateMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
distributionSetManagement.updateMetadata(1L,"key", "value");
|
||||
return null;
|
||||
@@ -100,7 +106,8 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void deleteMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
distributionSetManagement.deleteMetadata(1L, "key");
|
||||
return null;
|
||||
@@ -110,7 +117,8 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void lockPermissionsCheck() {
|
||||
@Test
|
||||
void lockPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
distributionSetManagement.lock(1L);
|
||||
return null;
|
||||
@@ -120,7 +128,8 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unlockPermissionsCheck() {
|
||||
@Test
|
||||
void unlockPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
distributionSetManagement.unlock(1L);
|
||||
return null;
|
||||
@@ -130,63 +139,72 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByActionPermissionsCheck() {
|
||||
@Test
|
||||
void getByActionPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByAction(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getWithDetailsPermissionsCheck() {
|
||||
@Test
|
||||
void getWithDetailsPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getWithDetails(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByNameAndVersionPermissionsCheck() {
|
||||
@Test
|
||||
void getByNameAndVersionPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByNameAndVersion("name", "version"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getValidAndCompletePermissionsCheck() {
|
||||
@Test
|
||||
void getValidAndCompletePermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getValidAndComplete(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getValidPermissionsCheck() {
|
||||
@Test
|
||||
void getValidPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getValid(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getOrElseThrowExceptionPermissionsCheck() {
|
||||
@Test
|
||||
void getOrElseThrowExceptionPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getOrElseThrowException(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByCompletedPermissionsCheck() {
|
||||
@Test
|
||||
void findByCompletedPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByCompleted(true, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByCompletedPermissionsCheck() {
|
||||
@Test
|
||||
void countByCompletedPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.countByCompleted(true), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByDistributionSetFilterPermissionsCheck() {
|
||||
@Test
|
||||
void findByDistributionSetFilterPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByDistributionSetFilter(DistributionSetFilter.builder().build(), PAGE),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -194,7 +212,8 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByDistributionSetFilterPermissionsCheck() {
|
||||
@Test
|
||||
void countByDistributionSetFilterPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.countByDistributionSetFilter(DistributionSetFilter.builder().build()),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -202,63 +221,72 @@ class DistributionSetManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByTagPermissionsCheck() {
|
||||
@Test
|
||||
void findByTagPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlAndTagPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlAndTagPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByRsqlAndTag("rsql", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void isInUsePermissionsCheck() {
|
||||
@Test
|
||||
void isInUsePermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.isInUse(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unassignSoftwareModulePermissionsCheck() {
|
||||
@Test
|
||||
void unassignSoftwareModulePermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.unassignSoftwareModule(1L, 1L), List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByTypeIdPermissionsCheck() {
|
||||
@Test
|
||||
void countByTypeIdPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.countByTypeId(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countRolloutsByStatusForDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void countRolloutsByStatusForDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.countRolloutsByStatusForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countActionsByStatusForDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void countActionsByStatusForDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.countActionsByStatusForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countAutoAssignmentsForDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void countAutoAssignmentsForDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.countAutoAssignmentsForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void invalidatePermissionsCheck() {
|
||||
@Test
|
||||
void invalidatePermissionsCheck() {
|
||||
distributionSetTypeManagement.create(entityFactory.distributionSetType().create().key("type").name("name"));
|
||||
assertPermissions(() -> {
|
||||
distributionSetManagement.invalidate(entityFactory.distributionSet().create().name("name").version("1.0").type("type").build());
|
||||
|
||||
@@ -83,7 +83,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that management get access react as specified on calls for non existing entities by means of Optional not present.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
|
||||
void nonExistingEntityAccessReturnsNotPresent() {
|
||||
@@ -168,7 +169,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a DistributionSet with invalid properties cannot be created or updated
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = DistributionSetUpdatedEvent.class) })
|
||||
@@ -183,7 +185,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that it is not possible to create a DS that already exists (unique constraint is on name,version for DS).
|
||||
*/
|
||||
@Test void createDuplicateDistributionSetsFailsWithException() {
|
||||
@Test
|
||||
void createDuplicateDistributionSetsFailsWithException() {
|
||||
testdataFactory.createDistributionSet("a");
|
||||
|
||||
assertThatThrownBy(() -> testdataFactory.createDistributionSet("a"))
|
||||
@@ -193,7 +196,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a DS is of default type if not specified explicitly at creation time.
|
||||
*/
|
||||
@Test void createDistributionSetWithImplicitType() {
|
||||
@Test
|
||||
void createDistributionSetWithImplicitType() {
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
|
||||
@@ -206,7 +210,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a DS cannot be created if another DS with same name and version exists.
|
||||
*/
|
||||
@Test void createDistributionSetWithDuplicateNameAndVersionFails() {
|
||||
@Test
|
||||
void createDistributionSetWithDuplicateNameAndVersionFails() {
|
||||
final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create().name("newtypesoft").version("1");
|
||||
distributionSetManagement.create(distributionSetCreate);
|
||||
|
||||
@@ -216,7 +221,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that multiple DS are of default type if not specified explicitly at creation time.
|
||||
*/
|
||||
@Test void createMultipleDistributionSetsWithImplicitType() {
|
||||
@Test
|
||||
void createMultipleDistributionSetsWithImplicitType() {
|
||||
final List<DistributionSetCreate> creates = new ArrayList<>(10);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
|
||||
@@ -236,7 +242,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that metadata for a distribution set can be created.
|
||||
*/
|
||||
@Test void createMetadata() {
|
||||
@Test
|
||||
void createMetadata() {
|
||||
final String knownKey = "dsMetaKnownKey";
|
||||
final String knownValue = "dsMetaKnownValue";
|
||||
|
||||
@@ -248,7 +255,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies the enforcement of the metadata quota per distribution set.
|
||||
*/
|
||||
@Test void createMetadataUntilQuotaIsExceeded() {
|
||||
@Test
|
||||
void createMetadataUntilQuotaIsExceeded() {
|
||||
|
||||
// add meta data one by one
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("ds1");
|
||||
@@ -293,7 +301,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that distribution sets can assigned and unassigned to a distribution set tag.
|
||||
*/
|
||||
@Test void assignAndUnassignDistributionSetToTag() {
|
||||
@Test
|
||||
void assignAndUnassignDistributionSetToTag() {
|
||||
final List<Long> assignDS = new ArrayList<>(4);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
||||
@@ -330,7 +339,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that updates concerning the internal software structure of a DS are not possible if the DS is already assigned.
|
||||
*/
|
||||
@Test void updateDistributionSetForbiddenWithIllegalUpdate() {
|
||||
@Test
|
||||
void updateDistributionSetForbiddenWithIllegalUpdate() {
|
||||
// prepare data
|
||||
final Target target = testdataFactory.createTarget();
|
||||
|
||||
@@ -360,7 +370,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that it is not possible to add a software module that is not defined of the DS's type.
|
||||
*/
|
||||
@Test void updateDistributionSetUnsupportedModuleFails() {
|
||||
@Test
|
||||
void updateDistributionSetUnsupportedModuleFails() {
|
||||
final Long setId = distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create()
|
||||
.type(distributionSetTypeManagement.create(
|
||||
@@ -382,7 +393,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Legal updates of a DS, e.g. name or description and module addition, removal while still unassigned.
|
||||
*/
|
||||
@Test void updateDistributionSet() {
|
||||
@Test
|
||||
void updateDistributionSet() {
|
||||
// prepare data
|
||||
DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
||||
@@ -412,7 +424,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to update an invalid distribution set
|
||||
*/
|
||||
@Test void updateInvalidDistributionSet() {
|
||||
@Test
|
||||
void updateInvalidDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet();
|
||||
|
||||
final DistributionSetUpdate update = entityFactory.distributionSet().update(distributionSet.getId()).name("new_name");
|
||||
@@ -423,7 +436,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies the enforcement of the software module quota per distribution set.
|
||||
*/
|
||||
@Test void assignSoftwareModulesUntilQuotaIsExceeded() {
|
||||
@Test
|
||||
void assignSoftwareModulesUntilQuotaIsExceeded() {
|
||||
|
||||
// create some software modules
|
||||
final int maxModules = quotaManagement.getMaxSoftwareModulesPerDistributionSet();
|
||||
@@ -467,7 +481,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to assign software modules to an invalidated distribution set.
|
||||
*/
|
||||
@Test void verifyAssignSoftwareModulesToInvalidDistributionSet() {
|
||||
@Test
|
||||
void verifyAssignSoftwareModulesToInvalidDistributionSet() {
|
||||
final Long distributionSetId = testdataFactory.createAndInvalidateDistributionSet().getId();
|
||||
final List<Long> softwareModuleIds = List.of(testdataFactory.createSoftwareModuleOs().getId());
|
||||
|
||||
@@ -479,7 +494,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to unassign a software module from an invalidated distribution set.
|
||||
*/
|
||||
@Test void verifyUnassignSoftwareModulesToInvalidDistributionSet() {
|
||||
@Test
|
||||
void verifyUnassignSoftwareModulesToInvalidDistributionSet() {
|
||||
final Long distributionSetId = testdataFactory.createDistributionSet().getId();
|
||||
final Long softwareModuleId = testdataFactory.createSoftwareModuleOs().getId();
|
||||
distributionSetManagement.assignSoftwareModules(distributionSetId, singletonList(softwareModuleId));
|
||||
@@ -529,7 +545,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* searches for distribution sets based on the various filter options, e.g. name, version, desc., tags.
|
||||
*/
|
||||
@Test void searchDistributionSetsOnFilters() {
|
||||
@Test
|
||||
void searchDistributionSetsOnFilters() {
|
||||
DistributionSetTag dsTagA = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-A"));
|
||||
final DistributionSetTag dsTagB = distributionSetTagManagement
|
||||
@@ -595,7 +612,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Simple DS load without the related data that should be loaded lazy.
|
||||
*/
|
||||
@Test void findDistributionSetsWithoutLazy() {
|
||||
@Test
|
||||
void findDistributionSetsWithoutLazy() {
|
||||
testdataFactory.createDistributionSets(20);
|
||||
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(20);
|
||||
@@ -604,7 +622,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Locks a DS.
|
||||
*/
|
||||
@Test void lockDistributionSet() {
|
||||
@Test
|
||||
void lockDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
|
||||
assertThat(
|
||||
distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(true))
|
||||
@@ -622,7 +641,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Locked a DS could be hard deleted.
|
||||
*/
|
||||
@Test void deleteUnassignedLockedDistributionSet() {
|
||||
@Test
|
||||
void deleteUnassignedLockedDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
|
||||
distributionSetManagement.lock(distributionSet.getId());
|
||||
assertThat(
|
||||
@@ -637,7 +657,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Locked an assigned DS could be soft deleted.
|
||||
*/
|
||||
@Test void deleteAssignedLockedDistributionSet() {
|
||||
@Test
|
||||
void deleteAssignedLockedDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
|
||||
distributionSetManagement.lock(distributionSet.getId());
|
||||
assertThat(
|
||||
@@ -655,7 +676,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Unlocks a DS.
|
||||
*/
|
||||
@Test void unlockDistributionSet() {
|
||||
@Test
|
||||
void unlockDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
|
||||
distributionSetManagement.lock(distributionSet.getId());
|
||||
assertThat(
|
||||
@@ -676,7 +698,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Software modules of a locked DS can't be modified. Expected behaviour is to throw an exception and to do not modify them.
|
||||
*/
|
||||
@Test void lockDistributionSetApplied() {
|
||||
@Test
|
||||
void lockDistributionSetApplied() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
|
||||
final int softwareModuleCount = distributionSet.getModules().size();
|
||||
assertThat(softwareModuleCount).isNotZero();
|
||||
@@ -706,7 +729,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test implicit locks for a DS and skip tags.
|
||||
*/
|
||||
@Test void isImplicitLockApplicableForDistributionSet() {
|
||||
@Test
|
||||
void isImplicitLockApplicableForDistributionSet() {
|
||||
final JpaDistributionSetManagement distributionSetManagement = (JpaDistributionSetManagement) this.distributionSetManagement;
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-non-skip");
|
||||
// assert that implicit lock is applicable for non skip tags
|
||||
@@ -734,7 +758,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Locks an incomplete DS. Expected behaviour is to throw an exception and to do not lock it.
|
||||
*/
|
||||
@Test void lockIncompleteDistributionSetFails() {
|
||||
@Test
|
||||
void lockIncompleteDistributionSetFails() {
|
||||
final long incompleteDistributionSetId = testdataFactory.createIncompleteDistributionSet().getId();
|
||||
assertThatExceptionOfType(IncompleteDistributionSetException.class)
|
||||
.as("Locking an incomplete distribution set should throw an exception")
|
||||
@@ -747,7 +772,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Deletes a DS that is no in use. Expected behaviour is a hard delete on the database.
|
||||
*/
|
||||
@Test void deleteUnassignedDistributionSet() {
|
||||
@Test
|
||||
void deleteUnassignedDistributionSet() {
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("ds-1");
|
||||
testdataFactory.createDistributionSet("ds-2");
|
||||
|
||||
@@ -762,7 +788,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Deletes an invalid distribution set
|
||||
*/
|
||||
@Test void deleteInvalidDistributionSet() {
|
||||
@Test
|
||||
void deleteInvalidDistributionSet() {
|
||||
final DistributionSet set = testdataFactory.createAndInvalidateDistributionSet();
|
||||
assertThat(distributionSetRepository.findById(set.getId())).isNotEmpty();
|
||||
distributionSetManagement.delete(set.getId());
|
||||
@@ -772,7 +799,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Deletes an incomplete distribution set
|
||||
*/
|
||||
@Test void deleteIncompleteDistributionSet() {
|
||||
@Test
|
||||
void deleteIncompleteDistributionSet() {
|
||||
final DistributionSet set = testdataFactory.createIncompleteDistributionSet();
|
||||
assertThat(distributionSetRepository.findById(set.getId())).isNotEmpty();
|
||||
distributionSetManagement.delete(set.getId());
|
||||
@@ -782,7 +810,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Queries and loads the metadata related to a given distribution set.
|
||||
*/
|
||||
@Test void getMetadata() {
|
||||
@Test
|
||||
void getMetadata() {
|
||||
// create a DS
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("testDs1");
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("testDs2");
|
||||
@@ -832,7 +861,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the find all by ids contains the entities which are looking for
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 12),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 36) })
|
||||
void verifyFindDistributionSetAllById() {
|
||||
@@ -855,7 +885,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that an exception is thrown when trying to get an invalid distribution set
|
||||
*/
|
||||
@Test void verifyGetValid() {
|
||||
@Test
|
||||
void verifyGetValid() {
|
||||
final Long distributionSetId = testdataFactory.createAndInvalidateDistributionSet().getId();
|
||||
|
||||
assertThatExceptionOfType(InvalidDistributionSetException.class)
|
||||
@@ -869,7 +900,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that an exception is thrown when trying to get an incomplete distribution set
|
||||
*/
|
||||
@Test void verifyGetValidAndComplete() {
|
||||
@Test
|
||||
void verifyGetValidAndComplete() {
|
||||
final Long distributionSetId = testdataFactory.createIncompleteDistributionSet().getId();
|
||||
assertThatExceptionOfType(IncompleteDistributionSetException.class)
|
||||
.as("Incomplete distributionSet should throw an exception")
|
||||
@@ -879,7 +911,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that an exception is thrown when trying to create or update metadata for an invalid distribution set.
|
||||
*/
|
||||
@Test void createMetadataForInvalidDistributionSet() {
|
||||
@Test
|
||||
void createMetadataForInvalidDistributionSet() {
|
||||
final String knownKey1 = "myKnownKey1";
|
||||
final String knownKey2 = "myKnownKey2";
|
||||
final String knownValue = "myKnownValue";
|
||||
@@ -905,7 +938,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Get the Rollouts count by status statistics for a specific Distribution Set
|
||||
*/
|
||||
@Test void getRolloutsCountStatisticsForDistributionSet() {
|
||||
@Test
|
||||
void getRolloutsCountStatisticsForDistributionSet() {
|
||||
DistributionSet ds1 = testdataFactory.createDistributionSet("DS1");
|
||||
DistributionSet ds2 = testdataFactory.createDistributionSet("DS2");
|
||||
DistributionSet ds3 = testdataFactory.createDistributionSet("DS3");
|
||||
@@ -935,7 +969,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Get the Rollouts count by status statistics for a specific Distribution Set
|
||||
*/
|
||||
@Test void getActionsCountStatisticsForDistributionSet() {
|
||||
@Test
|
||||
void getActionsCountStatisticsForDistributionSet() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("DS");
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("DS2");
|
||||
testdataFactory.createTargets("targets", 4);
|
||||
@@ -955,7 +990,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Get the Rollouts count by status statistics for a specific Distribution Set
|
||||
*/
|
||||
@Test void getAutoAssignmentsCountStatisticsForDistributionSet() {
|
||||
@Test
|
||||
void getAutoAssignmentsCountStatisticsForDistributionSet() {
|
||||
DistributionSet ds = testdataFactory.createDistributionSet("DS");
|
||||
DistributionSet ds2 = testdataFactory.createDistributionSet("DS2");
|
||||
testdataFactory.createTargets("targets", 4);
|
||||
|
||||
@@ -45,14 +45,16 @@ class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagem
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByNameWitPermissionWorks() {
|
||||
@Test
|
||||
void getByNameWitPermissionWorks() {
|
||||
assertPermissions(() -> distributionSetTagManagement.findByName("tagName"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void findByDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(1L, Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -60,7 +62,8 @@ class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagem
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteDistributionSetTagPermissionsCheck() {
|
||||
@Test
|
||||
void deleteDistributionSetTagPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
distributionSetTagManagement.delete("tagName");
|
||||
return null;
|
||||
|
||||
@@ -52,7 +52,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that management get access reacts as specified on calls for non existing entities by means of Optional not present.
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(distributionSetTagManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
@@ -77,7 +78,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Full DS tag lifecycle tested. Create tags, assign them to sets and delete the tags.
|
||||
*/
|
||||
@Test void createAndAssignAndDeleteDistributionSetTags() {
|
||||
@Test
|
||||
void createAndAssignAndDeleteDistributionSetTags() {
|
||||
final Collection<DistributionSet> dsAs = testdataFactory.createDistributionSets("DS-A", 20);
|
||||
final Collection<DistributionSet> dsBs = testdataFactory.createDistributionSets("DS-B", 10);
|
||||
final Collection<DistributionSet> dsCs = testdataFactory.createDistributionSets("DS-C", 25);
|
||||
@@ -140,7 +142,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies assign/unassign.
|
||||
*/
|
||||
@Test void assignAndUnassignDistributionSetTags() {
|
||||
@Test
|
||||
void assignAndUnassignDistributionSetTags() {
|
||||
final Collection<DistributionSet> groupA = testdataFactory.createDistributionSets(20);
|
||||
final Collection<DistributionSet> groupB = testdataFactory.createDistributionSets("unassigned", 20);
|
||||
|
||||
@@ -181,7 +184,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that tagging of set containing missing DS throws meaningful and correct exception.
|
||||
*/
|
||||
@Test void failOnMissingDs() {
|
||||
@Test
|
||||
void failOnMissingDs() {
|
||||
final Collection<Long> group = testdataFactory.createDistributionSets(5).stream().map(DistributionSet::getId).toList();
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
final List<Long> missing = new ArrayList<>();
|
||||
@@ -210,7 +214,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a created tag is persisted in the repository as defined.
|
||||
*/
|
||||
@Test void createDistributionSetTag() {
|
||||
@Test
|
||||
void createDistributionSetTag() {
|
||||
final Tag tag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
@@ -225,7 +230,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a deleted tag is removed from the repository as defined.
|
||||
*/
|
||||
@Test void deleteDistributionSetTag() {
|
||||
@Test
|
||||
void deleteDistributionSetTag() {
|
||||
// create test data
|
||||
final Iterable<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
final DistributionSetTag toDelete = tags.iterator().next();
|
||||
@@ -253,7 +259,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).
|
||||
*/
|
||||
@Test void failedDuplicateDsTagNameException() {
|
||||
@Test
|
||||
void failedDuplicateDsTagNameException() {
|
||||
final TagCreate tag = entityFactory.tag().create().name("A");
|
||||
distributionSetTagManagement.create(tag);
|
||||
|
||||
@@ -264,7 +271,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).
|
||||
*/
|
||||
@Test void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
||||
@Test
|
||||
void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
|
||||
@@ -276,7 +284,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the name update of a target tag.
|
||||
*/
|
||||
@Test void updateDistributionSetTag() {
|
||||
@Test
|
||||
void updateDistributionSetTag() {
|
||||
// create test data
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
// change data
|
||||
@@ -293,7 +302,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that all tags are retrieved through repository.
|
||||
*/
|
||||
@Test void findDistributionSetTagsAll() {
|
||||
@Test
|
||||
void findDistributionSetTagsAll() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
// test
|
||||
@@ -305,7 +315,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a created tags are persisted in the repository as defined.
|
||||
*/
|
||||
@Test void createDistributionSetTags() {
|
||||
@Test
|
||||
void createDistributionSetTags() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
||||
}
|
||||
|
||||
@@ -45,21 +45,24 @@ class DistributionSetTypeManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByKeyPermissionsCheck() {
|
||||
@Test
|
||||
void getByKeyPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByNamePermissionsCheck() {
|
||||
@Test
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignOptionalSoftwareModuleTypesPermissionsCheck() {
|
||||
@Test
|
||||
void assignOptionalSoftwareModuleTypesPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(1L, List.of(1L)),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
@@ -67,7 +70,8 @@ class DistributionSetTypeManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignMandatorySoftwareModuleTypesPermissionsCheck() {
|
||||
@Test
|
||||
void assignMandatorySoftwareModuleTypesPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(1L, List.of(1L)),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
@@ -75,7 +79,8 @@ class DistributionSetTypeManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unassignSoftwareModuleTypePermissionsCheck() {
|
||||
@Test
|
||||
void unassignSoftwareModuleTypePermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.unassignSoftwareModuleType(1L, 1L), List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a DistributionSet with invalid properties cannot be created or updated
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = DistributionSetUpdatedEvent.class, count = 0) })
|
||||
@@ -112,7 +113,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the successful module update of unused distribution set type which is in fact allowed.
|
||||
*/
|
||||
@Test void updateUnassignedDistributionSetTypeModules() {
|
||||
@Test
|
||||
void updateUnassignedDistributionSetTypeModules() {
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
@@ -138,7 +140,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the quota for software module types per distribution set type is enforced as expected.
|
||||
*/
|
||||
@Test void quotaMaxSoftwareModuleTypes() {
|
||||
@Test
|
||||
void quotaMaxSoftwareModuleTypes() {
|
||||
final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType();
|
||||
// create software module types
|
||||
final List<Long> moduleTypeIds = new ArrayList<>();
|
||||
@@ -186,7 +189,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the successfull update of used distribution set type meta data which is in fact allowed.
|
||||
*/
|
||||
@Test void updateAssignedDistributionSetTypeMetaData() {
|
||||
@Test
|
||||
void updateAssignedDistributionSetTypeMetaData() {
|
||||
final DistributionSetType nonUpdatableType = createDistributionSetTypeUsedByDs();
|
||||
|
||||
distributionSetTypeManagement.update(
|
||||
@@ -200,7 +204,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the unsuccessful update of used distribution set type (module addition).
|
||||
*/
|
||||
@Test void addModuleToAssignedDistributionSetTypeFails() {
|
||||
@Test
|
||||
void addModuleToAssignedDistributionSetTypeFails() {
|
||||
final Long nonUpdatableTypeId = createDistributionSetTypeUsedByDs().getId();
|
||||
final Set<Long> osTypeId = Set.of(osType.getId());
|
||||
assertThatThrownBy(() -> distributionSetTypeManagement
|
||||
@@ -211,7 +216,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the unsuccessful update of used distribution set type (module removal).
|
||||
*/
|
||||
@Test void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
@Test
|
||||
void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
@@ -229,7 +235,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the successfull deletion of unused (hard delete) distribution set types.
|
||||
*/
|
||||
@Test void deleteUnassignedDistributionSetType() {
|
||||
@Test
|
||||
void deleteUnassignedDistributionSetType() {
|
||||
final JpaDistributionSetType hardDelete = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
|
||||
@@ -242,7 +249,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the successfull deletion of used (soft delete) distribution set types.
|
||||
*/
|
||||
@Test void deleteAssignedDistributionSetType() {
|
||||
@Test
|
||||
void deleteAssignedDistributionSetType() {
|
||||
final int existing = (int) distributionSetTypeManagement.count();
|
||||
final JpaDistributionSetType toBeDeleted = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
@@ -263,7 +271,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that when no SoftwareModules are assigned to a Distribution then the DistributionSet is not complete.
|
||||
*/
|
||||
@Test void shouldFailWhenDistributionSetHasNoSoftwareModulesAssigned() {
|
||||
@Test
|
||||
void shouldFailWhenDistributionSetHasNoSoftwareModulesAssigned() {
|
||||
|
||||
final JpaDistributionSetType jpaDistributionSetType = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("newType").name("new Type"));
|
||||
|
||||
@@ -39,7 +39,8 @@ class LazyControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that lazy target poll update is executed as specified.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 2) })
|
||||
void lazyFindOrRegisterTargetIfItDoesNotExist() throws InterruptedException {
|
||||
|
||||
@@ -24,49 +24,56 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getPermissionsCheck() {
|
||||
@Test
|
||||
void getPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.get(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getWithDetailedStatusPermissionsCheck() {
|
||||
@Test
|
||||
void getWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.getWithDetailedStatus(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByRolloutPermissionsCheck() {
|
||||
@Test
|
||||
void countByRolloutPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.countByRollout(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countTargetsOfRolloutsGroupPermissionsCheck() {
|
||||
@Test
|
||||
void countTargetsOfRolloutsGroupPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.countTargetsOfRolloutsGroup(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRolloutPermissionsCheck() {
|
||||
@Test
|
||||
void findByRolloutPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findByRollout(1L, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRolloutAndRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByRolloutAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsql(1L, "name==*", PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findTargetsOfRolloutGroupPermissionsCheck() {
|
||||
@Test
|
||||
void findTargetsOfRolloutGroupPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(1L, PAGE),
|
||||
List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -74,7 +81,8 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findTargetsOfRolloutGroupByRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findTargetsOfRolloutGroupByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(1L, "name==*", PAGE),
|
||||
List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -82,7 +90,8 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() {
|
||||
@Test
|
||||
void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(1L, "name==*", PAGE),
|
||||
List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
@@ -90,7 +99,8 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRolloutWithDetailedStatusPermissionsCheck() {
|
||||
@Test
|
||||
void findByRolloutWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(1L, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the rollout group status mapping.
|
||||
*/
|
||||
@Test void testRolloutGroupStatusConvert() {
|
||||
@Test
|
||||
void testRolloutGroupStatusConvert() {
|
||||
final long id = rolloutGroupRepository.findByRolloutId(
|
||||
testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId(), PAGE).getContent()
|
||||
.get(0).getId();
|
||||
|
||||
@@ -47,7 +47,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies a simple rollout flow
|
||||
*/
|
||||
@Test void rolloutFlow() {
|
||||
@Test
|
||||
void rolloutFlow() {
|
||||
final String rolloutName = "rollout-std";
|
||||
final int amountGroups = 5; // static only
|
||||
final String targetPrefix = "controller-rollout-std-";
|
||||
@@ -88,7 +89,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies a simple dynamic rollout flow
|
||||
*/
|
||||
@Test void dynamicRolloutFlow() {
|
||||
@Test
|
||||
void dynamicRolloutFlow() {
|
||||
final String rolloutName = "dynamic-rollout-std";
|
||||
final int amountGroups = 2; // static only
|
||||
final String targetPrefix = "controller-dynamic-rollout-std-";
|
||||
@@ -203,7 +205,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies a simple dynamic rollout flow with a dynamic group template
|
||||
*/
|
||||
@Test void dynamicRolloutTemplateFlow() {
|
||||
@Test
|
||||
void dynamicRolloutTemplateFlow() {
|
||||
final String rolloutName = "dynamic-template-rollout-std";
|
||||
final int amountGroups = 3; // static only
|
||||
final String targetPrefix = "controller-template-dynamic-rollout-std-";
|
||||
@@ -302,7 +305,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies a simple pure (no static groups) dynamic rollout flow with a dynamic group template
|
||||
*/
|
||||
@Test void dynamicRolloutPureFlow() {
|
||||
@Test
|
||||
void dynamicRolloutPureFlow() {
|
||||
final String rolloutName = "pure-dynamic-rollout-std";
|
||||
final String targetPrefix = "controller-pure-dynamic-rollout-std-";
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName);
|
||||
@@ -384,7 +388,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies a simple rollout flow
|
||||
*/
|
||||
@Test void rollout0ThresholdFlow() {
|
||||
@Test
|
||||
void rollout0ThresholdFlow() {
|
||||
final String rolloutName = "rollout-std-0threshold";
|
||||
final int amountGroups = 5; // static only
|
||||
final String targetPrefix = "controller-rollout-std-0threshold-";
|
||||
|
||||
@@ -35,28 +35,32 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getPermissionsCheck() {
|
||||
@Test
|
||||
void getPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.get(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByNamePermissionsCheck() {
|
||||
@Test
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.getByName("name"), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getWithDetailedStatusPermissionsCheck() {
|
||||
@Test
|
||||
void getWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.getWithDetailedStatus(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void approveOrDenyPermissionsCheck() {
|
||||
@Test
|
||||
void approveOrDenyPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.approveOrDeny(1L, Rollout.ApprovalDecision.APPROVED), List.of(SpPermission.APPROVE_ROLLOUT));
|
||||
assertPermissions(() -> rolloutManagement.approveOrDeny(1L, Rollout.ApprovalDecision.APPROVED, "comment"),
|
||||
List.of(SpPermission.APPROVE_ROLLOUT));
|
||||
@@ -65,7 +69,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void pauseRolloutPermissionsCheck() {
|
||||
@Test
|
||||
void pauseRolloutPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
rolloutManagement.pauseRollout(1L);
|
||||
return null;
|
||||
@@ -75,7 +80,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void resumeRolloutPermissionsCheck() {
|
||||
@Test
|
||||
void resumeRolloutPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
rolloutManagement.resumeRollout(1L);
|
||||
return null;
|
||||
@@ -85,14 +91,16 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findActiveRolloutsPermissionsCheck() {
|
||||
@Test
|
||||
void findActiveRolloutsPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findActiveRollouts(), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void cancelRolloutsForDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void cancelRolloutsForDistributionSetPermissionsCheck() {
|
||||
final DistributionSetTypeCreate key = entityFactory.distributionSetType().create().name("type").key("type");
|
||||
distributionSetTypeManagement.create(key);
|
||||
final DistributionSetCreate dsCreate = entityFactory.distributionSet().create().name("name").version("1.0.0").type("type");
|
||||
@@ -106,21 +114,24 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countPermissionsCheck() {
|
||||
@Test
|
||||
void countPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.count(), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByDistributionSetIdAndRolloutIsStoppablePermissionsCheck() {
|
||||
@Test
|
||||
void countByDistributionSetIdAndRolloutIsStoppablePermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.countByDistributionSetIdAndRolloutIsStoppable(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createPermissionsCheck() {
|
||||
@Test
|
||||
void createPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.create(entityFactory.rollout().create().distributionSetId(1L), 1, false,
|
||||
new RolloutGroupConditionBuilder().withDefaults().build()), List.of(SpPermission.CREATE_ROLLOUT, SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> rolloutManagement.create(entityFactory.rollout().create().distributionSetId(1L), 1, false,
|
||||
@@ -136,28 +147,32 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findAllPermissionsCheck() {
|
||||
@Test
|
||||
void findAllPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findAll(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findByRsql("id==1", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findAllWithDetailedStatusPermissionsCheck() {
|
||||
@Test
|
||||
void findAllWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlWithDetailedStatusPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() ->
|
||||
rolloutManagement.findByRsqlWithDetailedStatus("name==*", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
@@ -165,21 +180,24 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void startPermissionsCheck() {
|
||||
@Test
|
||||
void startPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.start(1L), List.of(SpPermission.HANDLE_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updatePermissionsCheck() {
|
||||
@Test
|
||||
void updatePermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.update(entityFactory.rollout().update(1L)), List.of(SpPermission.UPDATE_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deletePermissionsCheck() {
|
||||
@Test
|
||||
void deletePermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
rolloutManagement.delete(1L);
|
||||
return null;
|
||||
@@ -189,7 +207,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void triggerNextGroupPermissionsCheck() {
|
||||
@Test
|
||||
void triggerNextGroupPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
rolloutManagement.triggerNextGroup(1L);
|
||||
return null;
|
||||
@@ -218,7 +237,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test @WithUser(principal = "user", authorities = { SpPermission.READ_ROLLOUT })
|
||||
@Test
|
||||
@WithUser(principal = "user", authorities = { SpPermission.READ_ROLLOUT })
|
||||
void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(1L, "name==*", PAGE),
|
||||
List.of(SpPermission.READ_ROLLOUT));
|
||||
@@ -227,7 +247,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRolloutWithDetailedStatusPermissionsCheck() {
|
||||
@Test
|
||||
void findByRolloutWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(1L, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Dynamic group doesn't override newer static group assignments
|
||||
*/
|
||||
@Test void dynamicGroupDoesntOverrideItsOrNewerStaticGroups() {
|
||||
@Test
|
||||
void dynamicGroupDoesntOverrideItsOrNewerStaticGroups() {
|
||||
final int amountGroups = 1; // static only
|
||||
final String targetPrefix = "controller-dynamic-rollout-";
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds");
|
||||
@@ -176,7 +177,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a running action with distribution-set (A) is not canceled by a rollout which tries to also assign a distribution-set (A)
|
||||
*/
|
||||
@Test void rolloutShouldNotCancelRunningActionWithTheSameDistributionSet() {
|
||||
@Test
|
||||
void rolloutShouldNotCancelRunningActionWithTheSameDistributionSet() {
|
||||
// manually assign distribution set to target
|
||||
final String knownControllerId = "controller12345";
|
||||
final DistributionSet knownDistributionSet = testdataFactory.createDistributionSet();
|
||||
@@ -242,7 +244,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that a running action is auto canceled by a rollout which assigns another distribution-set.
|
||||
*/
|
||||
@Test void rolloutAssignsNewDistributionSetAndAutoCloseActiveActions() {
|
||||
@Test
|
||||
void rolloutAssignsNewDistributionSetAndAutoCloseActiveActions() {
|
||||
tenantConfigurationManagement
|
||||
.addOrUpdateConfiguration(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, true);
|
||||
|
||||
@@ -328,7 +331,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying that the rollout is created correctly, executing the filter and split up the targets in the correct group size.
|
||||
*/
|
||||
@Test void creatingRolloutIsCorrectPersisted() {
|
||||
@Test
|
||||
void creatingRolloutIsCorrectPersisted() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
final int amountGroups = 5;
|
||||
@@ -348,7 +352,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying that when the rollout is started the actions for all targets in the rollout is created and the state of the first group is running as well as the corresponding actions
|
||||
*/
|
||||
@Test void startRolloutSetFirstGroupAndActionsInRunningStateAndOthersInScheduleState() {
|
||||
@Test
|
||||
void startRolloutSetFirstGroupAndActionsInRunningStateAndOthersInScheduleState() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
final int amountGroups = 5;
|
||||
@@ -385,7 +390,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying that a finish condition of a group is hit the next group of the rollout is also started
|
||||
*/
|
||||
@Test void checkRunningRolloutsDoesNotStartNextGroupIfFinishConditionIsNotHit() {
|
||||
@Test
|
||||
void checkRunningRolloutsDoesNotStartNextGroupIfFinishConditionIsNotHit() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
final int amountGroups = 5;
|
||||
@@ -428,7 +434,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying that next group is started when targets of the group have been deleted.
|
||||
*/
|
||||
@Test void checkRunningRolloutsStartsNextGroupIfTargetsDeleted() {
|
||||
@Test
|
||||
void checkRunningRolloutsStartsNextGroupIfTargetsDeleted() {
|
||||
final int amountTargetsForRollout = 15;
|
||||
final int amountOtherTargets = 0;
|
||||
final int amountGroups = 3;
|
||||
@@ -449,7 +456,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying that the error handling action of a group is executed to pause the current rollout
|
||||
*/
|
||||
@Test void checkErrorHitOfGroupCallsErrorActionToPauseTheRollout() {
|
||||
@Test
|
||||
void checkErrorHitOfGroupCallsErrorActionToPauseTheRollout() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
final int amountGroups = 5;
|
||||
@@ -494,7 +502,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying a paused rollout in case of error action hit can be resumed again
|
||||
*/
|
||||
@Test void errorActionPausesRolloutAndRolloutGetsResumedStartsNextScheduledGroup() {
|
||||
@Test
|
||||
void errorActionPausesRolloutAndRolloutGetsResumedStartsNextScheduledGroup() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
final int amountGroups = 5;
|
||||
@@ -547,7 +556,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying that the rollout is starting group after group and gets finished at the end
|
||||
*/
|
||||
@Test void rolloutStartsGroupAfterGroupAndGetsFinished() {
|
||||
@Test
|
||||
void rolloutStartsGroupAfterGroupAndGetsFinished() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
final int amountGroups = 5;
|
||||
@@ -586,7 +596,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the targets have the right status during the rollout.
|
||||
*/
|
||||
@Test void countCorrectStatusForEachTargetDuringRollout() {
|
||||
@Test
|
||||
void countCorrectStatusForEachTargetDuringRollout() {
|
||||
|
||||
final int amountTargetsForRollout = 8;
|
||||
final int amountOtherTargets = 15;
|
||||
@@ -651,7 +662,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the targets have the right status during a download_only rollout.
|
||||
*/
|
||||
@Test void countCorrectStatusForEachTargetDuringDownloadOnlyRollout() {
|
||||
@Test
|
||||
void countCorrectStatusForEachTargetDuringDownloadOnlyRollout() {
|
||||
|
||||
final int amountTargetsForRollout = 8;
|
||||
final int amountOtherTargets = 15;
|
||||
@@ -720,7 +732,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the targets have the right status during the rollout when an error emerges.
|
||||
*/
|
||||
@Test void countCorrectStatusForEachTargetDuringRolloutWithError() {
|
||||
@Test
|
||||
void countCorrectStatusForEachTargetDuringRolloutWithError() {
|
||||
|
||||
final int amountTargetsForRollout = 8;
|
||||
final int amountOtherTargets = 15;
|
||||
@@ -759,7 +772,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the targets have the right status during the rollout when receiving the status of rollout groups.
|
||||
*/
|
||||
@Test void countCorrectStatusForEachTargetGroupDuringRollout() {
|
||||
@Test
|
||||
void countCorrectStatusForEachTargetGroupDuringRollout() {
|
||||
|
||||
final int amountTargetsForRollout = 9;
|
||||
final int amountOtherTargets = 15;
|
||||
@@ -802,7 +816,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that target actions of rollout get canceled when a manuel distribution sets assignment is done.
|
||||
*/
|
||||
@Test void targetsOfRolloutGetsManuelDsAssignment() {
|
||||
@Test
|
||||
void targetsOfRolloutGetsManuelDsAssignment() {
|
||||
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 0;
|
||||
@@ -847,7 +862,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that target actions of a rollout get cancelled when another rollout with same targets gets started.
|
||||
*/
|
||||
@Test void targetsOfRolloutGetDistributionSetAssignmentByOtherRollout() {
|
||||
@Test
|
||||
void targetsOfRolloutGetDistributionSetAssignmentByOtherRollout() {
|
||||
|
||||
final int amountTargetsForRollout = 15;
|
||||
final int amountOtherTargets = 5;
|
||||
@@ -890,7 +906,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that error status of DistributionSet installation during rollout can get rerun with second rollout so that all targets have some DistributionSet installed at the end.
|
||||
*/
|
||||
@Test void startSecondRolloutAfterFirstRolloutEndsWithErrors() {
|
||||
@Test
|
||||
void startSecondRolloutAfterFirstRolloutEndsWithErrors() {
|
||||
|
||||
final int amountTargetsForRollout = 15;
|
||||
final int amountOtherTargets = 0;
|
||||
@@ -950,7 +967,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the rollout moves to the next group when the success condition was achieved and the error condition was not exceeded.
|
||||
*/
|
||||
@Test void successConditionAchievedAndErrorConditionNotExceeded() {
|
||||
@Test
|
||||
void successConditionAchievedAndErrorConditionNotExceeded() {
|
||||
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 0;
|
||||
@@ -977,7 +995,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the rollout does not move to the next group when the success condition was not achieved.
|
||||
*/
|
||||
@Test void successConditionNotAchieved() {
|
||||
@Test
|
||||
void successConditionNotAchieved() {
|
||||
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 0;
|
||||
@@ -1004,7 +1023,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the rollout pauses when the error condition was exceeded.
|
||||
*/
|
||||
@Test void errorConditionExceeded() {
|
||||
@Test
|
||||
void errorConditionExceeded() {
|
||||
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 0;
|
||||
@@ -1027,7 +1047,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that all rollouts are return with expected target statuses.
|
||||
*/
|
||||
@Test void findAllRolloutsWithDetailedStatus() {
|
||||
@Test
|
||||
void findAllRolloutsWithDetailedStatus() {
|
||||
|
||||
final int amountTargetsForRollout = 12;
|
||||
final int amountGroups = 2;
|
||||
@@ -1104,7 +1125,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the count of existing rollouts.
|
||||
*/
|
||||
@Test void rightCountForAllRollouts() {
|
||||
@Test
|
||||
void rightCountForAllRollouts() {
|
||||
|
||||
final int amountTargetsForRollout = 6;
|
||||
final int amountGroups = 2;
|
||||
@@ -1121,7 +1143,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the filtering and sorting ascending for rollout is working correctly.
|
||||
*/
|
||||
@Test void findRolloutByFilters() {
|
||||
@Test
|
||||
void findRolloutByFilters() {
|
||||
final int amountTargetsForRollout = 6;
|
||||
final int amountGroups = 2;
|
||||
final String successCondition = "50";
|
||||
@@ -1149,7 +1172,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the expected rollout is found by name.
|
||||
*/
|
||||
@Test void findRolloutByName() {
|
||||
@Test
|
||||
void findRolloutByName() {
|
||||
|
||||
final int amountTargetsForRollout = 12;
|
||||
final int amountGroups = 2;
|
||||
@@ -1167,7 +1191,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the percent count is acting like aspected when targets move to the status finished or error.
|
||||
*/
|
||||
@Test void getFinishedPercentForRunningGroup() {
|
||||
@Test
|
||||
void getFinishedPercentForRunningGroup() {
|
||||
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountGroups = 2;
|
||||
@@ -1214,7 +1239,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the expected targets are returned for the rollout groups.
|
||||
*/
|
||||
@Test void findRolloutGroupTargetsWithRsqlParam() {
|
||||
@Test
|
||||
void findRolloutGroupTargetsWithRsqlParam() {
|
||||
|
||||
final int amountTargetsForRollout = 15;
|
||||
final int amountGroups = 3;
|
||||
@@ -1266,7 +1292,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the creation of a Rollout without targets throws an Exception.
|
||||
*/
|
||||
@Test void createRolloutNotMatchingTargets() {
|
||||
@Test
|
||||
void createRolloutNotMatchingTargets() {
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
@@ -1284,7 +1311,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the creation of a Rollout with the same name throws an Exception.
|
||||
*/
|
||||
@Test void createDuplicateRollout() {
|
||||
@Test
|
||||
void createDuplicateRollout() {
|
||||
final int amountGroups = 5;
|
||||
final int amountTargetsForRollout = 10;
|
||||
final String successCondition = "50";
|
||||
@@ -1306,7 +1334,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the creation and the start of a Rollout with more groups than targets.
|
||||
*/
|
||||
@Test void createAndStartRolloutWithEmptyGroups() {
|
||||
@Test
|
||||
void createAndStartRolloutWithEmptyGroups() {
|
||||
final int amountTargetsForRollout = 3;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
@@ -1352,7 +1381,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the creation and the start of a rollout.
|
||||
*/
|
||||
@Test void createAndStartRollout() {
|
||||
@Test
|
||||
void createAndStartRollout() {
|
||||
|
||||
final int amountTargetsForRollout = 50;
|
||||
final int amountGroups = 5;
|
||||
@@ -1391,7 +1421,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the creation and the start of a rollout.
|
||||
*/
|
||||
@Test void createScheduledRollout() throws Exception {
|
||||
@Test
|
||||
void createScheduledRollout() throws Exception {
|
||||
final String rolloutName = "scheduledRolloutTest";
|
||||
testdataFactory.createTargets(50, rolloutName + "-", rolloutName);
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName);
|
||||
@@ -1451,7 +1482,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a rollout cannot be created if the 'max targets per rollout group' quota is violated.
|
||||
*/
|
||||
@Test void createRolloutFailsIfQuotaGroupQuotaIsViolated() {
|
||||
@Test
|
||||
void createRolloutFailsIfQuotaGroupQuotaIsViolated() {
|
||||
|
||||
final int maxTargets = quotaManagement.getMaxTargetsPerRolloutGroup();
|
||||
|
||||
@@ -1479,7 +1511,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a rollout cannot be created based on group definitions if the 'max targets per rollout group' quota is violated for one of the groups.
|
||||
*/
|
||||
@Test void createRolloutWithGroupDefinitionsFailsIfQuotaGroupQuotaIsViolated() {
|
||||
@Test
|
||||
void createRolloutWithGroupDefinitionsFailsIfQuotaGroupQuotaIsViolated() {
|
||||
final int maxTargets = quotaManagement.getMaxTargetsPerRolloutGroup();
|
||||
|
||||
final int amountTargetsForRollout = maxTargets * 2 + 2;
|
||||
@@ -1526,7 +1559,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the update of a rollout
|
||||
*/
|
||||
@Test void updateRollout() {
|
||||
@Test
|
||||
void updateRollout() {
|
||||
final int amountTargetsForRollout = 50;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
@@ -1555,7 +1589,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the creation of a rollout with a groups definition.
|
||||
*/
|
||||
@Test void createRolloutWithGroupDefinition() throws Exception {
|
||||
@Test
|
||||
void createRolloutWithGroupDefinition() throws Exception {
|
||||
final String rolloutName = "rolloutTest3";
|
||||
|
||||
final int amountTargetsInGroup1 = 10;
|
||||
@@ -1616,7 +1651,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify rollout execution with advanced group definition and confirmation flow active.
|
||||
*/
|
||||
@Test void createRolloutWithGroupDefinitionAndConfirmationFlowActive() {
|
||||
@Test
|
||||
void createRolloutWithGroupDefinitionAndConfirmationFlowActive() {
|
||||
final String rolloutName = "rolloutTest4";
|
||||
|
||||
final int amountTargetsInGroup1 = 10;
|
||||
@@ -1693,7 +1729,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify rollout creation fails if group definition does not address all targets
|
||||
*/
|
||||
@Test void createRolloutWithGroupsNotMatchingTargets() {
|
||||
@Test
|
||||
void createRolloutWithGroupsNotMatchingTargets() {
|
||||
final String rolloutName = "rolloutTest4";
|
||||
final int amountTargetsForRollout = 500;
|
||||
final int percentTargetsInGroup1 = 20;
|
||||
@@ -1715,7 +1752,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify rollout creation fails if group definition specifies illegal target percentage
|
||||
*/
|
||||
@Test void createRolloutWithIllegalPercentage() {
|
||||
@Test
|
||||
void createRolloutWithIllegalPercentage() {
|
||||
final String rolloutName = "rolloutTest6";
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int percentTargetsInGroup1 = 101;
|
||||
@@ -1737,7 +1775,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify rollout creation fails if the 'max rollout groups per rollout' quota is violated.
|
||||
*/
|
||||
@Test void createRolloutWithIllegalAmountOfGroups() {
|
||||
@Test
|
||||
void createRolloutWithIllegalAmountOfGroups() {
|
||||
final String rolloutName = "rolloutTest5";
|
||||
final int targets = 10;
|
||||
final int maxGroups = quotaManagement.getMaxRolloutGroupsPerRollout();
|
||||
@@ -1753,7 +1792,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the start of a Rollout does not work during creation phase.
|
||||
*/
|
||||
@Test void createAndStartRolloutDuringCreationFails() {
|
||||
@Test
|
||||
void createAndStartRolloutDuringCreationFails() {
|
||||
final int amountTargetsForRollout = 3;
|
||||
final int amountGroups = 5;
|
||||
final String successCondition = "50";
|
||||
@@ -1813,7 +1853,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Approving a rollout leads to transition to READY state.
|
||||
*/
|
||||
@Test void approvedRolloutTransitionsToReadyState() {
|
||||
@Test
|
||||
void approvedRolloutTransitionsToReadyState() {
|
||||
approvalStrategy.setApprovalNeeded(true);
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
@@ -1829,7 +1870,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Denying approval for a rollout leads to transition to APPROVAL_DENIED state.
|
||||
*/
|
||||
@Test void deniedRolloutTransitionsToApprovalDeniedState() {
|
||||
@Test
|
||||
void deniedRolloutTransitionsToApprovalDeniedState() {
|
||||
approvalStrategy.setApprovalNeeded(true);
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
@@ -1942,7 +1984,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that returned result considers provided sort parameter.
|
||||
*/
|
||||
@Test void findAllRolloutsConsidersSorting() {
|
||||
@Test
|
||||
void findAllRolloutsConsidersSorting() {
|
||||
final String randomString = randomString(5);
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet(randomString + "-testDs");
|
||||
testdataFactory.createTargets(10, randomString + "-testTarget-");
|
||||
@@ -1982,7 +2025,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Creating a rollout without weight value when multi assignment in enabled.
|
||||
*/
|
||||
@Test void weightNotRequiredInMultiAssignmentMode() {
|
||||
@Test
|
||||
void weightNotRequiredInMultiAssignmentMode() {
|
||||
enableMultiAssignments();
|
||||
final Rollout rollout = testdataFactory.createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, 2, "50",
|
||||
"80",
|
||||
@@ -1993,7 +2037,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Creating a rollout with a weight causes an error when multi assignment in disabled.
|
||||
*/
|
||||
@Test void weightAllowedWhenMultiAssignmentModeNotEnabled() {
|
||||
@Test
|
||||
void weightAllowedWhenMultiAssignmentModeNotEnabled() {
|
||||
assertThat(
|
||||
testdataFactory.createSimpleTestRolloutWithTargetsAndDistributionSet(
|
||||
10, 10, 2, "50", "80", ActionType.FORCED, 66))
|
||||
@@ -2003,7 +2048,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Weight is validated and saved to the Rollout.
|
||||
*/
|
||||
@Test void weightValidatedAndSaved() {
|
||||
@Test
|
||||
void weightValidatedAndSaved() {
|
||||
final String targetPrefix = UUID.randomUUID().toString();
|
||||
testdataFactory.createTargets(4, targetPrefix);
|
||||
enableMultiAssignments();
|
||||
@@ -2032,7 +2078,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* A Rollout with weight creates actions with weights
|
||||
*/
|
||||
@Test void actionsWithWeightAreCreated() {
|
||||
@Test
|
||||
void actionsWithWeightAreCreated() {
|
||||
final int amountOfTargets = 5;
|
||||
final int weight = 99;
|
||||
enableMultiAssignments();
|
||||
@@ -2050,7 +2097,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Rollout can be created without weight in single assignment and be started in multi assignment
|
||||
*/
|
||||
@Test void createInSingleStartInMultiassignMode() {
|
||||
@Test
|
||||
void createInSingleStartInMultiassignMode() {
|
||||
final int amountOfTargets = 5;
|
||||
final Long rolloutId = testdataFactory.createSimpleTestRolloutWithTargetsAndDistributionSet(amountOfTargets, 2,
|
||||
amountOfTargets,
|
||||
@@ -2067,7 +2115,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to create a rollout with an invalidated distribution set.
|
||||
*/
|
||||
@Test void createRolloutWithInvalidDistributionSet() {
|
||||
@Test
|
||||
void createRolloutWithInvalidDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet();
|
||||
|
||||
assertThatExceptionOfType(InvalidDistributionSetException.class)
|
||||
@@ -2079,7 +2128,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to create a rollout with an incomplete distribution set.
|
||||
*/
|
||||
@Test void createRolloutWithIncompleteDistributionSet() {
|
||||
@Test
|
||||
void createRolloutWithIncompleteDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet();
|
||||
|
||||
assertThatExceptionOfType(IncompleteDistributionSetException.class)
|
||||
@@ -2091,7 +2141,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify the that only compatible targets are part of a Rollout.
|
||||
*/
|
||||
@Test void createAndStartRolloutWithTargetTypes() {
|
||||
@Test
|
||||
void createAndStartRolloutWithTargetTypes() {
|
||||
final String rolloutName = "rolloutTestCompatibility";
|
||||
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet("test-ds");
|
||||
@@ -2135,7 +2186,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifying that next group is started on manual trigger next group.
|
||||
*/
|
||||
@Test void checkRunningRolloutsManualTriggerNextGroup() {
|
||||
@Test
|
||||
void checkRunningRolloutsManualTriggerNextGroup() {
|
||||
final int amountTargetsForRollout = 15;
|
||||
final int amountOtherTargets = 0;
|
||||
final int amountGroups = 3;
|
||||
@@ -2178,7 +2230,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the rollout status mapping.
|
||||
*/
|
||||
@Test void testRolloutStatusConvert() {
|
||||
@Test
|
||||
void testRolloutStatusConvert() {
|
||||
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
|
||||
for (final RolloutStatus status : RolloutStatus.values()) {
|
||||
final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow());
|
||||
@@ -2191,7 +2244,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the rollout action type mapping.
|
||||
*/
|
||||
@Test void testActionTypeConvert() {
|
||||
@Test
|
||||
void testActionTypeConvert() {
|
||||
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
|
||||
for (final ActionType actionType : ActionType.values()) {
|
||||
final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow());
|
||||
@@ -2204,7 +2258,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Trigger next rollout group if rollout is in wrong state
|
||||
*/
|
||||
@Test void triggeringNextGroupRolloutWrongState() {
|
||||
@Test
|
||||
void triggeringNextGroupRolloutWrongState() {
|
||||
|
||||
final int amountTargetsForRollout = 15;
|
||||
final int amountOtherTargets = 0;
|
||||
|
||||
@@ -44,7 +44,8 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createMetaDataPermissionsCheck() {
|
||||
@Test
|
||||
void createMetaDataPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> softwareModuleManagement.updateMetadata(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value")),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
@@ -58,7 +59,8 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteMetaDataPermissionsCheck() {
|
||||
@Test
|
||||
void deleteMetaDataPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
softwareModuleManagement.deleteMetadata(1L, "key");
|
||||
return null;
|
||||
@@ -68,21 +70,24 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByAssignedToPermissionsCheck() {
|
||||
@Test
|
||||
void findByAssignedToPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findByAssignedTo(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByAssignedToPermissionsCheck() {
|
||||
@Test
|
||||
void countByAssignedToPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.countByAssignedTo(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByTextAndTypePermissionsCheck() {
|
||||
@Test
|
||||
void findByTextAndTypePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findByTextAndType("text", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -95,21 +100,24 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||
@Test
|
||||
void getMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.getMetadata(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||
@Test
|
||||
void findMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.getMetadata(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() {
|
||||
@Test
|
||||
void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(1L, PAGE),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -117,14 +125,16 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByTypePermissionsCheck() {
|
||||
@Test
|
||||
void findByTypePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findByType(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void lockPermissionsCheck() {
|
||||
@Test
|
||||
void lockPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
softwareModuleManagement.lock(1L);
|
||||
return null;
|
||||
@@ -134,7 +144,8 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unlockPermissionsCheck() {
|
||||
@Test
|
||||
void unlockPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
softwareModuleManagement.unlock(1L);
|
||||
return null;
|
||||
@@ -144,7 +155,8 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updateMetaDataPermissionsCheck() {
|
||||
@Test
|
||||
void updateMetaDataPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> softwareModuleManagement.updateMetadata(entityFactory.softwareModuleMetadata().update(1L, "key").value("value")),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
@@ -153,7 +165,8 @@ class SoftwareManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findMetaDataBySoftwareModuleIdsAndTargetVisiblePermissionsCheck() {
|
||||
@Test
|
||||
void findMetaDataBySoftwareModuleIdsAndTargetVisiblePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdsAndTargetVisible(List.of(1L)),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -128,7 +128,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.
|
||||
*/
|
||||
@Test void updateNothingResultsInUnchangedRepository() {
|
||||
@Test
|
||||
void updateNothingResultsInUnchangedRepository() {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
@@ -142,7 +143,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Calling update for changed fields results in change in the repository.
|
||||
*/
|
||||
@Test void updateSoftwareModuleFieldsToNewValue() {
|
||||
@Test
|
||||
void updateSoftwareModuleFieldsToNewValue() {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
@@ -158,7 +160,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Create Software Module call fails when called for existing entity.
|
||||
*/
|
||||
@Test void createModuleCallFailsForExistingModule() {
|
||||
@Test
|
||||
void createModuleCallFailsForExistingModule() {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.as("Should not have worked as module already exists.")
|
||||
@@ -168,7 +171,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* searched for software modules based on the various filter options, e.g. name,desc,type, version.
|
||||
*/
|
||||
@Test void findSoftwareModuleByFilters() {
|
||||
@Test
|
||||
void findSoftwareModuleByFilters() {
|
||||
final SoftwareModule ah = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.1"));
|
||||
final SoftwareModule jvm = softwareModuleManagement
|
||||
@@ -211,7 +215,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Searches for software modules based on a list of IDs.
|
||||
*/
|
||||
@Test void findSoftwareModulesById() {
|
||||
@Test
|
||||
void findSoftwareModulesById() {
|
||||
|
||||
final List<Long> modules = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(),
|
||||
testdataFactory.createSoftwareModuleApp().getId(), 624355263L);
|
||||
@@ -222,7 +227,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Searches for software modules by type.
|
||||
*/
|
||||
@Test void findSoftwareModulesByType() {
|
||||
@Test
|
||||
void findSoftwareModulesByType() {
|
||||
// found in test
|
||||
final SoftwareModule one = testdataFactory.createSoftwareModuleOs("one");
|
||||
final SoftwareModule two = testdataFactory.createSoftwareModuleOs("two");
|
||||
@@ -238,7 +244,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Counts all software modules in the repsitory that are not marked as deleted.
|
||||
*/
|
||||
@Test void countSoftwareModulesAll() {
|
||||
@Test
|
||||
void countSoftwareModulesAll() {
|
||||
// found in test
|
||||
testdataFactory.createSoftwareModuleOs("one");
|
||||
testdataFactory.createSoftwareModuleOs("two");
|
||||
@@ -253,7 +260,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Deletes an artifact, which is not assigned to a Distribution Set
|
||||
*/
|
||||
@Test void hardDeleteOfNotAssignedArtifact() {
|
||||
@Test
|
||||
void hardDeleteOfNotAssignedArtifact() {
|
||||
|
||||
// [STEP1]: Create SoftwareModuleX with Artifacts
|
||||
final SoftwareModule unassignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
|
||||
@@ -280,7 +288,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Deletes an artifact, which is assigned to a DistributionSet
|
||||
*/
|
||||
@Test void softDeleteOfAssignedArtifact() {
|
||||
@Test
|
||||
void softDeleteOfAssignedArtifact() {
|
||||
// [STEP1]: Create SoftwareModuleX with ArtifactX
|
||||
SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
|
||||
|
||||
@@ -313,7 +322,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Delete an artifact, which has been assigned to a rolled out DistributionSet in the past
|
||||
*/
|
||||
@Test void softDeleteOfHistoricalAssignedArtifact() {
|
||||
@Test
|
||||
void softDeleteOfHistoricalAssignedArtifact() {
|
||||
|
||||
// Init target
|
||||
final Target target = testdataFactory.createTarget();
|
||||
@@ -354,7 +364,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Delete an software module with an artifact, which is also used by another software module.
|
||||
*/
|
||||
@Test void deleteSoftwareModulesWithSharedArtifact() {
|
||||
@Test
|
||||
void deleteSoftwareModulesWithSharedArtifact() {
|
||||
|
||||
// Init artifact binary data, target and DistributionSets
|
||||
final int artifactSize = 1024;
|
||||
@@ -401,7 +412,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Delete two assigned softwaremodules which share an artifact.
|
||||
*/
|
||||
@Test void deleteMultipleSoftwareModulesWhichShareAnArtifact() {
|
||||
@Test
|
||||
void deleteMultipleSoftwareModulesWhichShareAnArtifact() {
|
||||
// Init artifact binary data, target and DistributionSets
|
||||
final int artifactSize = 1024;
|
||||
final byte[] source = randomBytes(artifactSize);
|
||||
@@ -461,7 +473,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that all undeleted software modules are found in the repository.
|
||||
*/
|
||||
@Test void countSoftwareModuleTypesAll() {
|
||||
@Test
|
||||
void countSoftwareModuleTypesAll() {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
// one soft deleted
|
||||
@@ -476,7 +489,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that software modules are returned that are assigned to given DS.
|
||||
*/
|
||||
@Test void findSoftwareModuleByAssignedTo() {
|
||||
@Test
|
||||
void findSoftwareModuleByAssignedTo() {
|
||||
// test modules
|
||||
final SoftwareModule one = testdataFactory.createSoftwareModuleOs();
|
||||
testdataFactory.createSoftwareModuleOs("notassigned");
|
||||
@@ -494,7 +508,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that metadata for a software module can be created.
|
||||
*/
|
||||
@Test void createSoftwareModuleMetadata() {
|
||||
@Test
|
||||
void createSoftwareModuleMetadata() {
|
||||
final String knownKey1 = "myKnownKey1";
|
||||
final String knownValue1 = "myKnownValue1";
|
||||
|
||||
@@ -537,7 +552,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies the enforcement of the metadata quota per software module.
|
||||
*/
|
||||
@Test void createSoftwareModuleMetadataUntilQuotaIsExceeded() {
|
||||
@Test
|
||||
void createSoftwareModuleMetadataUntilQuotaIsExceeded() {
|
||||
|
||||
// add meta data one by one
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp("m1");
|
||||
@@ -585,7 +601,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that metadata for a software module cannot be created for an existing key.
|
||||
*/
|
||||
@Test void createSoftwareModuleMetadataFailsIfKeyExists() {
|
||||
@Test
|
||||
void createSoftwareModuleMetadataFailsIfKeyExists() {
|
||||
|
||||
final String knownKey1 = "myKnownKey1";
|
||||
final String knownValue1 = "myKnownValue1";
|
||||
@@ -657,7 +674,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that existing metadata can be deleted.
|
||||
*/
|
||||
@Test void deleteSoftwareModuleMetadata() {
|
||||
@Test
|
||||
void deleteSoftwareModuleMetadata() {
|
||||
final String knownKey1 = "myKnownKey1";
|
||||
final String knownValue1 = "myKnownValue1";
|
||||
|
||||
@@ -680,7 +698,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that non existing metadata find results in exception.
|
||||
*/
|
||||
@Test void findSoftwareModuleMetadataFailsIfEntryDoesNotExist() {
|
||||
@Test
|
||||
void findSoftwareModuleMetadataFailsIfEntryDoesNotExist() {
|
||||
final String knownKey1 = "myKnownKey1";
|
||||
final String knownValue1 = "myKnownValue1";
|
||||
|
||||
@@ -696,7 +715,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Queries and loads the metadata related to a given software module.
|
||||
*/
|
||||
@Test void findAllSoftwareModuleMetadataBySwId() {
|
||||
@Test
|
||||
void findAllSoftwareModuleMetadataBySwId() {
|
||||
final SoftwareModule sw1 = testdataFactory.createSoftwareModuleApp();
|
||||
final int metadataCountSw1 = 8;
|
||||
|
||||
@@ -731,7 +751,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Locks a SM.
|
||||
*/
|
||||
@Test void lockSoftwareModule() {
|
||||
@Test
|
||||
void lockSoftwareModule() {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("sm-1");
|
||||
assertThat(
|
||||
softwareModuleManagement.get(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(true))
|
||||
@@ -745,7 +766,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Unlocks a SM.
|
||||
*/
|
||||
@Test void unlockSoftwareModule() {
|
||||
@Test
|
||||
void unlockSoftwareModule() {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("sm-1");
|
||||
softwareModuleManagement.lock(softwareModule.getId());
|
||||
assertThat(
|
||||
@@ -760,7 +782,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Artifacts of a locked SM can't be modified. Expected behaviour is to throw an exception and to do not modify them.
|
||||
*/
|
||||
@Test void lockSoftwareModuleApplied() {
|
||||
@Test
|
||||
void lockSoftwareModuleApplied() {
|
||||
final Long softwareModuleId = testdataFactory.createSoftwareModule("sm-1").getId();
|
||||
artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(new byte[] { 1 }), softwareModuleId, "artifact1", false, 1));
|
||||
@@ -796,7 +819,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Artifacts of a locked SM can't be modified. Expected behaviour is to throw an exception and to do not modify them.
|
||||
*/
|
||||
@Test void lockedContainingDistributionSetApplied() {
|
||||
@Test
|
||||
void lockedContainingDistributionSetApplied() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
|
||||
final List<SoftwareModule> modules = distributionSet.getModules().stream().toList();
|
||||
assertThat(modules).hasSizeGreaterThan(1);
|
||||
|
||||
@@ -45,14 +45,16 @@ class SoftwareModuleTypeManagementSecurityTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByKeyPermissionsCheck() {
|
||||
@Test
|
||||
void getByKeyPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByNamePermissionsCheck() {
|
||||
@Test
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.
|
||||
*/
|
||||
@Test void updateNothingResultsInUnchangedRepositoryForType() {
|
||||
@Test
|
||||
void updateNothingResultsInUnchangedRepositoryForType() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
|
||||
@@ -78,7 +79,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Calling update for changed fields results in change in the repository.
|
||||
*/
|
||||
@Test void updateSoftwareModuleTypeFieldsToNewValue() {
|
||||
@Test
|
||||
void updateSoftwareModuleTypeFieldsToNewValue() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
|
||||
@@ -94,7 +96,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Create Software Module Types call fails when called for existing entities.
|
||||
*/
|
||||
@Test void createModuleTypesCallFailsForExistingTypes() {
|
||||
@Test
|
||||
void createModuleTypesCallFailsForExistingTypes() {
|
||||
final List<SoftwareModuleTypeCreate> created = Arrays.asList(
|
||||
entityFactory.softwareModuleType().create().key("test-key").name("test-name"),
|
||||
entityFactory.softwareModuleType().create().key("test-key2").name("test-name2"));
|
||||
@@ -107,7 +110,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).
|
||||
*/
|
||||
@Test void deleteAssignedAndUnassignedSoftwareModuleTypes() {
|
||||
@Test
|
||||
void deleteAssignedAndUnassignedSoftwareModuleTypes() {
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
|
||||
SoftwareModuleType type = softwareModuleTypeManagement
|
||||
@@ -144,7 +148,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that software module typeis found based on given name.
|
||||
*/
|
||||
@Test void findSoftwareModuleTypeByName() {
|
||||
@Test
|
||||
void findSoftwareModuleTypeByName() {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
final SoftwareModuleType found = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
@@ -157,7 +162,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that it is not possible to create a type that alrady exists.
|
||||
*/
|
||||
@Test void createSoftwareModuleTypeFailsWithExistingEntity() {
|
||||
@Test
|
||||
void createSoftwareModuleTypeFailsWithExistingEntity() {
|
||||
final SoftwareModuleTypeCreate create = entityFactory.softwareModuleType().create().key("thetype").name("thename");
|
||||
softwareModuleTypeManagement.create(create);
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
@@ -169,7 +175,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that it is not possible to create a list of types where one already exists.
|
||||
*/
|
||||
@Test void createSoftwareModuleTypesFailsWithExistingEntity() {
|
||||
@Test
|
||||
void createSoftwareModuleTypesFailsWithExistingEntity() {
|
||||
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
final List<SoftwareModuleTypeCreate> creates = List.of(
|
||||
entityFactory.softwareModuleType().create().key("thetype").name("thename"),
|
||||
@@ -182,7 +189,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the creation of a softwareModuleType is failing because of invalid max assignment
|
||||
*/
|
||||
@Test void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() {
|
||||
@Test
|
||||
void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() {
|
||||
final SoftwareModuleTypeCreate create = entityFactory.softwareModuleType().create().key("type").name("name").maxAssignments(0);
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("should not have worked as max assignment is invalid. Should be greater than 0")
|
||||
@@ -192,7 +200,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that multiple types are created as requested.
|
||||
*/
|
||||
@Test void createMultipleSoftwareModuleTypes() {
|
||||
@Test
|
||||
void createMultipleSoftwareModuleTypes() {
|
||||
final List<SoftwareModuleType> created = softwareModuleTypeManagement
|
||||
.create(Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),
|
||||
entityFactory.softwareModuleType().create().key("thetype2").name("thename2")));
|
||||
|
||||
@@ -26,14 +26,16 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findTenantsPermissionWorks() {
|
||||
@Test
|
||||
void findTenantsPermissionWorks() {
|
||||
assertPermissions(() -> systemManagement.findTenants(PAGE), List.of(SpPermission.SYSTEM_ADMIN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteTenantPermissionsCheck() {
|
||||
@Test
|
||||
void deleteTenantPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
systemManagement.deleteTenant("tenant");
|
||||
return null;
|
||||
@@ -43,7 +45,8 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void forEachTenantTenantPermissionsCheck() {
|
||||
@Test
|
||||
void forEachTenantTenantPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
systemManagement.forEachTenant(log::info);
|
||||
return null;
|
||||
@@ -53,21 +56,24 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getSystemUsageStatisticsWithTenantsPermissionsCheck() {
|
||||
@Test
|
||||
void getSystemUsageStatisticsWithTenantsPermissionsCheck() {
|
||||
assertPermissions(() -> systemManagement.getSystemUsageStatisticsWithTenants(), List.of(SpPermission.SYSTEM_ADMIN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getSystemUsageStatisticsPermissionsCheck() {
|
||||
@Test
|
||||
void getSystemUsageStatisticsPermissionsCheck() {
|
||||
assertPermissions(() -> systemManagement.getSystemUsageStatistics(), List.of(SpPermission.SYSTEM_ADMIN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getTenantMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void getTenantMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_TARGET), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_TENANT_CONFIGURATION), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
@@ -77,7 +83,8 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getTenantMetadataWithoutDetailsPermissionsCheck() {
|
||||
@Test
|
||||
void getTenantMetadataWithoutDetailsPermissionsCheck() {
|
||||
assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_TARGET), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_TENANT_CONFIGURATION), List.of(SpPermission.CREATE_REPOSITORY));
|
||||
@@ -87,21 +94,24 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getTenantMetadataByTenantPermissionsCheck() {
|
||||
@Test
|
||||
void getTenantMetadataByTenantPermissionsCheck() {
|
||||
assertPermissions(() -> systemManagement.getTenantMetadata(1L), List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createTenantMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void createTenantMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> systemManagement.createTenantMetadata("tenant"), List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updateTenantMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void updateTenantMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> systemManagement.updateTenantMetadata(1L), List.of(SpPermission.TENANT_CONFIGURATION));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that findTenants returns all tenants and not only restricted to the tenant which currently is logged in
|
||||
*/
|
||||
@Test void findTenantsReturnsAllTenantsNotOnlyWhichLoggedIn() throws Exception {
|
||||
@Test
|
||||
void findTenantsReturnsAllTenantsNotOnlyWhichLoggedIn() throws Exception {
|
||||
assertThat(systemManagement.findTenants(PAGE).getContent()).hasSize(1);
|
||||
|
||||
createTestTenantsForSystemStatistics(2, 0, 0, 0);
|
||||
@@ -48,7 +49,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that getSystemUsageStatisticsWithTenants returns the usage of all tenants and not only the first 1000 (max page size).
|
||||
*/
|
||||
@Test void systemUsageReportCollectsStatisticsOfManyTenants() throws Exception {
|
||||
@Test
|
||||
void systemUsageReportCollectsStatisticsOfManyTenants() throws Exception {
|
||||
// Prepare tenants
|
||||
createTestTenantsForSystemStatistics(1050, 0, 0, 0);
|
||||
|
||||
@@ -59,7 +61,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that the system report calculates correctly the artifact size of all tenants in the system. It ignores deleted software modules with their artifacts.
|
||||
*/
|
||||
@Test void systemUsageReportCollectsArtifactsOfAllTenants() throws Exception {
|
||||
@Test
|
||||
void systemUsageReportCollectsArtifactsOfAllTenants() throws Exception {
|
||||
// Prepare tenants
|
||||
createTestTenantsForSystemStatistics(2, 1234, 0, 0);
|
||||
|
||||
@@ -84,7 +87,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that the system report calculates correctly the targets size of all tenants in the system
|
||||
*/
|
||||
@Test void systemUsageReportCollectsTargetsOfAllTenants() throws Exception {
|
||||
@Test
|
||||
void systemUsageReportCollectsTargetsOfAllTenants() throws Exception {
|
||||
// Prepare tenants
|
||||
createTestTenantsForSystemStatistics(2, 0, 100, 0);
|
||||
|
||||
@@ -105,7 +109,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that the system report calculates correctly the actions size of all tenants in the system
|
||||
*/
|
||||
@Test void systemUsageReportCollectsActionsOfAllTenants() throws Exception {
|
||||
@Test
|
||||
void systemUsageReportCollectsActionsOfAllTenants() throws Exception {
|
||||
// Prepare tenants
|
||||
createTestTenantsForSystemStatistics(2, 0, 20, 2);
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createPermissionsCheck() {
|
||||
@Test
|
||||
void createPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("name").query("controllerId==id")),
|
||||
List.of(SpPermission.CREATE_TARGET));
|
||||
@@ -34,7 +35,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deletePermissionsCheck() {
|
||||
@Test
|
||||
void deletePermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetFilterQueryManagement.delete(1L);
|
||||
return null;
|
||||
@@ -44,7 +46,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void verifyTargetFilterQuerySyntaxPermissionsCheck() {
|
||||
@Test
|
||||
void verifyTargetFilterQuerySyntaxPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.verifyTargetFilterQuerySyntax("controllerId==id"),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -52,56 +55,64 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findAllPermissionsCheck() {
|
||||
@Test
|
||||
void findAllPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countPermissionsCheck() {
|
||||
@Test
|
||||
void countPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.count(), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByAutoAssignDistributionSetIdPermissionsCheck() {
|
||||
@Test
|
||||
void countByAutoAssignDistributionSetIdPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.countByAutoAssignDistributionSetId(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByNamePermissionsCheck() {
|
||||
@Test
|
||||
void findByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByName("filterName", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByNamePermissionsCheck() {
|
||||
@Test
|
||||
void countByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.countByName("filterName"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByRsql("name==id", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByQueryPermissionsCheck() {
|
||||
@Test
|
||||
void findByQueryPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByQuery("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByAutoAssignDistributionSetIdPermissionsCheck() {
|
||||
@Test
|
||||
void findByAutoAssignDistributionSetIdPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(1L, PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -109,7 +120,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByAutoAssignDSAndRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByAutoAssignDSAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(1L, "rsqlParam", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -117,28 +129,32 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findWithAutoAssignDSPermissionsCheck() {
|
||||
@Test
|
||||
void findWithAutoAssignDSPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findWithAutoAssignDS(PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getTargetFilterQueryByIdPermissionsCheck() {
|
||||
@Test
|
||||
void getTargetFilterQueryByIdPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.get(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getTargetFilterQueryByNamePermissionsCheck() {
|
||||
@Test
|
||||
void getTargetFilterQueryByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.getByName("filterName"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updatePermissionsCheck() {
|
||||
@Test
|
||||
void updatePermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.update(entityFactory.targetFilterQuery().update(1L)),
|
||||
List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
@@ -146,7 +162,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updateAutoAssignDSPermissionsCheck() {
|
||||
@Test
|
||||
void updateAutoAssignDSPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.updateAutoAssignDS(new AutoAssignDistributionSetUpdate(1L).weight(1)),
|
||||
List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
@@ -154,7 +171,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void cancelAutoAssignmentForDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void cancelAutoAssignmentForDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetFilterQueryManagement.cancelAutoAssignmentForDistributionSet(1L);
|
||||
return null;
|
||||
|
||||
@@ -65,7 +65,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that management get access reacts as specfied on calls for non existing entities by means of Optional not present.
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(targetFilterQueryManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(targetFilterQueryManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
@@ -74,7 +75,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that management queries react as specfied on calls for non existing entities by means of throwing EntityNotFoundException.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = TargetFilterQueryCreatedEvent.class, count = 1) })
|
||||
@@ -110,7 +112,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test creation of target filter query.
|
||||
*/
|
||||
@Test void createTargetFilterQuery() {
|
||||
@Test
|
||||
void createTargetFilterQuery() {
|
||||
final String filterName = "new target filter";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
@@ -121,7 +124,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Create a target filter query with an auto-assign distribution set and a query string that addresses too many targets.
|
||||
*/
|
||||
@Test void createTargetFilterQueryThatExceedsQuota() {
|
||||
@Test
|
||||
void createTargetFilterQueryThatExceedsQuota() {
|
||||
|
||||
// create targets
|
||||
final int maxTargets = quotaManagement.getMaxTargetsPerAutoAssignment();
|
||||
@@ -138,7 +142,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test searching a target filter query.
|
||||
*/
|
||||
@Test void searchTargetFilterQuery() {
|
||||
@Test
|
||||
void searchTargetFilterQuery() {
|
||||
final String filterName = "targetFilterQueryName";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
@@ -155,7 +160,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test searching a target filter query with an invalid filter.
|
||||
*/
|
||||
@Test void searchTargetFilterQueryInvalidField() {
|
||||
@Test
|
||||
void searchTargetFilterQueryInvalidField() {
|
||||
final PageRequest pageRequest = PageRequest.of(0, 10);
|
||||
Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.isThrownBy(() -> targetFilterQueryManagement.findByRsql("unknownField==testValue", pageRequest));
|
||||
@@ -164,7 +170,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks if the EntityAlreadyExistsException is thrown if a targetFilterQuery with the same name are created more than once.
|
||||
*/
|
||||
@Test void createDuplicateTargetFilterQuery() {
|
||||
@Test
|
||||
void createDuplicateTargetFilterQuery() {
|
||||
final String filterName = "new target filter duplicate";
|
||||
final TargetFilterQueryCreate targetFilterQueryCreate = entityFactory.targetFilterQuery().create()
|
||||
.name(filterName).query("name==PendingTargets001");
|
||||
@@ -179,7 +186,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test deletion of target filter query.
|
||||
*/
|
||||
@Test void deleteTargetFilterQuery() {
|
||||
@Test
|
||||
void deleteTargetFilterQuery() {
|
||||
final String filterName = "delete_target_filter_query";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(entityFactory.targetFilterQuery()
|
||||
.create().name(filterName).query("name==PendingTargets001"));
|
||||
@@ -192,7 +200,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test update of a target filter query.
|
||||
*/
|
||||
@Test void updateTargetFilterQuery() {
|
||||
@Test
|
||||
void updateTargetFilterQuery() {
|
||||
final String filterName = "target_filter_01";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
@@ -206,7 +215,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test assigning a distribution set for auto assignment with different action types
|
||||
*/
|
||||
@Test void assignDistributionSet() {
|
||||
@Test
|
||||
void assignDistributionSet() {
|
||||
final String filterName = "target_filter_02";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
@@ -223,7 +233,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Assigns a distribution set to an existing filter query and verifies that the quota 'max targets per auto assignment' is enforced.
|
||||
*/
|
||||
@Test void assignDistributionSetToTargetFilterQueryThatExceedsQuota() {
|
||||
@Test
|
||||
void assignDistributionSetToTargetFilterQueryThatExceedsQuota() {
|
||||
// create targets
|
||||
final int maxTargets = quotaManagement.getMaxTargetsPerAutoAssignment();
|
||||
testdataFactory.createTargets(maxTargets + 1, "target%s");
|
||||
@@ -244,7 +255,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Updates an existing filter query with a query string that addresses too many targets.
|
||||
*/
|
||||
@Test void updateTargetFilterQueryWithQueryThatExceedsQuota() {
|
||||
@Test
|
||||
void updateTargetFilterQueryWithQueryThatExceedsQuota() {
|
||||
// create targets
|
||||
final int maxTargets = quotaManagement.getMaxTargetsPerAutoAssignment();
|
||||
testdataFactory.createTargets(maxTargets + 1, "target%s");
|
||||
@@ -264,7 +276,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test removing distribution set while it has a relation to a target filter query
|
||||
*/
|
||||
@Test void removeAssignDistributionSet() {
|
||||
@Test
|
||||
void removeAssignDistributionSet() {
|
||||
final String filterName = "target_filter_03";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
@@ -292,7 +305,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test to implicitly remove the auto assign distribution set when the ds is soft deleted
|
||||
*/
|
||||
@Test void implicitlyRemoveAssignDistributionSet() {
|
||||
@Test
|
||||
void implicitlyRemoveAssignDistributionSet() {
|
||||
final String filterName = "target_filter_03";
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("dist_set");
|
||||
final Target target = testdataFactory.createTarget();
|
||||
@@ -327,7 +341,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test finding and auto assign distribution set
|
||||
*/
|
||||
@Test void findFiltersWithDistributionSet() {
|
||||
@Test
|
||||
void findFiltersWithDistributionSet() {
|
||||
final String filterName = "d";
|
||||
assertEquals(0L, targetFilterQueryManagement.count());
|
||||
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("a").query("name==*"));
|
||||
@@ -359,7 +374,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Creating or updating a target filter query with autoassignment and no-value weight when multi assignment in enabled.
|
||||
*/
|
||||
@Test void weightNotRequiredInMultiAssignmentMode() {
|
||||
@Test
|
||||
void weightNotRequiredInMultiAssignmentMode() {
|
||||
enableMultiAssignments();
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
final Long filterId = targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("a").query("name==*")).getId();
|
||||
@@ -377,7 +393,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Creating or updating a target filter query with autoassignment with a weight causes an error when multi assignment in disabled.
|
||||
*/
|
||||
@Test void weightAllowedWhenMultiAssignmentModeNotEnabled() {
|
||||
@Test
|
||||
void weightAllowedWhenMultiAssignmentModeNotEnabled() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
final Long filterId = targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("a").query("name==*")).getId();
|
||||
|
||||
@@ -395,7 +412,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Auto assignment can be removed from filter when multi assignment in enabled.
|
||||
*/
|
||||
@Test void removeDsFromFilterWhenMultiAssignmentModeNotEnabled() {
|
||||
@Test
|
||||
void removeDsFromFilterWhenMultiAssignmentModeNotEnabled() {
|
||||
enableMultiAssignments();
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
final Long filterId = targetFilterQueryManagement.create(
|
||||
@@ -409,7 +427,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Weight is validated and saved to the Filter.
|
||||
*/
|
||||
@Test void weightValidatedAndSaved() {
|
||||
@Test
|
||||
void weightValidatedAndSaved() {
|
||||
enableMultiAssignments();
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
|
||||
@@ -440,7 +459,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to create a target filter with an invalidated distribution set.
|
||||
*/
|
||||
@Test void createTargetFilterWithInvalidDistributionSet() {
|
||||
@Test
|
||||
void createTargetFilterWithInvalidDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet();
|
||||
|
||||
final TargetFilterQueryCreate targetFilterQueryCreate = entityFactory.targetFilterQuery().create()
|
||||
@@ -453,7 +473,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to create a target filter with an incomplete distribution set.
|
||||
*/
|
||||
@Test void createTargetFilterWithIncompleteDistributionSet() {
|
||||
@Test
|
||||
void createTargetFilterWithIncompleteDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet();
|
||||
|
||||
final TargetFilterQueryCreate targetFilterQueryCreate = entityFactory.targetFilterQuery().create()
|
||||
@@ -467,7 +488,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to update a target filter with an invalidated distribution set.
|
||||
*/
|
||||
@Test void updateAutoAssignDsWithInvalidDistributionSet() {
|
||||
@Test
|
||||
void updateAutoAssignDsWithInvalidDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name("updateAutoAssignDsWithInvalidDistributionSet")
|
||||
@@ -484,7 +506,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that an exception is thrown when trying to update a target filter with an incomplete distribution set.
|
||||
*/
|
||||
@Test void updateAutoAssignDsWithIncompleteDistributionSet() {
|
||||
@Test
|
||||
void updateAutoAssignDsWithIncompleteDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("updateAutoAssignDsWithIncompleteDistributionSet")
|
||||
@@ -501,7 +524,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the auto assign action type mapping.
|
||||
*/
|
||||
@Test void testAutoAssignActionTypeConvert() {
|
||||
@Test
|
||||
void testAutoAssignActionTypeConvert() {
|
||||
for (final ActionType actionType : ActionType.values()) {
|
||||
final Supplier<Long> create = () ->
|
||||
targetFilterQueryManagement.create(
|
||||
|
||||
@@ -40,7 +40,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that targets with given target type are returned from repository.
|
||||
*/
|
||||
@Test void findTargetByTargetType() {
|
||||
@Test
|
||||
void findTargetByTargetType() {
|
||||
final TargetType testType = testdataFactory.createTargetType("testType",
|
||||
Collections.singletonList(standardDsType));
|
||||
final List<Target> unassigned = testdataFactory.createTargets(9, "unassigned");
|
||||
@@ -190,7 +191,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that targets with given assigned DS are returned from repository.
|
||||
*/
|
||||
@Test void findTargetByAssignedDistributionSet() {
|
||||
@Test
|
||||
void findTargetByAssignedDistributionSet() {
|
||||
final DistributionSet assignedSet = testdataFactory.createDistributionSet("");
|
||||
testdataFactory.createTargets(10, "unassigned", "unassigned");
|
||||
List<Target> assignedtargets = testdataFactory.createTargets(10, "assigned", "assigned");
|
||||
@@ -209,7 +211,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that targets without given assigned DS are returned from repository.
|
||||
*/
|
||||
@Test void findTargetWithoutAssignedDistributionSet() {
|
||||
@Test
|
||||
void findTargetWithoutAssignedDistributionSet() {
|
||||
final DistributionSet assignedSet = testdataFactory.createDistributionSet("");
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name("tfq").query("name==*"));
|
||||
@@ -228,7 +231,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that targets with given installed DS are returned from repository.
|
||||
*/
|
||||
@Test void findTargetByInstalledDistributionSet() {
|
||||
@Test
|
||||
void findTargetByInstalledDistributionSet() {
|
||||
final DistributionSet assignedSet = testdataFactory.createDistributionSet("");
|
||||
final DistributionSet installedSet = testdataFactory.createDistributionSet("another");
|
||||
testdataFactory.createTargets(10, "unassigned", "unassigned");
|
||||
@@ -251,7 +255,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that all compatible targets are returned from repository.
|
||||
*/
|
||||
@Test void shouldFindAllTargetsCompatibleWithDS() {
|
||||
@Test
|
||||
void shouldFindAllTargetsCompatibleWithDS() {
|
||||
final DistributionSet testDs = testdataFactory.createDistributionSet();
|
||||
final TargetType targetType = testdataFactory.createTargetType("testType",
|
||||
Collections.singletonList(testDs.getType()));
|
||||
@@ -271,7 +276,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that incompatible targets are not returned from repository.
|
||||
*/
|
||||
@Test void shouldNotFindTargetsIncompatibleWithDS() {
|
||||
@Test
|
||||
void shouldNotFindTargetsIncompatibleWithDS() {
|
||||
final DistributionSetType dsType = testdataFactory.findOrCreateDistributionSetType("test-ds-type",
|
||||
"test-ds-type");
|
||||
final DistributionSet testDs = createDistSetWithType(dsType);
|
||||
|
||||
@@ -30,7 +30,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByAssignedDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void countByAssignedDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByAssignedDistributionSet(1L),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -38,7 +39,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByFiltersPermissionsCheck() {
|
||||
@Test
|
||||
void countByFiltersPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByFilters(new FilterParams(null, null, null, null, null, null)),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -46,7 +48,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByInstalledDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void countByInstalledDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByInstalledDistributionSet(1L),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -54,7 +57,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void existsByInstalledOrAssignedDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void existsByInstalledOrAssignedDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.existsByInstalledOrAssignedDistributionSet(1L),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -62,28 +66,32 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void countByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByRsql("controllerId==id"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByRsqlAndUpdatablePermissionsCheck() {
|
||||
@Test
|
||||
void countByRsqlAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByRsqlAndUpdatable("controllerId==id"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByRsqlAndCompatiblePermissionsCheck() {
|
||||
@Test
|
||||
void countByRsqlAndCompatiblePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByRsqlAndCompatible("controllerId==id", 1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByRsqlAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
@Test
|
||||
void countByRsqlAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByRsqlAndCompatibleAndUpdatable("controllerId==id", 1L),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -91,21 +99,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByFailedInRolloutPermissionsCheck() {
|
||||
@Test
|
||||
void countByFailedInRolloutPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByFailedInRollout("1", 1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countPermissionsCheck() {
|
||||
@Test
|
||||
void countPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.count(), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createPermissionsCheck() {
|
||||
@Test
|
||||
void createPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.create(entityFactory.target().create().controllerId("controller").name("name")),
|
||||
List.of(SpPermission.CREATE_TARGET));
|
||||
}
|
||||
@@ -113,7 +124,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createCollectionPermissionsCheck() {
|
||||
@Test
|
||||
void createCollectionPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.create(List.of(entityFactory.target().create().controllerId("controller").name("name"))),
|
||||
List.of(SpPermission.CREATE_TARGET));
|
||||
}
|
||||
@@ -121,7 +133,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deletePermissionsCheck() {
|
||||
@Test
|
||||
void deletePermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetManagement.delete(List.of(1L));
|
||||
return null;
|
||||
@@ -131,7 +144,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteByControllerIDPermissionsCheck() {
|
||||
@Test
|
||||
void deleteByControllerIDPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetManagement.deleteByControllerID("controllerId");
|
||||
return null;
|
||||
@@ -141,14 +155,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByTargetFilterQueryPermissionsCheck() {
|
||||
@Test
|
||||
void countByTargetFilterQueryPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByTargetFilterQuery(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
@Test
|
||||
void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -156,7 +172,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByRsqlAndNonDSAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
@Test
|
||||
void countByRsqlAndNonDSAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByRsqlAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id"),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -164,7 +181,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> targetManagement.findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(List.of(1L), "controllerId==id",
|
||||
entityFactory.distributionSetType().create().build(), PAGE
|
||||
@@ -174,7 +192,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByActionsInRolloutGroupPermissionsCheck() {
|
||||
@Test
|
||||
void countByActionsInRolloutGroupPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByActionsInRolloutGroup(1L),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
@@ -182,7 +201,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
@Test
|
||||
void countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable("controllerId==id", List.of(1L),
|
||||
entityFactory.distributionSetType().create().build()), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
@@ -190,7 +210,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
|
||||
@Test
|
||||
void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByFailedRolloutAndNotInRolloutGroups("1", List.of(1L), PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
@@ -198,7 +219,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
|
||||
@Test
|
||||
void countByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByFailedRolloutAndNotInRolloutGroups("1", List.of(1L)),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
@@ -206,14 +228,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByInRolloutGroupWithoutActionPermissionsCheck() {
|
||||
@Test
|
||||
void findByInRolloutGroupWithoutActionPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByAssignedDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void findByAssignedDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByAssignedDistributionSet(1L, PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -221,7 +245,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByAssignedDistributionSetAndRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByAssignedDistributionSetAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(1L, "controllerId==id", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -229,21 +254,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByControllerCollectionIDPermissionsCheck() {
|
||||
@Test
|
||||
void getByControllerCollectionIDPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.getByControllerID(List.of("controllerId")), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByControllerIDPermissionsCheck() {
|
||||
@Test
|
||||
void getByControllerIDPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.getByControllerID("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByFiltersPermissionsCheck() {
|
||||
@Test
|
||||
void findByFiltersPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByFilters(new FilterParams(null, null, null, null, null, null), PAGE),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
@@ -251,7 +279,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByInstalledDistributionSetPermissionsCheck() {
|
||||
@Test
|
||||
void findByInstalledDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByInstalledDistributionSet(1L, PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -259,7 +288,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByInstalledDistributionSetAndRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByInstalledDistributionSetAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(1L, "controllerId==id", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -267,63 +297,72 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByUpdateStatusPermissionsCheck() {
|
||||
@Test
|
||||
void findByUpdateStatusPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findAllPermissionsCheck() {
|
||||
@Test
|
||||
void findAllPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByRsql("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByTargetFilterQueryPermissionsCheck() {
|
||||
@Test
|
||||
void findByTargetFilterQueryPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByTargetFilterQuery(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByTagPermissionsCheck() {
|
||||
@Test
|
||||
void findByTagPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlAndTagPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlAndTagPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByRsqlAndTag("controllerId==id", 1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignTypePermissionsCheck() {
|
||||
@Test
|
||||
void assignTypePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.assignType(List.of("controllerId"), 1L), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unassignTypeByIdPermissionsCheck() {
|
||||
@Test
|
||||
void unassignTypeByIdPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.unassignType("controllerId"), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignTagWithHandlerPermissionsCheck() {
|
||||
@Test
|
||||
void assignTagWithHandlerPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.assignTag(List.of("controllerId"), 1L, strings -> {}),
|
||||
List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -331,7 +370,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignTagPermissionsCheck() {
|
||||
@Test
|
||||
void assignTagPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.assignTag(List.of("controllerId"), 1L),
|
||||
List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -339,14 +379,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unassignTagPermissionsCheck() {
|
||||
@Test
|
||||
void unassignTagPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.unassignTag(List.of("controllerId"), 1L), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unassignTagWithHandlerPermissionsCheck() {
|
||||
@Test
|
||||
void unassignTagWithHandlerPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.unassignTag(List.of("controllerId"), 1L, strings -> {}),
|
||||
List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -354,49 +396,56 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void unassignTypePermissionsCheck() {
|
||||
@Test
|
||||
void unassignTypePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.unassignType(List.of("controllerId")), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignTypeByIdPermissionsCheck() {
|
||||
@Test
|
||||
void assignTypeByIdPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.assignType("controllerId", 1L), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updatePermissionsCheck() {
|
||||
@Test
|
||||
void updatePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.update(entityFactory.target().update("controllerId")), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getPermissionsCheck() {
|
||||
@Test
|
||||
void getPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.get(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getCollectionPermissionsCheck() {
|
||||
@Test
|
||||
void getCollectionPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void existsByControllerIdPermissionsCheck() {
|
||||
@Test
|
||||
void existsByControllerIdPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.existsByControllerId("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
@Test
|
||||
void isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> targetManagement.isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatable("controllerId", 1L, "controllerId==id"),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
@@ -405,21 +454,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getTagsPermissionsCheck() {
|
||||
@Test
|
||||
void getTagsPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.getTags("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getControllerAttributesPermissionsCheck() {
|
||||
@Test
|
||||
void getControllerAttributesPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.getControllerAttributes("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void requestControllerAttributesPermissionsCheck() {
|
||||
@Test
|
||||
void requestControllerAttributesPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetManagement.requestControllerAttributes("controllerId");
|
||||
return null;
|
||||
@@ -429,21 +481,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void isControllerAttributesRequestedPermissionsCheck() {
|
||||
@Test
|
||||
void isControllerAttributesRequestedPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.isControllerAttributesRequested("controllerId"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByControllerAttributesRequestedPermissionsCheck() {
|
||||
@Test
|
||||
void findByControllerAttributesRequestedPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByControllerAttributesRequested(PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void createMetadataPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> {
|
||||
targetManagement.createMetadata("controllerId", Map.of("key", "value"));
|
||||
@@ -455,14 +510,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void getMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.getMetadata("controllerId"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test @WithUser(principal = "user", authorities = { SpPermission.UPDATE_REPOSITORY })
|
||||
@Test
|
||||
@WithUser(principal = "user", authorities = { SpPermission.UPDATE_REPOSITORY })
|
||||
void updateMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetManagement.updateMetadata("controllerId", "key", "value");
|
||||
@@ -474,7 +531,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteMetadataPermissionsCheck() {
|
||||
@Test
|
||||
void deleteMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetManagement.deleteMetadata("controllerId", "key");
|
||||
return null;
|
||||
|
||||
@@ -160,7 +160,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that retrieving the target security is only permitted with the necessary permissions.
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception {
|
||||
final Target createdTarget = targetManagement
|
||||
.create(entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token"));
|
||||
@@ -197,7 +198,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a target with same controller ID than another device cannot be created.
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
void createTargetThatViolatesUniqueConstraintFails() {
|
||||
final TargetCreate targetCreate = entityFactory.target().create().controllerId("123");
|
||||
targetManagement.create(targetCreate);
|
||||
@@ -209,7 +211,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a target with with invalid properties cannot be created or updated
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class) })
|
||||
void createAndUpdateTargetWithInvalidFields() {
|
||||
@@ -225,7 +228,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 4),
|
||||
@Expect(type = TargetTagCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 5) })
|
||||
@@ -262,7 +266,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that targets can deleted e.g. test all cascades
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 12),
|
||||
@Expect(type = TargetDeletedEvent.class, count = 12),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 6) })
|
||||
@@ -293,7 +298,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Finds a target by given ID and checks if all data is in the response (including the data defined as lazy).
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
|
||||
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
|
||||
@@ -364,7 +370,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks if the EntityAlreadyExistsException is thrown if the targets with the same controller ID are created twice.
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 5) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 5) })
|
||||
void createMultipleTargetsDuplicate() {
|
||||
testdataFactory.createTargets(5, "mySimpleTargs", "my simple targets");
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
@@ -375,7 +382,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks if the EntityAlreadyExistsException is thrown if a single target with the same controller ID are created twice.
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
void createTargetDuplicate() {
|
||||
final TargetCreate targetCreate = entityFactory.target().create().controllerId("4711");
|
||||
targetManagement.create(targetCreate);
|
||||
@@ -497,7 +505,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the assignment of tags to the a single target.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 2),
|
||||
@Expect(type = TargetTagCreatedEvent.class, count = 7),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 7) })
|
||||
@@ -531,7 +540,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the assignment of tags to multiple targets.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 50),
|
||||
@Expect(type = TargetTagCreatedEvent.class, count = 4),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 80) })
|
||||
@@ -602,7 +612,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the unassigment of tags to multiple targets.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetTagCreatedEvent.class, count = 3),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 109),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 227) })
|
||||
@@ -662,7 +673,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test that NO TAG functionality which gives all targets with no tag assigned.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetTagCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 50),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 25) })
|
||||
@@ -685,7 +697,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the a target can be read with only the read target permission
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Test
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 1) })
|
||||
void targetCanBeReadWithOnlyReadTargetPermission() throws Exception {
|
||||
@@ -705,7 +718,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test that RSQL filter finds targets with tags or specific ids.
|
||||
*/
|
||||
@Test void findTargetsWithTagOrId() {
|
||||
@Test
|
||||
void findTargetsWithTagOrId() {
|
||||
final String rsqlFilter = "tag==Targ-A-Tag,id==target-id-B-00001,id==target-id-B-00008";
|
||||
final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final List<String> targAs = testdataFactory.createTargets(25, "target-id-A", "first description").stream()
|
||||
@@ -725,7 +739,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the find all targets by ids method contains the entities that we are looking for
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12) })
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12) })
|
||||
void verifyFindTargetAllById() {
|
||||
final List<Long> searchIds = Arrays.asList(testdataFactory.createTarget("target-4").getId(),
|
||||
testdataFactory.createTarget("target-5").getId(), testdataFactory.createTarget("target-6").getId());
|
||||
@@ -744,7 +759,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that the flag for requesting controller attributes is set correctly.
|
||||
*/
|
||||
@Test void verifyRequestControllerAttributes() {
|
||||
@Test
|
||||
void verifyRequestControllerAttributes() {
|
||||
final String knownControllerId = "KnownControllerId";
|
||||
final Target target = createTargetWithAttributes(knownControllerId);
|
||||
|
||||
@@ -763,7 +779,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Checks that metadata for a target can be created.
|
||||
*/
|
||||
@Test void createMetadata() {
|
||||
@Test
|
||||
void createMetadata() {
|
||||
insertMetadata(
|
||||
"targetMetaKnownKey", "targetMetaKnownValue",
|
||||
testdataFactory.createTarget("targetIdWithMetadata")); // and validate
|
||||
@@ -772,7 +789,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies the enforcement of the metadata quota per target.
|
||||
*/
|
||||
@Test void createMetadataUntilQuotaIsExceeded() {
|
||||
@Test
|
||||
void createMetadataUntilQuotaIsExceeded() {
|
||||
// add meta-data one by one
|
||||
final Target target1 = testdataFactory.createTarget("target1");
|
||||
final int maxMetaData = quotaManagement.getMaxMetaDataEntriesPerTarget();
|
||||
@@ -816,7 +834,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Queries and loads the metadata related to a given target.
|
||||
*/
|
||||
@Test void getMetadata() {
|
||||
@Test
|
||||
void getMetadata() {
|
||||
// create targets
|
||||
assertThat(targetManagement.getMetadata(testdataFactory.createTarget("target0").getControllerId())).isEmpty();
|
||||
assertThat(targetManagement.getMetadata(createTargetWithMetadata("target1", 10).getControllerId())).hasSize(10);
|
||||
@@ -858,7 +877,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Queries and loads the metadata related to a given target.
|
||||
*/
|
||||
@Test void deleteMetadata() {
|
||||
@Test
|
||||
void deleteMetadata() {
|
||||
final String knownKey = "myKnownKey";
|
||||
final String knownValue = "myKnownValue";
|
||||
|
||||
@@ -1043,7 +1063,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test that RSQL filter finds targets with metadata and/or controllerId.
|
||||
*/
|
||||
@Test void findTargetsByRsqlWithMetadata() {
|
||||
@Test
|
||||
void findTargetsByRsqlWithMetadata() {
|
||||
final String controllerId1 = "target1";
|
||||
final String controllerId2 = "target2";
|
||||
createTargetWithMetadata(controllerId1, 2);
|
||||
@@ -1068,7 +1089,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test that RSQL filter finds targets with tag and metadata.
|
||||
*/
|
||||
@Test void findTargetsByRsqlWithTypeAndMetadata() {
|
||||
@Test
|
||||
void findTargetsByRsqlWithTypeAndMetadata() {
|
||||
if (RsqlConfigHolder.getInstance().getRsqlToSpecBuilder() == LEGACY_G1) {
|
||||
// legacy visitor fail with that
|
||||
return;
|
||||
@@ -1091,7 +1113,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target matches filter.
|
||||
*/
|
||||
@Test void matchesFilter() {
|
||||
@Test
|
||||
void matchesFilter() {
|
||||
final Target target = createTargetWithMetadata("target1", 2);
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
final String filter = "metadata.key1==target1-value1";
|
||||
@@ -1103,7 +1126,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target does not matches filter.
|
||||
*/
|
||||
@Test void matchesFilterWrongFilter() {
|
||||
@Test
|
||||
void matchesFilterWrongFilter() {
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
final String filter = "metadata.key==not_existing";
|
||||
@@ -1115,7 +1139,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target matches filter but DS already assigned.
|
||||
*/
|
||||
@Test void matchesFilterDsAssigned() {
|
||||
@Test
|
||||
void matchesFilterDsAssigned() {
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet();
|
||||
final DistributionSet ds2 = testdataFactory.createDistributionSet();
|
||||
@@ -1130,7 +1155,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target matches filter for DS with wrong type.
|
||||
*/
|
||||
@Test void matchesFilterWrongType() {
|
||||
@Test
|
||||
void matchesFilterWrongType() {
|
||||
final TargetType type = testdataFactory.createTargetType("type", Collections.emptyList());
|
||||
final Target target = testdataFactory.createTarget("target", "target", type.getId());
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
@@ -1142,7 +1168,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target matches filter that is invalid.
|
||||
*/
|
||||
@Test void matchesFilterInvalidFilter() {
|
||||
@Test
|
||||
void matchesFilterInvalidFilter() {
|
||||
final String target = testdataFactory.createTarget().getControllerId();
|
||||
final Long ds = testdataFactory.createDistributionSet().getId();
|
||||
|
||||
@@ -1155,7 +1182,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target matches filter for not existing target.
|
||||
*/
|
||||
@Test void matchesFilterTargetNotExists() {
|
||||
@Test
|
||||
void matchesFilterTargetNotExists() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
|
||||
assertThat(targetManagement.isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatable(
|
||||
@@ -1168,7 +1196,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target matches filter no active action with ge weight.
|
||||
*/
|
||||
@Test void findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable() {
|
||||
@Test
|
||||
void findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable() {
|
||||
final String targetPrefix = "dyn_action_filter_";
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final List<Target> targets = testdataFactory.createTargets(targetPrefix, 10);
|
||||
@@ -1220,7 +1249,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Target matches filter for not existing DS.
|
||||
*/
|
||||
@Test void matchesFilterDsNotExists() {
|
||||
@Test
|
||||
void matchesFilterDsNotExists() {
|
||||
final String target = testdataFactory.createTarget().getControllerId();
|
||||
|
||||
assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(
|
||||
@@ -1230,7 +1260,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test update status convert
|
||||
*/
|
||||
@Test void testUpdateStatusConvert() {
|
||||
@Test
|
||||
void testUpdateStatusConvert() {
|
||||
final long id = testdataFactory.createTarget().getId();
|
||||
for (final TargetUpdateStatus status : TargetUpdateStatus.values()) {
|
||||
final JpaTarget target = targetRepository.findById(id).orElseThrow(() -> new IllegalStateException("Target not found"));
|
||||
|
||||
@@ -26,21 +26,24 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countPermissionsCheck() {
|
||||
@Test
|
||||
void countPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.count(), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createPermissionsCheck() {
|
||||
@Test
|
||||
void createPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.create(entityFactory.tag().create().name("name")), List.of(SpPermission.CREATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createCollectionPermissionsCheck() {
|
||||
@Test
|
||||
void createCollectionPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.create(List.of(entityFactory.tag().create().name("name"))),
|
||||
List.of(SpPermission.CREATE_TARGET));
|
||||
}
|
||||
@@ -48,7 +51,8 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deletePermissionsCheck() {
|
||||
@Test
|
||||
void deletePermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetTagManagement.delete("tag");
|
||||
return null;
|
||||
@@ -58,42 +62,48 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findAllPermissionsCheck() {
|
||||
@Test
|
||||
void findAllPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByNamePermissionsCheck() {
|
||||
@Test
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.getByName("tag"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getPermissionsCheck() {
|
||||
@Test
|
||||
void getPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.get(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getCollectionPermissionsCheck() {
|
||||
@Test
|
||||
void getCollectionPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updatePermissionsCheck() {
|
||||
@Test
|
||||
void updatePermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.update(entityFactory.tag().update(1L)), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that tagging of set containing missing DS throws meaningful and correct exception.
|
||||
*/
|
||||
@Test void failOnMissingDs() {
|
||||
@Test
|
||||
void failOnMissingDs() {
|
||||
final Collection<String> group = testdataFactory.createTargets(5).stream()
|
||||
.map(Target::getControllerId)
|
||||
.toList();
|
||||
@@ -111,7 +112,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a tag with with invalid properties cannot be created or updated
|
||||
*/
|
||||
@Test void createAndUpdateTagWithInvalidFields() {
|
||||
@Test
|
||||
void createAndUpdateTagWithInvalidFields() {
|
||||
final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
createAndUpdateTagWithInvalidDescription(tag);
|
||||
createAndUpdateTagWithInvalidColour(tag);
|
||||
@@ -121,7 +123,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies assign/unassign.
|
||||
*/
|
||||
@Test void assignAndUnassignTargetTags() {
|
||||
@Test
|
||||
void assignAndUnassignTargetTags() {
|
||||
final List<Target> groupA = testdataFactory.createTargets(20);
|
||||
final List<Target> groupB = testdataFactory.createTargets(20, "groupb", "groupb");
|
||||
|
||||
@@ -159,7 +162,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that all tags are retrieved through repository.
|
||||
*/
|
||||
@Test void findAllTargetTags() {
|
||||
@Test
|
||||
void findAllTargetTags() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
assertThat(targetTagRepository.findAll()).isEqualTo(targetTagRepository.findAll()).isEqualTo(tags)
|
||||
@@ -169,7 +173,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a created tag is persisted in the repository as defined.
|
||||
*/
|
||||
@Test void createTargetTag() {
|
||||
@Test
|
||||
void createTargetTag() {
|
||||
final Tag tag = targetTagManagement
|
||||
.create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
@@ -182,7 +187,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a deleted tag is removed from the repository as defined.
|
||||
*/
|
||||
@Test void deleteTargetTags() {
|
||||
@Test
|
||||
void deleteTargetTags() {
|
||||
// create test data
|
||||
final Iterable<JpaTargetTag> tags = createTargetsWithTags();
|
||||
final TargetTag toDelete = tags.iterator().next();
|
||||
@@ -206,7 +212,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the name update of a target tag.
|
||||
*/
|
||||
@Test void updateTargetTag() {
|
||||
@Test
|
||||
void updateTargetTag() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
// change data
|
||||
@@ -227,7 +234,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a tag cannot be created if one exists already with that name (expects EntityAlreadyExistsException).
|
||||
*/
|
||||
@Test void failedDuplicateTargetTagNameException() {
|
||||
@Test
|
||||
void failedDuplicateTargetTagNameException() {
|
||||
final TagCreate tagCreate = entityFactory.tag().create().name("A");
|
||||
targetTagManagement.create(tagCreate);
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).isThrownBy(() -> targetTagManagement.create(tagCreate));
|
||||
@@ -236,7 +244,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a tag cannot be updated to a name that already exists on another tag (expects EntityAlreadyExistsException).
|
||||
*/
|
||||
@Test void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
||||
@Test
|
||||
void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
||||
targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
|
||||
|
||||
@@ -27,35 +27,40 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByKeyPermissionsCheck() {
|
||||
@Test
|
||||
void getByKeyPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.getByKey("key"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getByNamePermissionsCheck() {
|
||||
@Test
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.getByName("name"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countPermissionsCheck() {
|
||||
@Test
|
||||
void countPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.count(), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void countByNamePermissionsCheck() {
|
||||
@Test
|
||||
void countByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.countByName("name"), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createPermissionsCheck() {
|
||||
@Test
|
||||
void createPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.create(entityFactory.targetType().create().name("name")),
|
||||
List.of(SpPermission.CREATE_TARGET));
|
||||
}
|
||||
@@ -63,7 +68,8 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void createCollectionPermissionsCheck() {
|
||||
@Test
|
||||
void createCollectionPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.create(List.of(entityFactory.targetType().create().name("name"))),
|
||||
List.of(SpPermission.CREATE_TARGET));
|
||||
}
|
||||
@@ -71,7 +77,8 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deletePermissionsCheck() {
|
||||
@Test
|
||||
void deletePermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
targetTypeManagement.delete(1L);
|
||||
return null;
|
||||
@@ -81,49 +88,56 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findAllPermissionsCheck() {
|
||||
@Test
|
||||
void findAllPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByRsqlPermissionsCheck() {
|
||||
@Test
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void findByNamePermissionsCheck() {
|
||||
@Test
|
||||
void findByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.findByName("name", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getPermissionsCheck() {
|
||||
@Test
|
||||
void getPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.get(1L), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getCollectionPermissionsCheck() {
|
||||
@Test
|
||||
void getCollectionPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void updatePermissionsCheck() {
|
||||
@Test
|
||||
void updatePermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.update(entityFactory.targetType().update(1L)), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void assignCompatibleDistributionSetTypesPermissionsCheck() {
|
||||
@Test
|
||||
void assignCompatibleDistributionSetTypesPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.assignCompatibleDistributionSetTypes(1L, List.of(1L)),
|
||||
List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
@@ -131,7 +145,8 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test @WithUser(principal = "user", authorities = { SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY })
|
||||
@Test
|
||||
@WithUser(principal = "user", authorities = { SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY })
|
||||
void unassignDistributionSetTypePermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.unassignDistributionSetType(1L, 1L),
|
||||
List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
|
||||
|
||||
@@ -65,7 +65,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that a target type with invalid properties cannot be created or updated
|
||||
*/
|
||||
@Test void createAndUpdateTargetTypeWithInvalidFields() {
|
||||
@Test
|
||||
void createAndUpdateTargetTypeWithInvalidFields() {
|
||||
final TargetType targetType = targetTypeManagement
|
||||
.create(entityFactory.targetType().create()
|
||||
.name("targettype1").description("targettypedes1")
|
||||
@@ -103,7 +104,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the successful assignment of compatible distribution set types to a target type
|
||||
*/
|
||||
@Test void assignCompatibleDistributionSetTypesToTargetType() {
|
||||
@Test
|
||||
void assignCompatibleDistributionSetTypesToTargetType() {
|
||||
final TargetType targetType = targetTypeManagement
|
||||
.create(entityFactory.targetType().create()
|
||||
.name("targettype1").description("targettypedes1")
|
||||
@@ -119,7 +121,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the successful removal of compatible distribution set types to a target type
|
||||
*/
|
||||
@Test void unassignCompatibleDistributionSetTypesToTargetType() {
|
||||
@Test
|
||||
void unassignCompatibleDistributionSetTypesToTargetType() {
|
||||
final TargetType targetType = targetTypeManagement
|
||||
.create(entityFactory.targetType().create()
|
||||
.name("targettype1").description("targettypedes1")
|
||||
@@ -138,7 +141,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that all types are retrieved through repository.
|
||||
*/
|
||||
@Test void findAllTargetTypes() {
|
||||
@Test
|
||||
void findAllTargetTypes() {
|
||||
testdataFactory.createTargetTypes("targettype", 10);
|
||||
assertThat(targetTypeRepository.findAll()).as("Target type size").hasSize(10);
|
||||
}
|
||||
@@ -146,7 +150,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a created target type is persisted in the repository as defined.
|
||||
*/
|
||||
@Test void createTargetType() {
|
||||
@Test
|
||||
void createTargetType() {
|
||||
final String name = "targettype1";
|
||||
final String key = "targettype1.key";
|
||||
targetTypeManagement
|
||||
@@ -177,7 +182,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a deleted target type is removed from the repository as defined.
|
||||
*/
|
||||
@Test void deleteTargetType() {
|
||||
@Test
|
||||
void deleteTargetType() {
|
||||
// create test data
|
||||
final TargetType targetType = targetTypeManagement
|
||||
.create(entityFactory.targetType().create().name("targettype11").description("targettypedes11"));
|
||||
@@ -191,7 +197,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Tests the name update of a target type.
|
||||
*/
|
||||
@Test void updateTargetType() {
|
||||
@Test
|
||||
void updateTargetType() {
|
||||
final TargetType targetType = targetTypeManagement
|
||||
.create(entityFactory.targetType().create().name("targettype111").description("targettypedes111"));
|
||||
assertThat(findByName("targettype111").get().getDescription()).as("type found")
|
||||
@@ -203,7 +210,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a target type cannot be created if one exists already with that name (expects EntityAlreadyExistsException).
|
||||
*/
|
||||
@Test void failedDuplicateTargetTypeNameException() {
|
||||
@Test
|
||||
void failedDuplicateTargetTypeNameException() {
|
||||
final TargetTypeCreate targetTypeCreate = entityFactory.targetType().create().name("targettype123");
|
||||
targetTypeManagement.create(targetTypeCreate);
|
||||
assertThrows(EntityAlreadyExistsException.class, () -> targetTypeManagement.create(targetTypeCreate));
|
||||
@@ -212,7 +220,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that a target type cannot be updated to a name that already exists (expects EntityAlreadyExistsException).
|
||||
*/
|
||||
@Test void failedDuplicateTargetTypeNameExceptionAfterUpdate() {
|
||||
@Test
|
||||
void failedDuplicateTargetTypeNameExceptionAfterUpdate() {
|
||||
targetTypeManagement.create(entityFactory.targetType().create().name("targettype1234"));
|
||||
TargetType targetType = targetTypeManagement.create(entityFactory.targetType().create().name("targettype12345"));
|
||||
assertThrows(EntityAlreadyExistsException.class,
|
||||
|
||||
@@ -27,7 +27,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void addOrUpdateConfigurationPermissionsCheck() {
|
||||
@Test
|
||||
void addOrUpdateConfigurationPermissionsCheck() {
|
||||
assertPermissions(() -> tenantConfigurationManagement.addOrUpdateConfiguration("authentication.header.enabled", true),
|
||||
List.of(SpPermission.TENANT_CONFIGURATION));
|
||||
}
|
||||
@@ -35,7 +36,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void addOrUpdateConfigurationWithMapPermissionsCheck() {
|
||||
@Test
|
||||
void addOrUpdateConfigurationWithMapPermissionsCheck() {
|
||||
assertPermissions(() -> tenantConfigurationManagement.addOrUpdateConfiguration(Map.of("authentication.header.enabled", true)),
|
||||
List.of(SpPermission.TENANT_CONFIGURATION));
|
||||
}
|
||||
@@ -43,7 +45,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void deleteConfigurationPermissionsCheck() {
|
||||
@Test
|
||||
void deleteConfigurationPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
tenantConfigurationManagement.deleteConfiguration("authentication.header.enabled");
|
||||
return null;
|
||||
@@ -53,7 +56,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getConfigurationValuePermissionsCheck() {
|
||||
@Test
|
||||
void getConfigurationValuePermissionsCheck() {
|
||||
assertPermissions(() -> tenantConfigurationManagement.getConfigurationValue("authentication.header.enabled"),
|
||||
List.of(SpPermission.READ_TENANT_CONFIGURATION));
|
||||
}
|
||||
@@ -61,7 +65,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getConfigurationValueWithTypePermissionsCheck() {
|
||||
@Test
|
||||
void getConfigurationValueWithTypePermissionsCheck() {
|
||||
assertPermissions(() -> tenantConfigurationManagement.getConfigurationValue("authentication.header.enabled", Boolean.class),
|
||||
List.of(SpPermission.READ_TENANT_CONFIGURATION));
|
||||
}
|
||||
@@ -69,7 +74,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void getGlobalConfigurationValuePermissionsCheck() {
|
||||
@Test
|
||||
void getGlobalConfigurationValuePermissionsCheck() {
|
||||
assertPermissions(() -> tenantConfigurationManagement.getGlobalConfigurationValue("authentication.header.enabled", Boolean.class),
|
||||
List.of(SpPermission.READ_TENANT_CONFIGURATION));
|
||||
}
|
||||
@@ -77,7 +83,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
/**
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test void pollStatusResolverPermissionsCheck() {
|
||||
@Test
|
||||
void pollStatusResolverPermissionsCheck() {
|
||||
assertPermissions(() -> tenantConfigurationManagement.pollStatusResolver(), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tests that tenant specific configuration can be persisted and in case the tenant does not have specific configuration the default from environment is used instead.
|
||||
*/
|
||||
@Test void storeTenantSpecificConfigurationAsString() {
|
||||
@Test
|
||||
void storeTenantSpecificConfigurationAsString() {
|
||||
final String envPropertyDefault = environment.getProperty("hawkbit.server.ddi.security.authentication.gatewaytoken.key");
|
||||
assertThat(envPropertyDefault).isNotNull();
|
||||
|
||||
@@ -73,7 +74,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tests that the tenant specific configuration can be updated
|
||||
*/
|
||||
@Test void updateTenantSpecificConfiguration() {
|
||||
@Test
|
||||
void updateTenantSpecificConfiguration() {
|
||||
final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY;
|
||||
final String value1 = "firstValue";
|
||||
final String value2 = "secondValue";
|
||||
@@ -90,7 +92,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tests that the tenant specific configuration can be batch updated
|
||||
*/
|
||||
@Test void batchUpdateTenantSpecificConfiguration() {
|
||||
@Test
|
||||
void batchUpdateTenantSpecificConfiguration() {
|
||||
Map<String, Serializable> configuration = new HashMap<>() {{
|
||||
put(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, "token_123");
|
||||
put(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, true);
|
||||
@@ -109,7 +112,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tests that the configuration value can be converted from String to Integer automatically
|
||||
*/
|
||||
@Test void storeAndUpdateTenantSpecificConfigurationAsBoolean() {
|
||||
@Test
|
||||
void storeAndUpdateTenantSpecificConfigurationAsBoolean() {
|
||||
final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED;
|
||||
final Boolean value1 = true;
|
||||
tenantConfigurationManagement.addOrUpdateConfiguration(configKey, value1);
|
||||
@@ -122,7 +126,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tests that the get configuration throws exception in case the value cannot be automatically converted from String to Boolean
|
||||
*/
|
||||
@Test void wrongTenantConfigurationValueTypeThrowsException() {
|
||||
@Test
|
||||
void wrongTenantConfigurationValueTypeThrowsException() {
|
||||
final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED;
|
||||
final String value1 = "thisIsNotABoolean";
|
||||
|
||||
@@ -135,7 +140,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tests that the get configuration throws exception in case the value is the wrong type
|
||||
*/
|
||||
@Test void batchWrongTenantConfigurationValueTypeThrowsException() {
|
||||
@Test
|
||||
void batchWrongTenantConfigurationValueTypeThrowsException() {
|
||||
final Map<String, Serializable> configuration = new HashMap<>() {{
|
||||
put(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, "token_123");
|
||||
put(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, true);
|
||||
@@ -160,7 +166,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tests that a deletion of a tenant specific configuration deletes it from the database.
|
||||
*/
|
||||
@Test void deleteConfigurationReturnNullConfiguration() {
|
||||
@Test
|
||||
void deleteConfigurationReturnNullConfiguration() {
|
||||
final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY;
|
||||
|
||||
// gateway token does not have default value so no configuration value should be available
|
||||
@@ -186,7 +193,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Test that an Exception is thrown, when an integer is stored but a string expected.
|
||||
*/
|
||||
@Test void storesIntegerWhenStringIsExpected() {
|
||||
@Test
|
||||
void storesIntegerWhenStringIsExpected() {
|
||||
final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY;
|
||||
final Integer wrongDatType = 123;
|
||||
assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDatType))
|
||||
@@ -197,7 +205,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Test that an Exception is thrown, when an integer is stored but a boolean expected.
|
||||
*/
|
||||
@Test void storesIntegerWhenBooleanIsExpected() {
|
||||
@Test
|
||||
void storesIntegerWhenBooleanIsExpected() {
|
||||
final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED;
|
||||
final Integer wrongDataType = 123;
|
||||
assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataType))
|
||||
@@ -208,7 +217,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Test that an Exception is thrown, when an integer is stored as PollingTime.
|
||||
*/
|
||||
@Test void storesIntegerWhenPollingIntervalIsExpected() {
|
||||
@Test
|
||||
void storesIntegerWhenPollingIntervalIsExpected() {
|
||||
final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||
final Integer wrongDataType = 123;
|
||||
assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataType))
|
||||
@@ -219,7 +229,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime.
|
||||
*/
|
||||
@Test void storesWrongFormattedStringAsPollingInterval() {
|
||||
@Test
|
||||
void storesWrongFormattedStringAsPollingInterval() {
|
||||
final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||
final String wrongFormatted = "wrongFormatted";
|
||||
assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongFormatted))
|
||||
@@ -230,7 +241,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime.
|
||||
*/
|
||||
@Test void storesTooSmallDurationAsPollingInterval() {
|
||||
@Test
|
||||
void storesTooSmallDurationAsPollingInterval() {
|
||||
final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||
|
||||
final String tooSmallDuration = DurationHelper
|
||||
@@ -243,7 +255,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Stores a correct formatted PollignTime and reads it again.
|
||||
*/
|
||||
@Test void storesCorrectDurationAsPollingInterval() {
|
||||
@Test
|
||||
void storesCorrectDurationAsPollingInterval() {
|
||||
final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||
|
||||
final Duration duration = DurationHelper.getDurationByTimeValues(1, 2, 0);
|
||||
@@ -258,7 +271,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Request a config value in a wrong Value
|
||||
*/
|
||||
@Test void requestConfigValueWithWrongType() {
|
||||
@Test
|
||||
void requestConfigValueWithWrongType() {
|
||||
assertThatThrownBy(() -> tenantConfigurationManagement.getConfigurationValue(
|
||||
TenantConfigurationKey.POLLING_TIME_INTERVAL, Serializable.class))
|
||||
.isInstanceOf(TenantConfigurationValidatorException.class);
|
||||
@@ -267,7 +281,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Verifies that every TenenatConfiguraationKeyName exists only once
|
||||
*/
|
||||
@Test void verifyThatAllKeysAreDifferent() {
|
||||
@Test
|
||||
void verifyThatAllKeysAreDifferent() {
|
||||
final Map<String, Void> keyNames = new HashMap<>();
|
||||
tenantConfigurationProperties.getConfigurationKeys().forEach(key -> {
|
||||
assertThat(keyNames)
|
||||
@@ -280,7 +295,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Get TenantConfigurationKeyByName
|
||||
*/
|
||||
@Test void getTenantConfigurationKeyByName() {
|
||||
@Test
|
||||
void getTenantConfigurationKeyByName() {
|
||||
final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL;
|
||||
assertThat(tenantConfigurationProperties.fromKeyName(configKey).getKeyName()).isEqualTo(configKey);
|
||||
}
|
||||
@@ -288,7 +304,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple
|
||||
/**
|
||||
* Tenant configuration which is not declared throws exception
|
||||
*/
|
||||
@Test void storeTenantConfigurationWhichIsNotDeclaredThrowsException() {
|
||||
@Test
|
||||
void storeTenantConfigurationWhichIsNotDeclaredThrowsException() {
|
||||
final String configKeyWhichDoesNotExists = "configKeyWhichDoesNotExists";
|
||||
assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKeyWhichDoesNotExists, "value"))
|
||||
.as("Expected InvalidTenantConfigurationKeyException for tenant configuration key which is not declared")
|
||||
|
||||
@@ -35,21 +35,24 @@ class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the pre persist is called after a entity creation.
|
||||
*/
|
||||
@Test void prePersistIsCalledWhenPersistingATarget() {
|
||||
@Test
|
||||
void prePersistIsCalledWhenPersistingATarget() {
|
||||
executePersistAndAssertCallbackResult(new PrePersistEntityListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the post persist is called after a entity creation.
|
||||
*/
|
||||
@Test void postPersistIsCalledWhenPersistingATarget() {
|
||||
@Test
|
||||
void postPersistIsCalledWhenPersistingATarget() {
|
||||
executePersistAndAssertCallbackResult(new PostPersistEntityListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the post load is called after a entity is loaded.
|
||||
*/
|
||||
@Test void postLoadIsCalledWhenLoadATarget() {
|
||||
@Test
|
||||
void postLoadIsCalledWhenLoadATarget() {
|
||||
final PostLoadEntityListener postLoadEntityListener = new PostLoadEntityListener();
|
||||
EntityInterceptorHolder.getInstance().getEntityInterceptors().add(postLoadEntityListener);
|
||||
|
||||
@@ -63,28 +66,32 @@ class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that the pre update is called after a entity update.
|
||||
*/
|
||||
@Test void preUpdateIsCalledWhenUpdateATarget() {
|
||||
@Test
|
||||
void preUpdateIsCalledWhenUpdateATarget() {
|
||||
executeUpdateAndAssertCallbackResult(new PreUpdateEntityListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the post update is called after a entity update.
|
||||
*/
|
||||
@Test void postUpdateIsCalledWhenUpdateATarget() {
|
||||
@Test
|
||||
void postUpdateIsCalledWhenUpdateATarget() {
|
||||
executeUpdateAndAssertCallbackResult(new PostUpdateEntityListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the pre remove is called after a entity deletion.
|
||||
*/
|
||||
@Test void preRemoveIsCalledWhenDeletingATarget() {
|
||||
@Test
|
||||
void preRemoveIsCalledWhenDeletingATarget() {
|
||||
executeDeleteAndAssertCallbackResult(new PreRemoveEntityListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the post remove is called after a entity deletion.
|
||||
*/
|
||||
@Test void postRemoveIsCalledWhenDeletingATarget() {
|
||||
@Test
|
||||
void postRemoveIsCalledWhenDeletingATarget() {
|
||||
executeDeleteAndAssertCallbackResult(new PostRemoveEntityListener());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that different objects even with identical primary key, version and tenant return different hash codes.
|
||||
*/
|
||||
@Test void differentEntitiesReturnDifferentHashCodes() {
|
||||
@Test
|
||||
void differentEntitiesReturnDifferentHashCodes() {
|
||||
assertThat(new JpaAction().hashCode()).as("action should have different hashcode than action status")
|
||||
.isNotEqualTo(new JpaActionStatus().hashCode());
|
||||
assertThat(new JpaDistributionSet().hashCode())
|
||||
@@ -41,7 +42,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that different object even with identical primary key, version and tenant are not equal.
|
||||
*/
|
||||
@Test void differentEntitiesAreNotEqual() {
|
||||
@Test
|
||||
void differentEntitiesAreNotEqual() {
|
||||
assertThat(new JpaAction().equals(new JpaActionStatus())).as("action equals action status").isFalse();
|
||||
assertThat(new JpaDistributionSet().equals(new JpaSoftwareModule()))
|
||||
.as("Distribution set equals software module").isFalse();
|
||||
@@ -54,7 +56,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verifies that updated entities are not equal.
|
||||
*/
|
||||
@Test void changedEntitiesAreNotEqual() {
|
||||
@Test
|
||||
void changedEntitiesAreNotEqual() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("test").name("test"));
|
||||
assertThat(type).as("persited entity is not equal to regular object")
|
||||
@@ -68,7 +71,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Verify that no proxy of the entity manager has an influence on the equals or hashcode result.
|
||||
*/
|
||||
@Test void managedEntityIsEqualToUnamangedObjectWithSameKey() {
|
||||
@Test
|
||||
void managedEntityIsEqualToUnamangedObjectWithSameKey() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test").name("test").description("test"));
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter action by id
|
||||
*/
|
||||
@Test void testFilterByParameterId() {
|
||||
@Test
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(ActionFields.ID.name() + "==" + action.getId(), 1);
|
||||
assertRSQLQuery(ActionFields.ID.name() + "!=" + action.getId(), 10);
|
||||
assertRSQLQuery(ActionFields.ID.name() + "==" + -1, 0);
|
||||
@@ -69,7 +70,8 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test action by status
|
||||
*/
|
||||
@Test void testFilterByParameterStatus() {
|
||||
@Test
|
||||
void testFilterByParameterStatus() {
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "==pending", 5);
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "!=pending", 6);
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "=in=(pending)", 5);
|
||||
@@ -84,7 +86,8 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test action by status
|
||||
*/
|
||||
@Test void testFilterByParameterExtRef() {
|
||||
@Test
|
||||
void testFilterByParameterExtRef() {
|
||||
assertRSQLQuery(ActionFields.EXTERNALREF.name() + "==extRef", 5);
|
||||
assertRSQLQuery(ActionFields.EXTERNALREF.name() + "!=extRef", 6);
|
||||
assertRSQLQuery(ActionFields.EXTERNALREF.name() + "==extRef*", 10);
|
||||
|
||||
@@ -41,7 +41,8 @@ class RSQLRolloutFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter rollout by distrbution set type id
|
||||
*/
|
||||
@Test void testFilterByDsType() {
|
||||
@Test
|
||||
void testFilterByDsType() {
|
||||
assertRSQLQuery(RolloutFields.DISTRIBUTIONSET.name() + ".type.id" + "==" + rollout.getDistributionSet().getType().getId() + 1, 0);
|
||||
assertRSQLQuery(RolloutFields.DISTRIBUTIONSET.name() + ".type.id" + "!=" + rollout.getDistributionSet().getType().getId() + 1, 1);
|
||||
assertRSQLQuery(RolloutFields.DISTRIBUTIONSET.name() + ".type.id" + "==" + rollout.getDistributionSet().getType().getId(), 1);
|
||||
|
||||
@@ -47,7 +47,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter rollout group by id
|
||||
*/
|
||||
@Test void testFilterByParameterId() {
|
||||
@Test
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "==" + rolloutGroupId, 1);
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "!=" + rolloutGroupId, 3);
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "==" + -1, 0);
|
||||
@@ -65,7 +66,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter rollout group by name
|
||||
*/
|
||||
@Test void testFilterByParameterName() {
|
||||
@Test
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(RolloutGroupFields.NAME.name() + "==group-1", 1);
|
||||
assertRSQLQuery(RolloutGroupFields.NAME.name() + "!=group-1", 3);
|
||||
assertRSQLQuery(RolloutGroupFields.NAME.name() + "==*", 4);
|
||||
@@ -77,7 +79,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter rollout group by description
|
||||
*/
|
||||
@Test void testFilterByParameterDescription() {
|
||||
@Test
|
||||
void testFilterByParameterDescription() {
|
||||
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "==group-1", 1);
|
||||
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "!=group-1", 3);
|
||||
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "==group*", 4);
|
||||
|
||||
@@ -60,7 +60,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module by id
|
||||
*/
|
||||
@Test void testFilterByParameterId() {
|
||||
@Test
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "==" + ah.getId(), 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "!=" + ah.getId(), 5);
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "==" + -1, 0);
|
||||
@@ -78,7 +79,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module by name
|
||||
*/
|
||||
@Test void testFilterByParameterName() {
|
||||
@Test
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "!=agent-hub", 5);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub*", 2);
|
||||
@@ -100,7 +102,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module by name which contain mutated vowels
|
||||
*/
|
||||
@Test void testFilterByParameterNameWithUmlaut() {
|
||||
@Test
|
||||
void testFilterByParameterNameWithUmlaut() {
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ö*", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ä*", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ü*", 1);
|
||||
@@ -109,7 +112,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module by description
|
||||
*/
|
||||
@Test void testFilterByParameterDescription() {
|
||||
@Test
|
||||
void testFilterByParameterDescription() {
|
||||
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==''", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "!=''", 5);
|
||||
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==agent-hub", 1);
|
||||
@@ -122,7 +126,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module by version
|
||||
*/
|
||||
@Test void testFilterByParameterVersion() {
|
||||
@Test
|
||||
void testFilterByParameterVersion() {
|
||||
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "==1.0.1", 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "!=v1.0", 6);
|
||||
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "=in=(1.0.1,1.0.2)", 2);
|
||||
@@ -132,7 +137,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module by type key
|
||||
*/
|
||||
@Test void testFilterByType() {
|
||||
@Test
|
||||
void testFilterByType() {
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==" + TestdataFactory.SM_TYPE_APP, 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "!=" + TestdataFactory.SM_TYPE_APP, 4);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==noExist*", 0);
|
||||
@@ -143,7 +149,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module by metadata
|
||||
*/
|
||||
@Test void testFilterByMetadata() {
|
||||
@Test
|
||||
void testFilterByMetadata() {
|
||||
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey==metaValue", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey!=metaValue", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey!=notexist", 2);
|
||||
|
||||
@@ -29,7 +29,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module test type by id
|
||||
*/
|
||||
@Test void testFilterByParameterId() {
|
||||
@Test
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==" + osType.getId(), 1);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "!=" + osType.getId(), 2);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==" + -1, 0);
|
||||
@@ -47,7 +48,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module test type by name
|
||||
*/
|
||||
@Test void testFilterByParameterName() {
|
||||
@Test
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "==" + Constants.SMT_DEFAULT_OS_NAME, 1);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "!=" + Constants.SMT_DEFAULT_OS_NAME, 2);
|
||||
}
|
||||
@@ -55,7 +57,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module test type by description
|
||||
*/
|
||||
@Test void testFilterByParameterDescription() {
|
||||
@Test
|
||||
void testFilterByParameterDescription() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==''", 0);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "!=''", 3);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==Updated*", 3);
|
||||
@@ -66,7 +69,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module test type by key
|
||||
*/
|
||||
@Test void testFilterByParameterKey() {
|
||||
@Test
|
||||
void testFilterByParameterKey() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "==os", 1);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "!=os", 2);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "=in=(os)", 1);
|
||||
@@ -76,7 +80,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter software module test type by max
|
||||
*/
|
||||
@Test void testFilterByMaxAssignment() {
|
||||
@Test
|
||||
void testFilterByMaxAssignment() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "==1", 2);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "!=1", 1);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target tag by name
|
||||
*/
|
||||
@Test void testFilterTargetTagByParameterName() {
|
||||
@Test
|
||||
void testFilterTargetTagByParameterName() {
|
||||
assertRSQLQueryTarget(TagFields.NAME.name() + "==''", 0);
|
||||
assertRSQLQueryTarget(TagFields.NAME.name() + "!=''", 5);
|
||||
assertRSQLQueryTarget(TagFields.NAME.name() + "==1", 1);
|
||||
@@ -55,7 +56,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target tag by description
|
||||
*/
|
||||
@Test void testFilterTargetTagByParameterDescription() {
|
||||
@Test
|
||||
void testFilterTargetTagByParameterDescription() {
|
||||
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==''", 0);
|
||||
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "!=''", 5);
|
||||
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==1", 1);
|
||||
@@ -69,7 +71,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target tag by colour
|
||||
*/
|
||||
@Test void testFilterTargetTagByParameterColour() {
|
||||
@Test
|
||||
void testFilterTargetTagByParameterColour() {
|
||||
assertRSQLQueryTarget(TagFields.COLOUR.name() + "==''", 0);
|
||||
assertRSQLQueryTarget(TagFields.COLOUR.name() + "!=''", 5);
|
||||
assertRSQLQueryTarget(TagFields.COLOUR.name() + "==red", 3);
|
||||
@@ -83,7 +86,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter distribution set tag by name
|
||||
*/
|
||||
@Test void testFilterDistributionSetTagByParameterName() {
|
||||
@Test
|
||||
void testFilterDistributionSetTagByParameterName() {
|
||||
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==''", 0);
|
||||
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "!=''", 5);
|
||||
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==1", 1);
|
||||
@@ -97,7 +101,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter distribution set by description
|
||||
*/
|
||||
@Test void testFilterDistributionSetTagByParameterDescription() {
|
||||
@Test
|
||||
void testFilterDistributionSetTagByParameterDescription() {
|
||||
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==''", 0);
|
||||
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "!=''", 5);
|
||||
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==1", 1);
|
||||
@@ -111,7 +116,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter distribution set by colour
|
||||
*/
|
||||
@Test void testFilterDistributionSetTagByParameterColour() {
|
||||
@Test
|
||||
void testFilterDistributionSetTagByParameterColour() {
|
||||
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==''", 0);
|
||||
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "!=''", 5);
|
||||
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==red", 3);
|
||||
|
||||
@@ -109,7 +109,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by (controller) id
|
||||
*/
|
||||
@Test void testFilterByParameterId() {
|
||||
@Test
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(TargetFields.ID.name() + "==targetId123", 1);
|
||||
assertRSQLQuery(TargetFields.ID.name() + "!=targetId123", 4);
|
||||
assertRSQLQuery(TargetFields.ID.name() + "=in=(targetId123,notexist)", 1);
|
||||
@@ -119,7 +120,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by name
|
||||
*/
|
||||
@Test void testFilterByParameterName() {
|
||||
@Test
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(TargetFields.NAME.name() + "==targetName123", 1);
|
||||
assertRSQLQuery(TargetFields.NAME.name() + "==target*", 5);
|
||||
assertRSQLQuery(TargetFields.NAME.name() + "==noExist*", 0);
|
||||
@@ -131,7 +133,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by description
|
||||
*/
|
||||
@Test void testFilterByParameterDescription() {
|
||||
@Test
|
||||
void testFilterByParameterDescription() {
|
||||
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "==''", 3);
|
||||
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "!=''", 2);
|
||||
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "==targetDesc123", 1);
|
||||
@@ -145,7 +148,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by controller id
|
||||
*/
|
||||
@Test void testFilterByParameterControllerId() {
|
||||
@Test
|
||||
void testFilterByParameterControllerId() {
|
||||
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==targetId123", 1);
|
||||
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==target*", 5);
|
||||
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==noExist*", 0);
|
||||
@@ -157,7 +161,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by status
|
||||
*/
|
||||
@Test void testFilterByParameterUpdateStatus() {
|
||||
@Test
|
||||
void testFilterByParameterUpdateStatus() {
|
||||
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "==pending", 1);
|
||||
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "!=pending", 4);
|
||||
final String rsqlNoExistStar = TargetFields.UPDATESTATUS.name() + "==noExist*";
|
||||
@@ -171,7 +176,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by attribute
|
||||
*/
|
||||
@Test void testFilterByAttribute() {
|
||||
@Test
|
||||
void testFilterByAttribute() {
|
||||
controllerManagement.updateControllerAttributes(
|
||||
testdataFactory.createTarget().getControllerId(),
|
||||
Map.of(
|
||||
@@ -237,7 +243,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by assigned ds name
|
||||
*/
|
||||
@Test void testFilterByAssignedDsName() {
|
||||
@Test
|
||||
void testFilterByAssignedDsName() {
|
||||
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==AssignedDs", 1);
|
||||
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==A*", 1);
|
||||
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==noExist*", 0);
|
||||
@@ -248,7 +255,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by assigned ds version
|
||||
*/
|
||||
@Test void testFilterByAssignedDsVersion() {
|
||||
@Test
|
||||
void testFilterByAssignedDsVersion() {
|
||||
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==" + TestdataFactory.DEFAULT_VERSION, 1);
|
||||
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==*1*", 1);
|
||||
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==noExist*", 0);
|
||||
@@ -259,7 +267,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by tag name
|
||||
*/
|
||||
@Test void testFilterByTag() {
|
||||
@Test
|
||||
void testFilterByTag() {
|
||||
assertRSQLQuery(TargetFields.TAG.name() + "==Tag1", 2);
|
||||
assertRSQLQuery(TargetFields.TAG.name() + "!=Tag1", 3);
|
||||
assertRSQLQuery(TargetFields.TAG.name() + "==T*", 4);
|
||||
@@ -282,7 +291,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by lastTargetQuery
|
||||
*/
|
||||
@Test void testFilterByLastTargetQuery() {
|
||||
@Test
|
||||
void testFilterByLastTargetQuery() {
|
||||
assertRSQLQuery(TargetFields.LASTCONTROLLERREQUESTAT.name() + "==" + target.getLastTargetQuery(), 1);
|
||||
assertRSQLQuery(TargetFields.LASTCONTROLLERREQUESTAT.name() + "!=" + target.getLastTargetQuery(), 4);
|
||||
assertRSQLQuery(TargetFields.LASTCONTROLLERREQUESTAT.name() + "=lt=" + target.getLastTargetQuery(), 0);
|
||||
@@ -296,7 +306,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target by metadata
|
||||
*/
|
||||
@Test void testFilterByMetadata() {
|
||||
@Test
|
||||
void testFilterByMetadata() {
|
||||
targetManagement.createMetadata(testdataFactory.createTarget().getControllerId(), Map.of("key.dot", "value.dot"));
|
||||
|
||||
assertRSQLQuery(TargetFields.METADATA.name() + ".metaKey==metaValue", 1);
|
||||
@@ -363,7 +374,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter based on more complex RSQL queries
|
||||
*/
|
||||
@Test void testFilterByComplexQueries() {
|
||||
@Test
|
||||
void testFilterByComplexQueries() {
|
||||
assertRSQLQuery(TargetFields.NAME.name() + "!=targetName123" + AND + TargetFields.METADATA.name() + ".metaKey!=value", 0);
|
||||
assertRSQLQuery(
|
||||
"(" + TargetFields.TAG.name() + "!=TAG1" + OR + TargetFields.TAG.name() + "!=TAG2)" +
|
||||
@@ -373,7 +385,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Testing allowed RSQL keys based on TargetFields definition
|
||||
*/
|
||||
@Test void rsqlValidTargetFields() {
|
||||
@Test
|
||||
void rsqlValidTargetFields() {
|
||||
RSQLUtility.validateRsqlFor(
|
||||
"ID == '0123' and NAME == abcd and DESCRIPTION == absd and CREATEDAT =lt= 0123 and LASTMODIFIEDAT =gt= 0123" +
|
||||
" and CONTROLLERID == 0123 and UPDATESTATUS == PENDING and IPADDRESS == 0123 and LASTCONTROLLERREQUESTAT == 0123" +
|
||||
@@ -401,7 +414,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter by target type key
|
||||
*/
|
||||
@Test void shouldFilterTargetsByTypeKey() {
|
||||
@Test
|
||||
void shouldFilterTargetsByTypeKey() {
|
||||
assertRSQLQuery("targettype." + TargetTypeFields.KEY.name() + "==" + targetType1.getKey(), 1);
|
||||
assertRSQLQuery("targettype." + TargetTypeFields.KEY.name() + "==*1.key", 1);
|
||||
assertRSQLQuery("targettype." + TargetTypeFields.KEY.name() + "!=" + targetType2.getKey(), 4);
|
||||
@@ -411,7 +425,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter by target type name
|
||||
*/
|
||||
@Test void shouldFilterTargetsByTypeName() {
|
||||
@Test
|
||||
void shouldFilterTargetsByTypeName() {
|
||||
assertRSQLQuery("targettype." + TargetTypeFields.NAME.name() + "==" + targetType1.getName(), 1);
|
||||
assertRSQLQuery("targettype." + TargetTypeFields.NAME.name() + "==*1", 1);
|
||||
assertRSQLQuery("targettype." + TargetTypeFields.NAME.name() + "!=" + targetType2.getName(), 4);
|
||||
@@ -421,7 +436,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter by target type ID and description
|
||||
*/
|
||||
@Test void shouldFilterTargetsByTypeIdAndDescription() {
|
||||
@Test
|
||||
void shouldFilterTargetsByTypeIdAndDescription() {
|
||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.isThrownBy(() -> assertRSQLQuery("targettype.ID==1", 0));
|
||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
|
||||
@@ -54,7 +54,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target filter query by id
|
||||
*/
|
||||
@Test void testFilterByParameterId() {
|
||||
@Test
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==" + filter1.getId(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "!=" + filter1.getId(), 2);
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==" + -1, 0);
|
||||
@@ -73,7 +74,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target filter query by name
|
||||
*/
|
||||
@Test void testFilterByParameterName() {
|
||||
@Test
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==" + filter1.getName(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==" + filter2.getName(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==filter_*", 3);
|
||||
@@ -85,7 +87,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target filter query by auto assigned ds name
|
||||
*/
|
||||
@Test void testFilterByAutoAssignedDsName() {
|
||||
@Test
|
||||
void testFilterByAutoAssignedDsName() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".name=="
|
||||
+ filter1.getAutoAssignDistributionSet().getName(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".name=="
|
||||
@@ -101,7 +104,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test filter target filter query by auto assigned ds version
|
||||
*/
|
||||
@Test void testFilterByAutoAssignedDsVersion() {
|
||||
@Test
|
||||
void testFilterByAutoAssignedDsVersion() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".version=="
|
||||
+ TestdataFactory.DEFAULT_VERSION, 2);
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".version==*1*", 2);
|
||||
|
||||
@@ -364,7 +364,8 @@ class RSQLUtilityTest {
|
||||
/**
|
||||
* Tests the resolution of overdue_ts placeholder in context of a RSQL expression.
|
||||
*/
|
||||
@Test void correctRsqlWithOverdueMacro() {
|
||||
@Test
|
||||
void correctRsqlWithOverdueMacro() {
|
||||
reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
final String overdueProp = "overdue_ts";
|
||||
final String overduePropPlaceholder = "${" + overdueProp + "}";
|
||||
@@ -387,7 +388,8 @@ class RSQLUtilityTest {
|
||||
/**
|
||||
* Tests RSQL expression with an unknown placeholder.
|
||||
*/
|
||||
@Test void correctRsqlWithUnknownMacro() {
|
||||
@Test
|
||||
void correctRsqlWithUnknownMacro() {
|
||||
reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
final String overdueProp = "unknown";
|
||||
final String overduePropPlaceholder = "${" + overdueProp + "}";
|
||||
|
||||
@@ -63,7 +63,8 @@ class VirtualPropertyResolverTest {
|
||||
/**
|
||||
* Tests VirtualPropertyResolver with a placeholder unknown to VirtualPropertyResolver.
|
||||
*/
|
||||
@Test void handleUnknownPlaceholder() {
|
||||
@Test
|
||||
void handleUnknownPlaceholder() {
|
||||
final String placeholder = "${unknown}";
|
||||
final String testString = "lhs=lt=" + placeholder;
|
||||
|
||||
@@ -74,7 +75,8 @@ class VirtualPropertyResolverTest {
|
||||
/**
|
||||
* Tests escape mechanism for placeholders (syntax is $${SOME_PLACEHOLDER}).
|
||||
*/
|
||||
@Test void handleEscapedPlaceholder() {
|
||||
@Test
|
||||
void handleEscapedPlaceholder() {
|
||||
final String placeholder = "${OVERDUE_TS}";
|
||||
final String escapedPlaceholder = StringSubstitutor.DEFAULT_ESCAPE + placeholder;
|
||||
final String testString = "lhs=lt=" + escapedPlaceholder;
|
||||
|
||||
@@ -39,7 +39,8 @@ class SpecificationsBuilderTest {
|
||||
/**
|
||||
* Test the combination of specs on an empty list which returns null
|
||||
*/
|
||||
@Test void combineWithAndEmptyList() {
|
||||
@Test
|
||||
void combineWithAndEmptyList() {
|
||||
final List<Specification<Object>> specList = Collections.emptyList();
|
||||
assertThat(SpecificationsBuilder.combineWithAnd(specList)).isNull();
|
||||
}
|
||||
@@ -47,7 +48,8 @@ class SpecificationsBuilderTest {
|
||||
/**
|
||||
* Test the combination of specs on an immutable list with one entry
|
||||
*/
|
||||
@Test void combineWithAndSingleImmutableList() {
|
||||
@Test
|
||||
void combineWithAndSingleImmutableList() {
|
||||
final Specification<Object> spec = (root, query, cb) -> cb.equal(root.get("field1"), "testValue");
|
||||
final List<Specification<Object>> specList = Collections.singletonList(spec);
|
||||
final Specification<Object> specifications = SpecificationsBuilder.combineWithAnd(specList);
|
||||
@@ -72,7 +74,8 @@ class SpecificationsBuilderTest {
|
||||
/**
|
||||
* Test the combination of specs on a list with multiple entries
|
||||
*/
|
||||
@Test void combineWithAndList() {
|
||||
@Test
|
||||
void combineWithAndList() {
|
||||
final Specification<Object> spec1 = (root, query, cb) -> cb.equal(root.get("field1"), "testValue1");
|
||||
final Specification<Object> spec2 = (root, query, cb) -> cb.equal(root.get("field2"), "testValue2");
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that multiple targets with same controller-ID can be created for different tenants.
|
||||
*/
|
||||
@Test void createMultipleTargetsWithSameIdForDifferentTenant() throws Exception {
|
||||
@Test
|
||||
void createMultipleTargetsWithSameIdForDifferentTenant() throws Exception {
|
||||
// known controller ID for overall tenants same
|
||||
final String knownControllerId = "controllerId";
|
||||
|
||||
@@ -65,7 +66,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that targets created by a tenant are not visible by another tenant.
|
||||
*/
|
||||
@Test @WithUser(tenantId = "mytenant", allSpPermissions = true)
|
||||
@Test
|
||||
@WithUser(tenantId = "mytenant", allSpPermissions = true)
|
||||
void queryTargetFromDifferentTenantIsNotVisible() throws Exception {
|
||||
// create target for another tenant
|
||||
final String anotherTenant = "anotherTenant";
|
||||
@@ -86,7 +88,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that tenant with proper permissions can read and delete other tenants.
|
||||
*/
|
||||
@Test @WithUser(tenantId = "mytenant", allSpPermissions = true)
|
||||
@Test
|
||||
@WithUser(tenantId = "mytenant", allSpPermissions = true)
|
||||
void deleteAnotherTenantPossible() throws Exception {
|
||||
// create target for another tenant
|
||||
final String anotherTenant = "anotherTenant";
|
||||
@@ -103,7 +106,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that tenant metadata is retrieved for the current tenant.
|
||||
*/
|
||||
@Test @WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true)
|
||||
@Test
|
||||
@WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true)
|
||||
void getTenanatMetdata() throws Exception {
|
||||
|
||||
// logged in tenant mytenant - check if tenant default data is
|
||||
@@ -124,7 +128,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that targets created from a different tenant cannot be deleted from other tenants
|
||||
*/
|
||||
@Test @WithUser(tenantId = "mytenant", allSpPermissions = true)
|
||||
@Test
|
||||
@WithUser(tenantId = "mytenant", allSpPermissions = true)
|
||||
void deleteTargetFromOtherTenantIsNotPossible() throws Exception {
|
||||
// create target for another tenant
|
||||
final String anotherTenant = "anotherTenant";
|
||||
@@ -151,7 +156,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Ensures that multiple distribution sets with same name and version can be created for different tenants.
|
||||
*/
|
||||
@Test void createMultipleDistributionSetsWithSameNameForDifferentTenants() throws Exception {
|
||||
@Test
|
||||
void createMultipleDistributionSetsWithSameNameForDifferentTenants() throws Exception {
|
||||
|
||||
// known tenant names
|
||||
final String tenant = "aTenant";
|
||||
|
||||
Reference in New Issue
Block a user