Fine grained repository permissions (#2562)
1. Introduce @PrreAuthorize check based on hasPermission - allowing custom processing (compared with non-modifiable hasAuthority/Role processing) 2. Dedicated permissions could be implemented on management api level. Check is made by plugged in PermissionEvaluator 3. Thus common XXX_REPOSITORY permissions could differ for extending services 4. Change create/update entity builder pattern - not via EntityFactory but via clean static lombok based builders (with fine fluent api). 5. Implement abstract repository management jpa class that handles the boilerplate code from extending classes in single place consistently -> AbsreactJpaRepositoryManagement 6. Register management api-s as **Sevice**-s instead of **Bean**-s in order to make easier maintainable and get away from heavy argument forwading 7. Simplify custom hawkbit repository registration + adding proxy to handle exception mapping at lower level - thus not depending on Aspects for converting exceptions 8. Implemented general purpose 'copy' utility (ObjectCopyUtil) that using getter/setter patterns is able to copy (e.g. Create/Update) objects to other objects (e.g. JPA entity objects)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement.Create;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -31,6 +32,9 @@ class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTest<Dist
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||
Create.builder()
|
||||
.type(distributionSetTypeManagement.findByKey("os").orElseThrow())
|
||||
.name("incomplete").version("2").description("incomplete")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement.Create;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -38,6 +39,6 @@ class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest<Distribu
|
||||
|
||||
@Override
|
||||
protected DistributionSetTag createEntity() {
|
||||
return distributionSetTagManagement.create(entityFactory.tag().create().name("tag1"));
|
||||
return distributionSetTagManagement.create(Create.builder().name("tag1").build());
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement.Create;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -36,6 +37,9 @@ class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTest<Dist
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||
Create.builder()
|
||||
.type(distributionSetTypeManagement.findByKey("os").orElseThrow())
|
||||
.name("incomplete").version("2").description("incomplete")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,10 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
@@ -38,10 +40,16 @@ class RolloutEventTest extends AbstractRemoteEntityEventTest<Rollout> {
|
||||
protected Rollout createEntity() {
|
||||
testdataFactory.createTarget("12345");
|
||||
final SoftwareModule module = softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().name("swm").version("2").description("desc").type("os"));
|
||||
SoftwareModuleManagement.Create.builder()
|
||||
.type(softwareModuleTypeManagement.findByKey("os").orElseThrow())
|
||||
.name("swm").version("2").description("desc")
|
||||
.build());
|
||||
final DistributionSet ds = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("complete").version("2").description("complete")
|
||||
.type("os").modules(Collections.singletonList(module.getId())));
|
||||
.create(DistributionSetManagement.Create.builder()
|
||||
.type(distributionSetTypeManagement.findByKey("os").orElseThrow())
|
||||
.name("complete").version("2").description("complete")
|
||||
.modules(Set.of(module))
|
||||
.build());
|
||||
|
||||
return rolloutManagement.create(
|
||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").distributionSetId(ds),
|
||||
|
||||
@@ -11,9 +11,11 @@ package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
@@ -79,12 +81,16 @@ class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<RolloutGroup>
|
||||
protected RolloutGroup createEntity() {
|
||||
testdataFactory.createTarget(UUID.randomUUID().toString());
|
||||
final SoftwareModule module = softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().name("swm").version("2").description("desc").type("os"));
|
||||
SoftwareModuleManagement.Create.builder()
|
||||
.type(softwareModuleTypeManagement.findByKey("os").orElseThrow())
|
||||
.name("swm").version("2").description("desc")
|
||||
.build());
|
||||
final DistributionSet ds = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create()
|
||||
.name("complete").version("2")
|
||||
.description("complete").type("os")
|
||||
.modules(List.of(module.getId())));
|
||||
.create(DistributionSetManagement.Create.builder()
|
||||
.type(distributionSetTypeManagement.findByKey("os").orElseThrow())
|
||||
.name("complete").version("2").description("complete")
|
||||
.modules(Set.of(module))
|
||||
.build());
|
||||
|
||||
final Rollout entity = rolloutManagement.create(
|
||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").distributionSetId(ds),
|
||||
|
||||
@@ -176,16 +176,14 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
targets.stream().map(Target::getControllerId).toList(), tag.getId());
|
||||
}
|
||||
|
||||
protected List<DistributionSet> assignTag(final Collection<DistributionSet> sets,
|
||||
protected List<? extends DistributionSet> assignTag(final Collection<? extends DistributionSet> sets,
|
||||
final DistributionSetTag tag) {
|
||||
return distributionSetManagement.assignTag(
|
||||
sets.stream().map(DistributionSet::getId).toList(), tag.getId());
|
||||
return distributionSetManagement.assignTag(sets.stream().map(DistributionSet::getId).toList(), tag.getId());
|
||||
}
|
||||
|
||||
protected List<DistributionSet> unassignTag(final Collection<DistributionSet> sets,
|
||||
final DistributionSetTag tag) {
|
||||
return distributionSetManagement.unassignTag(
|
||||
sets.stream().map(DistributionSet::getId).toList(), tag.getId());
|
||||
protected List<? extends DistributionSet> unassignTag(
|
||||
final Collection<DistributionSet> sets, final DistributionSetTag tag) {
|
||||
return distributionSetManagement.unassignTag(sets.stream().map(DistributionSet::getId).toList(), tag.getId());
|
||||
}
|
||||
|
||||
protected TargetTypeAssignmentResult initiateTypeAssignment(final Collection<Target> targets, final TargetType type) {
|
||||
@@ -278,7 +276,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
|
||||
/**
|
||||
* Asserts that the given callable succeeds.
|
||||
*
|
||||
* </p>
|
||||
* Note: This method will assume that EntityNotFoundException is OK, as security tests use dummy (non-existing) IDs.
|
||||
* It matters to either callable succeeds without any exception or at most EntityNotFoundException.
|
||||
* All other cases will be considered as an error.
|
||||
@@ -288,7 +286,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
private void assertPermissionWorks(final Callable<?> callable) {
|
||||
try {
|
||||
callable.call();
|
||||
} catch (Throwable th) {
|
||||
} catch (final Throwable th) {
|
||||
if (th instanceof EntityNotFoundException) {
|
||||
log.info("Expected (at most) EntityNotFoundException catch: {}", th.getMessage());
|
||||
} else {
|
||||
@@ -298,8 +296,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
}
|
||||
|
||||
protected void finishAction(final Action action) {
|
||||
controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).status(Action.Status.FINISHED));
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).status(Action.Status.FINISHED));
|
||||
}
|
||||
|
||||
protected Set<TargetTag> getTargetTags(final String controllerId) {
|
||||
@@ -313,4 +310,4 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
private JpaRollout refresh(final Rollout rollout) {
|
||||
return rolloutRepository.findById(rollout.getId()).get();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,13 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.Identifiable;
|
||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends AbstractJpaIntegrationTest {
|
||||
public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEntity, C, U extends Identifiable<Long>> extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
* @return the repository management to test with
|
||||
@@ -127,5 +129,4 @@ public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends
|
||||
void findByRsqlPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.Identifiable;
|
||||
import org.eclipse.hawkbit.repository.builder.AutoAssignDistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
@@ -184,8 +185,10 @@ class DistributionSetAccessControllerTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet permitted = testdataFactory.createDistributionSet();
|
||||
final DistributionSet readOnly = testdataFactory.createDistributionSet();
|
||||
final DistributionSet hidden = testdataFactory.createDistributionSet();
|
||||
final Long dsTagId = distributionSetTagManagement.create(entityFactory.tag().create().name("dsTag")).getId();
|
||||
final Long dsTag2Id = distributionSetTagManagement.create(entityFactory.tag().create().name("dsTag2")).getId();
|
||||
final Long dsTagId = distributionSetTagManagement.create(
|
||||
DistributionSetTagManagement.Create.builder().name("dsTag").build()).getId();
|
||||
final Long dsTag2Id = distributionSetTagManagement.create(
|
||||
DistributionSetTagManagement.Create.builder().name("dsTag2").build()).getId();
|
||||
|
||||
// perform tag assignment before setting access rules
|
||||
distributionSetManagement.assignTag(Arrays.asList(permitted.getId(), readOnly.getId(), hidden.getId()), dsTagId);
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement.Create;
|
||||
import org.eclipse.hawkbit.repository.builder.AutoAssignDistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
@@ -251,8 +252,10 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
void checkAutoAssignWithFailures() {
|
||||
|
||||
// incomplete distribution set that will be assigned
|
||||
final DistributionSet setF = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("dsA").version("1").type(testdataFactory.findOrCreateDefaultTestDsType()));
|
||||
final DistributionSet setF = distributionSetManagement.create(Create.builder()
|
||||
.type(testdataFactory.findOrCreateDefaultTestDsType())
|
||||
.name("dsA").version("1")
|
||||
.build());
|
||||
final DistributionSet setA = testdataFactory.createDistributionSet("dsA");
|
||||
final DistributionSet setB = testdataFactory.createDistributionSet("dsB");
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.event.TenantAwareEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
|
||||
@@ -211,7 +212,7 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
void softwareModuleUpdateEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
softwareModuleManagement
|
||||
.update(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
.update(SoftwareModuleManagement.Update.builder().id(softwareModule.getId()).description("New").build());
|
||||
|
||||
final SoftwareModuleUpdatedEvent softwareModuleUpdatedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleUpdatedEvent.class);
|
||||
@@ -267,5 +268,4 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -660,9 +660,9 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// create two artifacts with identical SHA1 hash
|
||||
final Artifact artifact = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
|
||||
ds.findFirstModuleByType(osType).get().getId(), "file1", false, artifactSize));
|
||||
findFirstModuleByType(ds, osType).orElseThrow().getId(), "file1", false, artifactSize));
|
||||
final Artifact artifact2 = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
|
||||
ds2.findFirstModuleByType(osType).get().getId(), "file1", false, artifactSize));
|
||||
findFirstModuleByType(ds2, osType).orElseThrow().getId(), "file1", false, artifactSize));
|
||||
assertThat(artifact.getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
|
||||
|
||||
assertThat(
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Set;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.im.authentication.SpRole;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation;
|
||||
@@ -291,8 +292,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void cancelActionsForDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
deploymentManagement.cancelActionsForDistributionSet(DistributionSetInvalidation.CancelationType.FORCE,
|
||||
entityFactory.distributionSet().create().build());
|
||||
deploymentManagement.cancelActionsForDistributionSet(
|
||||
DistributionSetInvalidation.CancelationType.FORCE, new JpaDistributionSet());
|
||||
return null;
|
||||
}, List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import lombok.Getter;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.MultiActionCancelEvent;
|
||||
@@ -129,7 +131,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that management get access react as specified on calls for non existing entities by means
|
||||
* Verifies that management get access react as specified on calls for non existing entities by means
|
||||
* of Optional not present.
|
||||
*/
|
||||
@Test
|
||||
@@ -140,8 +142,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that management queries react as specified on calls for non existing entities
|
||||
* by means of throwing EntityNotFoundException.
|
||||
* Verifies that management queries react as specified on calls for non existing entities
|
||||
* by means of throwing EntityNotFoundException.
|
||||
*/
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
@@ -298,7 +300,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// not exists
|
||||
assignDS.add(100_000L);
|
||||
|
||||
final Long tagId = distributionSetTagManagement.create(entityFactory.tag().create().name("Tag1")).getId();
|
||||
final Long tagId = distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("Tag1").build()).getId();
|
||||
|
||||
assertThatExceptionOfType(EntityNotFoundException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.assignTag(assignDS, tagId))
|
||||
@@ -321,7 +323,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
|
||||
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
|
||||
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6) })
|
||||
// implicit lock })
|
||||
// implicit lock
|
||||
void multiAssigmentHistoryOverMultiplePagesResultsInTwoActiveAction() {
|
||||
final DistributionSet cancelDs = testdataFactory.createDistributionSet("Canceled DS", "1.0", Collections.emptyList());
|
||||
final DistributionSet cancelDs2 = testdataFactory.createDistributionSet("Canceled DS", "1.2", Collections.emptyList());
|
||||
@@ -336,7 +338,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels multiple active actions on a target. Expected behaviour is that with two active
|
||||
* Cancels multiple active actions on a target. Expected behaviour is that with two active
|
||||
* After canceling the first one also the target goes back to IN_SYNC as no open action is left.
|
||||
*/
|
||||
@Test
|
||||
@@ -384,7 +386,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels multiple active actions on a target. Expected behaviour is that with two active
|
||||
* Cancels multiple active actions on a target. Expected behaviour is that with two active
|
||||
* also the target goes back to IN_SYNC as no open action is left.
|
||||
*/
|
||||
@Test
|
||||
@@ -497,7 +499,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple offline deployment of a distribution set to a list of targets. Verifies that offline assigment
|
||||
* Simple offline deployment of a distribution set to a list of targets. Verifies that offline assigment
|
||||
* is correctly executed for targets that do not have a running update already. Those are ignored.
|
||||
*/
|
||||
@Test
|
||||
@@ -848,9 +850,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.contains("Assignment initiated by user 'bumlux'")
|
||||
.contains("""
|
||||
Assignment automatically confirmed by initiator 'not_bumlux'.\s
|
||||
|
||||
|
||||
Auto confirmation activated by system user: 'bumlux'\s
|
||||
|
||||
|
||||
Remark: my personal remark""");
|
||||
} else {
|
||||
// assignment never required confirmation, auto-confirmation will not be
|
||||
@@ -1141,8 +1143,12 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final DistributionSet incomplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("v1").type(standardDsType).modules(Collections.singletonList(ah.getId())));
|
||||
final DistributionSet incomplete = distributionSetManagement.create(
|
||||
DistributionSetManagement.Create.builder()
|
||||
.type(standardDsType)
|
||||
.name("incomplete").version("v1")
|
||||
.modules(Set.of(ah))
|
||||
.build());
|
||||
|
||||
assertThatExceptionOfType(IncompleteDistributionSetException.class)
|
||||
.as("expected IncompleteDistributionSetException")
|
||||
@@ -1156,7 +1162,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple deployments or distribution set to target assignment test. Expected behaviour is that a new deployment
|
||||
* Multiple deployments or distribution set to target assignment test. Expected behaviour is that a new deployment
|
||||
* overides unfinished old one which are canceled as part of the operation.
|
||||
*/
|
||||
@Test
|
||||
@@ -1222,7 +1228,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple deployments or distribution set to target assignment test including finished response
|
||||
* Multiple deployments or distribution set to target assignment test including finished response
|
||||
* IN_SYNC status and installed DS is set to the assigned DS entry.
|
||||
*/
|
||||
@Test
|
||||
@@ -1317,12 +1323,11 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
* or {@link Target#getInstalledDistributionSet()}
|
||||
*/
|
||||
/**
|
||||
* Deletes distribution set. Expected behaviour is that a soft delete is performed
|
||||
* Deletes distribution set. Expected behaviour is that a soft delete is performed
|
||||
* if the DS is assigned to a target and a hard delete if the DS is not in use at all.
|
||||
*/
|
||||
@Test
|
||||
void deleteDistributionSet() {
|
||||
|
||||
final PageRequest pageRequest = PageRequest.of(0, 100, Direction.ASC, "id");
|
||||
|
||||
final String undeployedTargetPrefix = "undep-T";
|
||||
@@ -1351,7 +1356,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
// verify that deleted attribute is used correctly
|
||||
List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(true, PAGE).getContent();
|
||||
List<? extends DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(true, PAGE).getContent();
|
||||
assertThat(allFoundDS).as("no ds should be founded").isEmpty();
|
||||
|
||||
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||
@@ -1359,7 +1364,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||
|
||||
IntStream.range(0, deploymentResult.getDistributionSets().size()).forEach(i -> testdataFactory.sendUpdateActionStatusToTargets(
|
||||
deploymentResult.getDeployedTargets(), Status.FINISHED, Collections.singletonList("blabla alles gut")));
|
||||
deploymentResult.getDeployedTargets(), Status.FINISHED, Collections.singletonList("blabla alles gut")));
|
||||
|
||||
// try to delete again
|
||||
distributionSetManagement.delete(deploymentResult.getDistributionSetIDs());
|
||||
@@ -1391,7 +1396,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
deployedTargetPrefix, noOfDeployedTargets, noOfDistributionSets, "myTestDS");
|
||||
|
||||
IntStream.range(0, deploymentResult.getDistributionSets().size()).forEach(i -> testdataFactory.sendUpdateActionStatusToTargets(
|
||||
deploymentResult.getDeployedTargets(), Status.FINISHED, Collections.singletonList("blabla alles gut")));
|
||||
deploymentResult.getDeployedTargets(), Status.FINISHED, Collections.singletonList("blabla alles gut")));
|
||||
|
||||
assertThat(targetManagement.count()).as("size of targets is wrong").isNotZero();
|
||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero();
|
||||
@@ -1479,7 +1484,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
* The test verifies that the DS itself is not changed because of an target assignment
|
||||
* which is a relationship but not a changed on the entity itself..
|
||||
* which is a relationship but not a changed on the entity itself..
|
||||
*/
|
||||
@Test
|
||||
void checkThatDsRevisionsIsNotChangedWithTargetAssignment() {
|
||||
|
||||
@@ -13,12 +13,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractRepositoryManagementSecurityTest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -26,22 +26,22 @@ import org.junit.jupiter.api.Test;
|
||||
* Story: SecurityTests DistributionSetManagement
|
||||
*/
|
||||
class DistributionSetManagementSecurityTest
|
||||
extends AbstractRepositoryManagementSecurityTest<DistributionSet, DistributionSetCreate, DistributionSetUpdate> {
|
||||
extends AbstractRepositoryManagementSecurityTest<DistributionSet, DistributionSetManagement.Create, DistributionSetManagement.Update> {
|
||||
|
||||
@Override
|
||||
protected RepositoryManagement<DistributionSet, DistributionSetCreate, DistributionSetUpdate> getRepositoryManagement() {
|
||||
protected DistributionSetManagement getRepositoryManagement() {
|
||||
return distributionSetManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DistributionSetCreate getCreateObject() {
|
||||
return entityFactory.distributionSet().create().name("name").version("1.0.0").type("type");
|
||||
protected DistributionSetManagement.Create getCreateObject() {
|
||||
return DistributionSetManagement.Create.builder().name("name").version("1.0.0").type(defaultDsType()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DistributionSetUpdate getUpdateObject() {
|
||||
return entityFactory.distributionSet().update(0L).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true);
|
||||
protected DistributionSetManagement.Update getUpdateObject() {
|
||||
return DistributionSetManagement.Update.builder().id(0L).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true).build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ class DistributionSetManagementSecurityTest
|
||||
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
|
||||
*/
|
||||
@Test
|
||||
void getMetadataPermissiosCheck() {
|
||||
void getMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getMetadata(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
void updateMetadataPermissionsCheck() {
|
||||
assertPermissions(() -> {
|
||||
distributionSetManagement.updateMetadata(1L,"key", "value");
|
||||
distributionSetManagement.updateMetadata(1L, "key", "value");
|
||||
return null;
|
||||
},
|
||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
@@ -287,9 +287,12 @@ class DistributionSetManagementSecurityTest
|
||||
*/
|
||||
@Test
|
||||
void invalidatePermissionsCheck() {
|
||||
distributionSetTypeManagement.create(entityFactory.distributionSetType().create().key("type").name("name"));
|
||||
final DistributionSetType dsType = distributionSetTypeManagement.create(DistributionSetTypeManagement.Create.builder()
|
||||
.key("type").name("name").build());
|
||||
final DistributionSet ds = distributionSetManagement.create(DistributionSetManagement.Create.builder()
|
||||
.type(dsType).name("test").version("1.0.0").build());
|
||||
assertPermissions(() -> {
|
||||
distributionSetManagement.invalidate(entityFactory.distributionSet().create().name("name").version("1.0").type("type").build());
|
||||
((DistributionSetManagement) distributionSetManagement).invalidate(ds);
|
||||
return null;
|
||||
}, List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -30,9 +31,10 @@ import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent;
|
||||
@@ -96,7 +98,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that management queries react as specified on calls for non existing entities by means of
|
||||
* Verifies that management queries react as specified on calls for non existing entities by means of
|
||||
* throwing EntityNotFoundException.
|
||||
*/
|
||||
@Test
|
||||
@@ -133,9 +135,6 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.unassignTag(singletonList(NOT_EXIST_IDL), dsTag.getId()), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)), "DistributionSetType");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.createMetadata(NOT_EXIST_IDL, Map.of("123", "123")), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.delete(singletonList(NOT_EXIST_IDL)), "DistributionSet");
|
||||
@@ -154,10 +153,11 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.hasMessageContaining("DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.update(entityFactory.distributionSet().update(NOT_EXIST_IDL)), "DistributionSet");
|
||||
() -> distributionSetManagement.update(DistributionSetManagement.Update.builder().id(NOT_EXIST_IDL).build()),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetadata(NOT_EXIST_IDL,"xxx", "xxx"), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetadata(set.getId(),NOT_EXIST_ID, "xxx"), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetadata(NOT_EXIST_IDL, "xxx", "xxx"), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetadata(set.getId(), NOT_EXIST_ID, "xxx"), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.getOrElseThrowException(NOT_EXIST_IDL), "DistributionSet");
|
||||
|
||||
@@ -199,7 +199,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void createDistributionSetWithImplicitType() {
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
.create(DistributionSetManagement.Create.builder().type(defaultDsType()).name("newtypesoft").version("1").build());
|
||||
|
||||
assertThat(set.getType())
|
||||
.as("Type should be equal to default type of tenant")
|
||||
@@ -212,7 +212,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void createDistributionSetWithDuplicateNameAndVersionFails() {
|
||||
final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create().name("newtypesoft").version("1");
|
||||
final DistributionSetManagement.Create distributionSetCreate =
|
||||
DistributionSetManagement.Create.builder().type(defaultDsType()).name("newtypesoft").version("1").build();
|
||||
distributionSetManagement.create(distributionSetCreate);
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).isThrownBy(() -> distributionSetManagement.create(distributionSetCreate));
|
||||
@@ -223,14 +224,14 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void createMultipleDistributionSetsWithImplicitType() {
|
||||
final List<DistributionSetCreate> creates = new ArrayList<>(10);
|
||||
final List<DistributionSetManagement.Create> creates = new ArrayList<>(10);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
|
||||
creates.add(DistributionSetManagement.Create.builder().type(defaultDsType()).name("newtypesoft" + i).version("1" + i).build());
|
||||
}
|
||||
|
||||
assertThat(distributionSetManagement.create(creates))
|
||||
.as("Type should be equal to default type of tenant")
|
||||
.are(new Condition<>() {
|
||||
.are(new Condition<DistributionSet>() {
|
||||
|
||||
@Override
|
||||
public boolean matches(final DistributionSet value) {
|
||||
@@ -308,9 +309,10 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
||||
}
|
||||
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name(TAG1_NAME));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(
|
||||
DistributionSetTagManagement.Create.builder().name(TAG1_NAME).build());
|
||||
|
||||
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
|
||||
final List<? extends DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
|
||||
assertThat(assignedDS).as("assigned ds has wrong size").hasSize(4);
|
||||
assignedDS.stream().map(JpaDistributionSet.class::cast).forEach(ds -> assertThat(ds.getTags())
|
||||
.as("ds has wrong tag size")
|
||||
@@ -362,7 +364,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isInstanceOf(EntityReadOnlyException.class);
|
||||
|
||||
// not allowed as it is assigned now
|
||||
final Long appId = getOrThrow(ds.findFirstModuleByType(appType)).getId();
|
||||
final Long appId = getOrThrow(findFirstModuleByType(ds, appType)).getId();
|
||||
assertThatThrownBy(() -> distributionSetManagement.unassignSoftwareModule(dsId, appId))
|
||||
.isInstanceOf(EntityReadOnlyException.class);
|
||||
}
|
||||
@@ -373,17 +375,22 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void updateDistributionSetUnsupportedModuleFails() {
|
||||
final Long setId = distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create()
|
||||
DistributionSetManagement.Create.builder()
|
||||
.type(distributionSetTypeManagement.create(
|
||||
entityFactory.distributionSetType().create()
|
||||
DistributionSetTypeManagement.Create.builder()
|
||||
.key("test")
|
||||
.name("test")
|
||||
.mandatory(singletonList(osType.getId()))).getKey())
|
||||
.mandatoryModuleTypes(Set.of(osType))
|
||||
.build()))
|
||||
.name("agent-hub2")
|
||||
.version("1.0.5")).getId();
|
||||
.version("1.0.5")
|
||||
.build()).getId();
|
||||
|
||||
final Set<Long> moduleId = Set.of(softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().name("agent-hub2").version("1.0.5").type(appType.getKey())).getId());
|
||||
SoftwareModuleManagement.Create.builder()
|
||||
.type(appType)
|
||||
.name("agent-hub2").version("1.0.5")
|
||||
.build()).getId());
|
||||
|
||||
// update data
|
||||
assertThatThrownBy(() -> distributionSetManagement.assignSoftwareModules(setId, moduleId))
|
||||
@@ -403,17 +410,17 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// legal update of module addition
|
||||
distributionSetManagement.assignSoftwareModules(ds.getId(), Set.of(os.getId()));
|
||||
ds = getOrThrow(distributionSetManagement.getWithDetails(ds.getId()));
|
||||
assertThat(getOrThrow(ds.findFirstModuleByType(osType))).isEqualTo(os);
|
||||
assertThat(getOrThrow(findFirstModuleByType(ds, osType))).isEqualTo(os);
|
||||
|
||||
// legal update of module removal
|
||||
distributionSetManagement.unassignSoftwareModule(ds.getId(),
|
||||
getOrThrow(ds.findFirstModuleByType(appType)).getId());
|
||||
getOrThrow(findFirstModuleByType(ds, appType)).getId());
|
||||
ds = getOrThrow(distributionSetManagement.getWithDetails(ds.getId()));
|
||||
assertThat(ds.findFirstModuleByType(appType)).isNotPresent();
|
||||
assertThat(findFirstModuleByType(ds, appType)).isNotPresent();
|
||||
|
||||
// Update description
|
||||
distributionSetManagement.update(entityFactory.distributionSet().update(ds.getId()).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true));
|
||||
distributionSetManagement.update(DistributionSetManagement.Update.builder().id(ds.getId()).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true).build());
|
||||
ds = getOrThrow(distributionSetManagement.getWithDetails(ds.getId()));
|
||||
assertThat(ds.getDescription()).isEqualTo("a new description");
|
||||
assertThat(ds.getName()).isEqualTo("a new name");
|
||||
@@ -428,7 +435,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
void updateInvalidDistributionSet() {
|
||||
final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet();
|
||||
|
||||
final DistributionSetUpdate update = entityFactory.distributionSet().update(distributionSet.getId()).name("new_name");
|
||||
final DistributionSetManagement.Update update =
|
||||
DistributionSetManagement.Update.builder().id(distributionSet.getId()).name("new_name").build();
|
||||
assertThatExceptionOfType(InvalidDistributionSetException.class)
|
||||
.as("Invalid distributionSet should throw an exception").isThrownBy(() -> distributionSetManagement.update(update));
|
||||
}
|
||||
@@ -548,22 +556,23 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void searchDistributionSetsOnFilters() {
|
||||
DistributionSetTag dsTagA = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-A"));
|
||||
.create(DistributionSetTagManagement.Create.builder().name("DistributionSetTag-A").build());
|
||||
final DistributionSetTag dsTagB = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-B"));
|
||||
.create(DistributionSetTagManagement.Create.builder().name("DistributionSetTag-B").build());
|
||||
final DistributionSetTag dsTagC = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||
.create(DistributionSetTagManagement.Create.builder().name("DistributionSetTag-C").build());
|
||||
distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("DistributionSetTag-D").build());
|
||||
|
||||
List<DistributionSet> dsGroup1 = testdataFactory.createDistributionSets("", 5);
|
||||
List<? extends DistributionSet> dsGroup1 = testdataFactory.createDistributionSets("", 5);
|
||||
final String dsGroup2Prefix = "test";
|
||||
List<DistributionSet> dsGroup2 = testdataFactory.createDistributionSets(dsGroup2Prefix, 5);
|
||||
List<? extends DistributionSet> dsGroup2 = testdataFactory.createDistributionSets(dsGroup2Prefix, 5);
|
||||
DistributionSet dsDeleted = testdataFactory.createDistributionSet("testDeleted");
|
||||
final DistributionSet dsInComplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||
final DistributionSet dsInComplete = distributionSetManagement.create(
|
||||
DistributionSetManagement.Create.builder()
|
||||
.name("notcomplete").version("1").type(standardDsType).build());
|
||||
|
||||
DistributionSetType newType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("foo").name("bar").description("test"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("foo").name("bar").description("test").build());
|
||||
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(newType.getId(),
|
||||
singletonList(osType.getId()));
|
||||
@@ -571,8 +580,11 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
Arrays.asList(appType.getId(), runtimeType.getId()));
|
||||
|
||||
final DistributionSet dsNewType = distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("newtype").version("1").type(newType.getKey()).modules(
|
||||
dsDeleted.getModules().stream().map(SoftwareModule::getId).toList()));
|
||||
DistributionSetManagement.Create.builder()
|
||||
.type(newType)
|
||||
.name("newtype").version("1")
|
||||
.modules(new HashSet<>(dsDeleted.getModules()))
|
||||
.build());
|
||||
|
||||
assignDistributionSet(dsDeleted, testdataFactory.createTargets(5));
|
||||
distributionSetManagement.delete(dsDeleted.getId());
|
||||
@@ -585,10 +597,10 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
dsGroup2 = assignTag(dsGroup2, dsTagA);
|
||||
dsTagA = getOrThrow(distributionSetTagRepository.findByNameEquals(dsTagA.getName()));
|
||||
|
||||
final List<DistributionSet> allDistributionSets = Stream
|
||||
final List<? extends DistributionSet> allDistributionSets = Stream
|
||||
.of(dsGroup1, dsGroup2, Arrays.asList(dsDeleted, dsInComplete, dsNewType)).flatMap(Collection::stream)
|
||||
.toList();
|
||||
final List<DistributionSet> dsGroup1WithGroup2 = Stream.of(dsGroup1, dsGroup2).flatMap(Collection::stream)
|
||||
final List<? extends DistributionSet> dsGroup1WithGroup2 = Stream.of(dsGroup1, dsGroup2).flatMap(Collection::stream)
|
||||
.toList();
|
||||
final int sizeOfAllDistributionSets = allDistributionSets.size();
|
||||
|
||||
@@ -604,8 +616,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
validateDeletedAndCompleted(dsGroup1WithGroup2, dsNewType, dsDeleted);
|
||||
validateDeletedAndCompletedAndType(dsGroup1WithGroup2, dsDeleted, newType, dsNewType);
|
||||
validateDeletedAndCompletedAndTypeAndSearchText(dsGroup2, newType, dsGroup2Prefix);
|
||||
validateDeletedAndCompletedAndTypeAndSearchText(dsGroup1WithGroup2, dsDeleted, dsInComplete, dsNewType, newType,
|
||||
":1");
|
||||
validateDeletedAndCompletedAndTypeAndSearchText(dsGroup1WithGroup2, dsDeleted, dsInComplete, dsNewType, newType, ":1");
|
||||
validateDeletedAndCompletedAndTypeAndSearchTextAndTag(dsGroup2, dsTagA, dsGroup2Prefix);
|
||||
}
|
||||
|
||||
@@ -729,21 +740,22 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
/**
|
||||
* Test implicit locks for a DS and skip tags.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
void isImplicitLockApplicableForDistributionSet() {
|
||||
final JpaDistributionSetManagement distributionSetManagement = (JpaDistributionSetManagement) this.distributionSetManagement;
|
||||
final JpaDistributionSetManagement distributionSetManagement = (JpaDistributionSetManagement) (DistributionSetManagement) this.distributionSetManagement;
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-non-skip");
|
||||
// assert that implicit lock is applicable for non skip tags
|
||||
assertThat(distributionSetManagement.isImplicitLockApplicable(distributionSet)).isTrue();
|
||||
|
||||
assertThat(repositoryProperties.getSkipImplicitLockForTags().size()).isNotZero();
|
||||
final List<DistributionSetTag> skipTags = distributionSetTagManagement.create(
|
||||
final List<? extends DistributionSetTag> skipTags = distributionSetTagManagement.create(
|
||||
repositoryProperties.getSkipImplicitLockForTags().stream()
|
||||
.map(String::toLowerCase)
|
||||
// remove same in case-insensitive terms tags
|
||||
// in of case-insensitive db's it will end up as same names and constraint violation (?)
|
||||
.distinct()
|
||||
.map(skipTag -> entityFactory.tag().create().name(skipTag))
|
||||
.map(skipTag -> (DistributionSetTagManagement.Create)DistributionSetTagManagement.Create.builder().name(skipTag).build())
|
||||
.toList());
|
||||
// assert that implicit lock locks for every skip tag
|
||||
skipTags.forEach(skipTag -> {
|
||||
@@ -829,7 +841,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a DS that is in use by either target assignment or rollout. Expected behaviour is a soft delete on the database, i.e. only marked as
|
||||
* Deletes a DS that is in use by either target assignment or rollout. Expected behaviour is a soft delete on the database, i.e. only marked as
|
||||
* deleted, kept as reference but unavailable for future use..
|
||||
*/
|
||||
@Test
|
||||
@@ -874,7 +886,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createDistributionSet("test" + i);
|
||||
}
|
||||
|
||||
final List<DistributionSet> foundDs = distributionSetManagement.get(searchIds);
|
||||
final List<? extends DistributionSet> foundDs = distributionSetManagement.get(searchIds);
|
||||
|
||||
assertThat(foundDs).hasSize(3);
|
||||
|
||||
@@ -1006,91 +1018,92 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
||||
final DistributionSetCreate distributionSetCreate =
|
||||
entityFactory.distributionSet().create().name("a").version("a").description(randomString(513));
|
||||
final DistributionSetManagement.Create distributionSetCreate =
|
||||
DistributionSetManagement.Create.builder().name("a").version("a").description(randomString(513)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long description should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate2 =
|
||||
entityFactory.distributionSet().create().name("a").version("a").description(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Create distributionSetCreate2 =
|
||||
DistributionSetManagement.Create.builder().name("a").version("a").description(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with invalid description should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate2));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate =
|
||||
entityFactory.distributionSet().update(set.getId()).description(randomString(513));
|
||||
final DistributionSetManagement.Update distributionSetUpdate =
|
||||
DistributionSetManagement.Update.builder().id(set.getId()).description(randomString(513)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long description should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate2 = entityFactory.distributionSet().update(set.getId()).description(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Update distributionSetUpdate2 =
|
||||
DistributionSetManagement.Update.builder().id(set.getId()).description(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with invalid characters should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate2));
|
||||
}
|
||||
|
||||
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
||||
final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create()
|
||||
.version("a").name(randomString(NamedEntity.NAME_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Create distributionSetCreate = DistributionSetManagement.Create.builder()
|
||||
.version("a").name(randomString(NamedEntity.NAME_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate2 = entityFactory.distributionSet().create().version("a").name("");
|
||||
final DistributionSetManagement.Create distributionSetCreate2 = DistributionSetManagement.Create.builder().version("a").name("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too short name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate2));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate3 = entityFactory.distributionSet().create().version("a").name(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Create distributionSetCreate3 = DistributionSetManagement.Create.builder().version("a").name(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with invalid characters in name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate3));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate = entityFactory.distributionSet().update(set.getId())
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Update distributionSetUpdate = DistributionSetManagement.Update.builder().id(set.getId())
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate2 = entityFactory.distributionSet().update(set.getId()).name(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Update distributionSetUpdate2 = DistributionSetManagement.Update.builder().id(set.getId()).name(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with invalid characters should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate2));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate3 = entityFactory.distributionSet().update(set.getId()).name("");
|
||||
final DistributionSetManagement.Update distributionSetUpdate3 = DistributionSetManagement.Update.builder().id(set.getId()).name("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too short name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate3));
|
||||
}
|
||||
|
||||
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
||||
final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create()
|
||||
.name("a").version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Create distributionSetCreate = DistributionSetManagement.Create.builder()
|
||||
.name("a").version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate2 = entityFactory.distributionSet().create().name("a").version("");
|
||||
final DistributionSetManagement.Create distributionSetCreate2 = DistributionSetManagement.Create.builder().name("a").version("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too short version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate2));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate = entityFactory.distributionSet().update(set.getId())
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Update distributionSetUpdate = DistributionSetManagement.Update.builder().id(set.getId())
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long version should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate2 = entityFactory.distributionSet().update(set.getId()).version("");
|
||||
final DistributionSetManagement.Update distributionSetUpdate2 = DistributionSetManagement.Update.builder().id(set.getId()).version("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too short version should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate2));
|
||||
}
|
||||
|
||||
private void validateFindAll(final List<DistributionSet> expectedDistributionsets) {
|
||||
private void validateFindAll(final List<? extends DistributionSet> expectedDistributionSets) {
|
||||
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder(), expectedDistributionsets);
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder(), expectedDistributionSets);
|
||||
}
|
||||
|
||||
private void validateDeleted(final DistributionSet deletedDistributionSet, final int notDeletedSize) {
|
||||
@@ -1119,51 +1132,44 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
DistributionSetFilter.builder().typeId(standardDsType.getId()), standardDsTypeSize, dsNewType);
|
||||
}
|
||||
|
||||
private void validateSearchText(final List<DistributionSet> allDistributionSets, final String dsNamePrefix) {
|
||||
|
||||
final List<DistributionSet> withTestNamePrefix = allDistributionSets.stream()
|
||||
private void validateSearchText(final List<? extends DistributionSet> allDistributionSets, final String dsNamePrefix) {
|
||||
final List<? extends DistributionSet> withTestNamePrefix = allDistributionSets.stream()
|
||||
.filter(ds -> ds.getName().startsWith(dsNamePrefix)).toList();
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(dsNamePrefix),
|
||||
withTestNamePrefix);
|
||||
|
||||
final List<DistributionSet> withTestNameExact = withTestNamePrefix.stream()
|
||||
final List<? extends DistributionSet> withTestNameExact = withTestNamePrefix.stream()
|
||||
.filter(ds -> ds.getName().equals(dsNamePrefix)).toList();
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(
|
||||
DistributionSetFilter.builder().searchText(dsNamePrefix + ":"), withTestNameExact);
|
||||
|
||||
final List<DistributionSet> withTestNameExactAndVersionPrefix = withTestNameExact.stream()
|
||||
final List<? extends DistributionSet> withTestNameExactAndVersionPrefix = withTestNameExact.stream()
|
||||
.filter(ds -> ds.getVersion().startsWith("1")).toList();
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(
|
||||
DistributionSetFilter.builder().searchText(dsNamePrefix + ":1"),
|
||||
withTestNameExactAndVersionPrefix);
|
||||
|
||||
final List<DistributionSet> dsWithExactNameAndVersion = withTestNameExactAndVersionPrefix.stream()
|
||||
final List<? extends DistributionSet> dsWithExactNameAndVersion = withTestNameExactAndVersionPrefix.stream()
|
||||
.filter(ds -> ds.getVersion().equals("1.0.0")).toList();
|
||||
assertThat(dsWithExactNameAndVersion).hasSize(1);
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(
|
||||
DistributionSetFilter.builder().searchText(dsNamePrefix + ":1.0.0"), dsWithExactNameAndVersion);
|
||||
|
||||
final List<DistributionSet> withVersionPrefix = allDistributionSets.stream()
|
||||
final List<? extends DistributionSet> withVersionPrefix = allDistributionSets.stream()
|
||||
.filter(ds -> ds.getVersion().startsWith("1.0.")).toList();
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(":1.0."),
|
||||
withVersionPrefix);
|
||||
|
||||
final List<DistributionSet> withVersionExact = withVersionPrefix.stream()
|
||||
final List<? extends DistributionSet> withVersionExact = withVersionPrefix.stream()
|
||||
.filter(ds -> ds.getVersion().equals("1.0.0")).toList();
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(":1.0.0"),
|
||||
withVersionExact);
|
||||
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(":"),
|
||||
allDistributionSets);
|
||||
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(" : "),
|
||||
allDistributionSets);
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(":1.0.0"), withVersionExact);
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(":"), allDistributionSets);
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().searchText(" : "), allDistributionSets);
|
||||
}
|
||||
|
||||
private void validateTags(final DistributionSetTag dsTagA, final DistributionSetTag dsTagB,
|
||||
final DistributionSetTag dsTagC, final List<DistributionSet> dsWithTagA,
|
||||
final List<DistributionSet> dsWithTagB) {
|
||||
|
||||
final DistributionSetTag dsTagC, final List<? extends DistributionSet> dsWithTagA,
|
||||
final List<? extends DistributionSet> dsWithTagB) {
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(
|
||||
DistributionSetFilter.builder().tagNames(singletonList(dsTagA.getName())), dsWithTagA);
|
||||
|
||||
@@ -1182,7 +1188,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
DistributionSetFilter.builder().tagNames(singletonList(dsTagC.getName())));
|
||||
}
|
||||
|
||||
private void validateDeletedAndCompleted(final List<DistributionSet> completedStandardType,
|
||||
private void validateDeletedAndCompleted(final List<? extends DistributionSet> completedStandardType,
|
||||
final DistributionSet dsNewType, final DistributionSet dsDeleted) {
|
||||
|
||||
final List<DistributionSet> completedNotDeleted = new ArrayList<>(completedStandardType);
|
||||
@@ -1199,7 +1205,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
DistributionSetFilter.builder().isComplete(Boolean.FALSE).isDeleted(Boolean.TRUE));
|
||||
}
|
||||
|
||||
private void validateDeletedAndCompletedAndType(final List<DistributionSet> deletedAndCompletedAndStandardType,
|
||||
private void validateDeletedAndCompletedAndType(final List<? extends DistributionSet> deletedAndCompletedAndStandardType,
|
||||
final DistributionSet dsDeleted, final DistributionSetType newType, final DistributionSet dsNewType) {
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().isDeleted(Boolean.FALSE)
|
||||
.isComplete(Boolean.TRUE).typeId(standardDsType.getId()), deletedAndCompletedAndStandardType);
|
||||
@@ -1213,9 +1219,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void validateDeletedAndCompletedAndTypeAndSearchText(
|
||||
final List<DistributionSet> completedAndStandardTypeAndSearchText, final DistributionSetType newType,
|
||||
final String text) {
|
||||
|
||||
final List<? extends DistributionSet> completedAndStandardTypeAndSearchText, final DistributionSetType newType, final String text) {
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(DistributionSetFilter.builder().isDeleted(Boolean.FALSE)
|
||||
.isComplete(Boolean.TRUE).typeId(standardDsType.getId()).searchText(text),
|
||||
completedAndStandardTypeAndSearchText);
|
||||
@@ -1232,7 +1236,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void validateDeletedAndCompletedAndTypeAndSearchText(
|
||||
final List<DistributionSet> completedAndNotDeletedStandardTypeAndFilterString,
|
||||
final List<? extends DistributionSet> completedAndNotDeletedStandardTypeAndFilterString,
|
||||
final DistributionSet dsDeleted, final DistributionSet dsInComplete, final DistributionSet dsNewType,
|
||||
final DistributionSetType newType, final String filterString) {
|
||||
|
||||
@@ -1263,9 +1267,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void validateDeletedAndCompletedAndTypeAndSearchTextAndTag(
|
||||
final List<DistributionSet> completedAndStandartTypeAndSearchTextAndTagA, final DistributionSetTag dsTagA,
|
||||
final String text) {
|
||||
|
||||
final List<? extends DistributionSet> completedAndStandartTypeAndSearchTextAndTagA, final DistributionSetTag dsTagA, final String text) {
|
||||
assertThatFilterContainsOnlyGivenDistributionSets(
|
||||
DistributionSetFilter.builder().isComplete(Boolean.TRUE).typeId(standardDsType.getId())
|
||||
.searchText(text).tagNames(singletonList(dsTagA.getName())),
|
||||
@@ -1282,9 +1284,9 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertThatFilterContainsOnlyGivenDistributionSets(final DistributionSetFilterBuilder filterBuilder,
|
||||
final List<DistributionSet> distributionSets) {
|
||||
final List<? extends DistributionSet> distributionSets) {
|
||||
final int expectedDsSize = distributionSets.size();
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||
assertThat(((DistributionSetManagement)distributionSetManagement).findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||
.hasSize(expectedDsSize).containsOnly(distributionSets.toArray(new DistributionSet[expectedDsSize]));
|
||||
}
|
||||
|
||||
@@ -1295,7 +1297,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void assertThatFilterHasSizeAndDoesNotContainDistributionSet(
|
||||
final DistributionSetFilterBuilder filterBuilder, final int size, final DistributionSet ds) {
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||
assertThat(((DistributionSetManagement)distributionSetManagement).findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||
.hasSize(size).doesNotContain(ds);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,8 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractRepositoryManagementSecurityTest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -25,21 +24,22 @@ import org.springframework.data.domain.Pageable;
|
||||
* Feature: SecurityTests - DistributionSetTagManagement<br/>
|
||||
* Story: SecurityTests DistributionSetTagManagement
|
||||
*/
|
||||
class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagementSecurityTest<DistributionSetTag, TagCreate, TagUpdate> {
|
||||
class DistributionSetTagManagementSecurityTest
|
||||
extends AbstractRepositoryManagementSecurityTest<DistributionSetTag, DistributionSetTagManagement.Create, DistributionSetTagManagement.Update> {
|
||||
|
||||
@Override
|
||||
protected RepositoryManagement<DistributionSetTag, TagCreate, TagUpdate> getRepositoryManagement() {
|
||||
protected RepositoryManagement getRepositoryManagement() {
|
||||
return distributionSetTagManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TagCreate getCreateObject() {
|
||||
return entityFactory.tag().create().name(String.format("tag-%d", new Random().nextInt()));
|
||||
protected DistributionSetTagManagement.Create getCreateObject() {
|
||||
return DistributionSetTagManagement.Create.builder().name(String.format("tag-%d", new Random().nextInt())).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TagUpdate getUpdateObject() {
|
||||
return entityFactory.tag().update(1L).name("tag");
|
||||
protected DistributionSetTagManagement.Update getUpdateObject() {
|
||||
return DistributionSetTagManagement.Update.builder().id(1L).name("tag").build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,8 +22,6 @@ import java.util.Random;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
|
||||
@@ -60,7 +58,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that management queries react as specified on calls for non existing entities by means of throwing
|
||||
* Verifies that management queries react as specified on calls for non existing entities by means of throwing
|
||||
* EntityNotFoundException.
|
||||
*/
|
||||
@Test
|
||||
@@ -69,10 +67,9 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
|
||||
void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(NOT_EXIST_IDL, PAGE),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
"DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(NOT_EXIST_IDL, PAGE), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.update(
|
||||
DistributionSetTagManagement.Update.builder().id(NOT_EXIST_IDL).build()), "DistributionSetTag");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,11 +85,11 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> dsBCs = testdataFactory.createDistributionSets("DS-BC", 13);
|
||||
final Collection<DistributionSet> dsABCs = testdataFactory.createDistributionSets("DS-ABC", 9);
|
||||
|
||||
final DistributionSetTag tagA = distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tagB = distributionSetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
final DistributionSetTag tagC = distributionSetTagManagement.create(entityFactory.tag().create().name("C"));
|
||||
final DistributionSetTag tagX = distributionSetTagManagement.create(entityFactory.tag().create().name("X"));
|
||||
final DistributionSetTag tagY = distributionSetTagManagement.create(entityFactory.tag().create().name("Y"));
|
||||
final DistributionSetTag tagA = distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("A").build());
|
||||
final DistributionSetTag tagB = distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("B").build());
|
||||
final DistributionSetTag tagC = distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("C").build());
|
||||
final DistributionSetTag tagX = distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("X").build());
|
||||
final DistributionSetTag tagY = distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("Y").build());
|
||||
|
||||
assignTag(dsAs, tagA);
|
||||
assignTag(dsBs, tagB);
|
||||
@@ -148,13 +145,13 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> groupB = testdataFactory.createDistributionSets("unassigned", 20);
|
||||
|
||||
final DistributionSetTag tag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
.create(DistributionSetTagManagement.Create.builder().name("tag1").description("tagdesc1").build());
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
List<DistributionSet> result = assignTag(groupA, tag);
|
||||
List<? extends DistributionSet> result = assignTag(groupA, tag);
|
||||
assertThat(result)
|
||||
.hasSize(20)
|
||||
.containsAll(distributionSetManagement.get(groupA.stream().map(DistributionSet::getId).toList()));
|
||||
.containsAll((Collection) distributionSetManagement.get(groupA.stream().map(DistributionSet::getId).toList()));
|
||||
assertThat(
|
||||
distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream()
|
||||
.map(DistributionSet::getId)
|
||||
@@ -165,7 +162,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> groupAB = concat(groupA, groupB);
|
||||
// toggle A+B -> A is still assigned and B is assigned as well
|
||||
result = assignTag(groupAB, tag);
|
||||
assertThat(result)
|
||||
assertThat((List) result)
|
||||
.hasSize(40)
|
||||
.containsAll(distributionSetManagement.get(groupAB.stream().map(DistributionSet::getId).toList()));
|
||||
assertThat(
|
||||
@@ -177,7 +174,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
result = unassignTag(concat(groupA, groupB), tag);
|
||||
assertThat(result)
|
||||
.hasSize(40)
|
||||
.containsAll(distributionSetManagement.get(concat(groupB, groupA).stream().map(DistributionSet::getId).toList()));
|
||||
.containsAll((List) distributionSetManagement.get(concat(groupB, groupA).stream().map(DistributionSet::getId).toList()));
|
||||
assertThat(distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent()).isEmpty();
|
||||
}
|
||||
|
||||
@@ -187,7 +184,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@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 DistributionSetTag tag = distributionSetTagManagement.create(
|
||||
DistributionSetTagManagement.Create.builder().name("tag1").description("tagdesc1").build());
|
||||
final List<Long> missing = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
while (true) {
|
||||
@@ -217,7 +215,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void createDistributionSetTag() {
|
||||
final Tag tag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
.create(DistributionSetTagManagement.Create.builder().name("kai1").description("kai2").colour("colour").build());
|
||||
|
||||
assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found")
|
||||
.isEqualTo("kai2");
|
||||
@@ -261,7 +259,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void failedDuplicateDsTagNameException() {
|
||||
final TagCreate tag = entityFactory.tag().create().name("A");
|
||||
final DistributionSetTagManagement.Create tag = DistributionSetTagManagement.Create.builder().name("A").build();
|
||||
distributionSetTagManagement.create(tag);
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).as("should not have worked as tag already exists")
|
||||
@@ -273,10 +271,10 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("A").build());
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder().name("B").build());
|
||||
|
||||
final TagUpdate tagUpdate = entityFactory.tag().update(tag.getId()).name("A");
|
||||
final DistributionSetTagManagement.Update tagUpdate = DistributionSetTagManagement.Update.builder().id(tag.getId()).name("A").build();
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).as("should not have worked as tag already exists")
|
||||
.isThrownBy(() -> distributionSetTagManagement.update(tagUpdate));
|
||||
}
|
||||
@@ -291,7 +289,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
// change data
|
||||
final DistributionSetTag savedAssigned = tags.iterator().next();
|
||||
// persist
|
||||
distributionSetTagManagement.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
distributionSetTagManagement.update(DistributionSetTagManagement.Update.builder().id(savedAssigned.getId()).name("test123").build());
|
||||
// check data
|
||||
assertThat(distributionSetTagManagement.findAll(PAGE).getContent()).as("Wrong size of ds tags")
|
||||
.hasSize(tags.size());
|
||||
@@ -337,7 +335,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
tags.forEach(tag -> assignTag(sets, tag));
|
||||
|
||||
return distributionSetTagManagement.findAll(PAGE).getContent();
|
||||
return distributionSetTagManagement.findAll(PAGE).getContent().stream().map(DistributionSetTag.class::cast).toList();
|
||||
}
|
||||
|
||||
private DistributionSetFilter.DistributionSetFilterBuilder getDistributionSetFilterBuilder() {
|
||||
|
||||
@@ -13,9 +13,8 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractRepositoryManagementSecurityTest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -25,21 +24,21 @@ import org.junit.jupiter.api.Test;
|
||||
* Story: SecurityTests DistributionSetTypeManagement
|
||||
*/
|
||||
class DistributionSetTypeManagementSecurityTest
|
||||
extends AbstractRepositoryManagementSecurityTest<DistributionSetType, DistributionSetTypeCreate, DistributionSetTypeUpdate> {
|
||||
extends AbstractRepositoryManagementSecurityTest<DistributionSetType, DistributionSetTypeManagement.Create, DistributionSetTypeManagement.Update> {
|
||||
|
||||
@Override
|
||||
protected RepositoryManagement<DistributionSetType, DistributionSetTypeCreate, DistributionSetTypeUpdate> getRepositoryManagement() {
|
||||
protected RepositoryManagement getRepositoryManagement() {
|
||||
return distributionSetTypeManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DistributionSetTypeCreate getCreateObject() {
|
||||
return entityFactory.distributionSetType().create().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt()));
|
||||
protected DistributionSetTypeManagement.Create getCreateObject() {
|
||||
return DistributionSetTypeManagement.Create.builder().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt())).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DistributionSetTypeUpdate getUpdateObject() {
|
||||
return entityFactory.distributionSetType().update(1L).description("description");
|
||||
protected DistributionSetTypeManagement.Update getUpdateObject() {
|
||||
return DistributionSetTypeManagement.Update.builder().id(1L).description("description").build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,4 +82,4 @@ class DistributionSetTypeManagementSecurityTest
|
||||
void unassignSoftwareModuleTypePermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.unassignSoftwareModuleType(1L, 1L), List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,8 @@ import java.util.Set;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent;
|
||||
@@ -90,8 +89,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.delete(NOT_EXIST_IDL), "DistributionSetType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetTypeManagement.update(entityFactory.distributionSetType().update(NOT_EXIST_IDL)),
|
||||
"DistributionSet");
|
||||
() -> distributionSetTypeManagement.update(DistributionSetTypeManagement.Update.builder().id(NOT_EXIST_IDL).build()),
|
||||
"DistributionSetType");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +115,7 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void updateUnassignedDistributionSetTypeModules() {
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("updatableType").name("to be deleted").build());
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
// add OS
|
||||
@@ -146,14 +145,14 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
// create software module types
|
||||
final List<Long> moduleTypeIds = new ArrayList<>();
|
||||
for (int i = 0; i < quota + 1; ++i) {
|
||||
final SoftwareModuleTypeCreate smCreate = entityFactory.softwareModuleType().create().name("smType_" + i)
|
||||
.description("smType_" + i).maxAssignments(1).colour("blue").key("smType_" + i);
|
||||
final SoftwareModuleTypeManagement.Create smCreate = SoftwareModuleTypeManagement.Create.builder().name("smType_" + i)
|
||||
.description("smType_" + i).maxAssignments(1).colour("blue").key("smType_" + i).build();
|
||||
moduleTypeIds.add(softwareModuleTypeManagement.create(smCreate).getId());
|
||||
}
|
||||
|
||||
// assign all types at once
|
||||
final DistributionSetType dsType1 = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("dst1").name("dst1"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("dst1").name("dst1").build());
|
||||
final Long dsType1Id = dsType1.getId();
|
||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||
.isThrownBy(() -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType1Id, moduleTypeIds));
|
||||
@@ -162,7 +161,7 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// assign as many mandatory modules as possible
|
||||
final DistributionSetType dsType2 = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("dst2").name("dst2"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("dst2").name("dst2").build());
|
||||
final Long dsType2Id = dsType2.getId();
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType2Id,
|
||||
moduleTypeIds.subList(0, quota));
|
||||
@@ -175,7 +174,7 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// assign as many optional modules as possible
|
||||
final DistributionSetType dsType3 = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("dst3").name("dst3"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("dst3").name("dst3").build());
|
||||
final Long dsType3Id = dsType3.getId();
|
||||
distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3Id, moduleTypeIds.subList(0, quota));
|
||||
assertThat(distributionSetTypeManagement.get(dsType3Id)).isNotEmpty();
|
||||
@@ -194,11 +193,10 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSetType nonUpdatableType = createDistributionSetTypeUsedByDs();
|
||||
|
||||
distributionSetTypeManagement.update(
|
||||
entityFactory.distributionSetType().update(nonUpdatableType.getId()).description("a new description"));
|
||||
DistributionSetTypeManagement.Update.builder().id(nonUpdatableType.getId()).description("a new description").build());
|
||||
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getDescription())
|
||||
.isEqualTo("a new description");
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getColour()).isEqualTo("test123");
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").orElseThrow().getDescription()).isEqualTo("a new description");
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").orElseThrow().getColour()).isEqualTo("test123");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,13 +217,13 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("updatableType").name("to be deleted").build());
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
final Long osTypeId = osType.getId();
|
||||
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(), Set.of(osTypeId));
|
||||
distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("newtypesoft").version("1").type(nonUpdatableType.getKey()));
|
||||
DistributionSetManagement.Create.builder().type(nonUpdatableType).name("newtypesoft").version("1").build());
|
||||
|
||||
final Long typeId = nonUpdatableType.getId();
|
||||
assertThatThrownBy(() -> distributionSetTypeManagement.unassignSoftwareModuleType(typeId, osTypeId))
|
||||
@@ -238,7 +236,7 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void deleteUnassignedDistributionSetType() {
|
||||
final JpaDistributionSetType hardDelete = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("delete").name("to be deleted").build());
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).contains(hardDelete);
|
||||
distributionSetTypeManagement.delete(hardDelete.getId());
|
||||
@@ -253,16 +251,16 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
void deleteAssignedDistributionSetType() {
|
||||
final int existing = (int) distributionSetTypeManagement.count();
|
||||
final JpaDistributionSetType toBeDeleted = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("softdeleted").name("to be deleted").build());
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).contains(toBeDeleted);
|
||||
distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("softdeleted").version("1").type(toBeDeleted.getKey()));
|
||||
DistributionSetManagement.Create.builder().type(toBeDeleted).name("softdeleted").version("1").build());
|
||||
|
||||
distributionSetTypeManagement.delete(toBeDeleted.getId());
|
||||
final Optional<DistributionSetType> softdeleted = distributionSetTypeManagement.findByKey("softdeleted");
|
||||
assertThat(softdeleted).isPresent();
|
||||
assertThat(softdeleted.get().isDeleted()).isTrue();
|
||||
final Optional<? extends DistributionSetType> softDeleted = distributionSetTypeManagement.findByKey("softdeleted");
|
||||
assertThat(softDeleted).isPresent();
|
||||
assertThat(softDeleted.get().isDeleted()).isTrue();
|
||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).hasSize(existing);
|
||||
assertThat(distributionSetTypeManagement.findByRsql("name==*", PAGE)).hasSize(existing);
|
||||
assertThat(distributionSetTypeManagement.count()).isEqualTo(existing);
|
||||
@@ -273,9 +271,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void shouldFailWhenDistributionSetHasNoSoftwareModulesAssigned() {
|
||||
|
||||
final JpaDistributionSetType jpaDistributionSetType = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("newType").name("new Type"));
|
||||
.create(DistributionSetTypeManagement.Create.builder().key("newType").name("new Type").build());
|
||||
|
||||
final List<SoftwareModule> softwareModules = new ArrayList<>();
|
||||
|
||||
@@ -286,103 +283,113 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
||||
final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create()
|
||||
.name("a").version("a").description(randomString(513));
|
||||
final DistributionSetManagement.Create distributionSetCreate = DistributionSetManagement.Create.builder()
|
||||
.name("a").version("a").description(randomString(513)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long description should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate2 = entityFactory.distributionSet().create()
|
||||
.name("a").version("a").description(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Create distributionSetCreate2 = DistributionSetManagement.Create.builder()
|
||||
.name("a").version("a").description(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set invalid description text should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate2));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate = entityFactory.distributionSet().update(set.getId())
|
||||
.description(randomString(513));
|
||||
final DistributionSetManagement.Update distributionSetUpdate = DistributionSetManagement.Update.builder().id(set.getId())
|
||||
.description(randomString(513)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long description should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate2 = entityFactory.distributionSet().update(set.getId()).description(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Update distributionSetUpdate2 = DistributionSetManagement.Update.builder().id(set.getId()).description(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid description should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate2));
|
||||
}
|
||||
|
||||
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
||||
final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create()
|
||||
.version("a").name(randomString(NamedEntity.NAME_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Create distributionSetCreate = DistributionSetManagement.Create.builder()
|
||||
.version("a").name(randomString(NamedEntity.NAME_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate2 = entityFactory.distributionSet().create().version("a").name(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Create distributionSetCreate2 =
|
||||
DistributionSetManagement.Create.builder().version("a").name(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate2));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate3 = entityFactory.distributionSet().create().version("a").name("");
|
||||
final DistributionSetManagement.Create distributionSetCreate3 =
|
||||
DistributionSetManagement.Create.builder().version("a").name("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too short name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate3));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate4 = entityFactory.distributionSet().create().version("a").name(null);
|
||||
final DistributionSetManagement.Create distributionSetCreate4 =
|
||||
DistributionSetManagement.Create.builder().version("a").name(null).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with null name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate4));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate = entityFactory.distributionSet().update(set.getId())
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Update distributionSetUpdate = DistributionSetManagement.Update.builder().id(set.getId())
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate2 = entityFactory.distributionSet().update(set.getId()).name(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Update distributionSetUpdate2 =
|
||||
DistributionSetManagement.Update.builder().id(set.getId()).name(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate2));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate3 = entityFactory.distributionSet().update(set.getId()).name("");
|
||||
final DistributionSetManagement.Update distributionSetUpdate3 =
|
||||
DistributionSetManagement.Update.builder().id(set.getId()).name("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too short name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate3));
|
||||
}
|
||||
|
||||
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
||||
final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create()
|
||||
.name("a").version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Create distributionSetCreate = DistributionSetManagement.Create.builder()
|
||||
.name("a").version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate2 = entityFactory.distributionSet().create().name("a").version(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Create distributionSetCreate2 =
|
||||
DistributionSetManagement.Create.builder().name("a").version(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate2));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate3 = entityFactory.distributionSet().create().name("a").version("");
|
||||
final DistributionSetManagement.Create distributionSetCreate3 =
|
||||
DistributionSetManagement.Create.builder().name("a").version("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too short version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate3));
|
||||
|
||||
final DistributionSetCreate distributionSetCreate4 = entityFactory.distributionSet().create().name("a").version(null);
|
||||
final DistributionSetManagement.Create distributionSetCreate4 =
|
||||
DistributionSetManagement.Create.builder().name("a").version(null).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with null version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(distributionSetCreate4));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate = entityFactory.distributionSet().update(set.getId())
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1));
|
||||
final DistributionSetManagement.Update distributionSetUpdate = DistributionSetManagement.Update.builder().id(set.getId())
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1)).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long version should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate2 = entityFactory.distributionSet().update(set.getId()).version(INVALID_TEXT_HTML);
|
||||
final DistributionSetManagement.Update distributionSetUpdate2 =
|
||||
DistributionSetManagement.Update.builder().id(set.getId()).version(INVALID_TEXT_HTML).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid version should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate2));
|
||||
|
||||
final DistributionSetUpdate distributionSetUpdate3 = entityFactory.distributionSet().update(set.getId()).version("");
|
||||
final DistributionSetManagement.Update distributionSetUpdate3 =
|
||||
DistributionSetManagement.Update.builder().id(set.getId()).version("").build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too short version should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(distributionSetUpdate3));
|
||||
@@ -390,10 +397,12 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private DistributionSetType createDistributionSetTypeUsedByDs() {
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.create(
|
||||
entityFactory.distributionSetType().create().key("updatableType").name("to be deleted").colour("test123"));
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("newtypesoft").version("1").type(nonUpdatableType.getKey()));
|
||||
DistributionSetTypeManagement.Create.builder().key("updatableType").name("to be deleted").colour("test123").build());
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").orElseThrow().getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.create(DistributionSetManagement.Create.builder()
|
||||
.type(nonUpdatableType)
|
||||
.name("newtypesoft").version("1")
|
||||
.build());
|
||||
return nonUpdatableType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import jakarta.validation.ConstraintDeclarationException;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.DynamicRolloutGroupTemplate;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -25,11 +25,11 @@ import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Feature: SecurityTests - RolloutManagement<br/>
|
||||
* Story: SecurityTests RolloutManagement
|
||||
*/
|
||||
@Slf4j
|
||||
class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
@@ -101,9 +101,10 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void cancelRolloutsForDistributionSetPermissionsCheck() {
|
||||
final DistributionSetTypeCreate key = entityFactory.distributionSetType().create().name("type").key("type");
|
||||
final DistributionSetTypeManagement.Create key = DistributionSetTypeManagement.Create.builder().name("type").key("type").build();
|
||||
distributionSetTypeManagement.create(key);
|
||||
final DistributionSetCreate dsCreate = entityFactory.distributionSet().create().name("name").version("1.0.0").type("type");
|
||||
final DistributionSetManagement.Create dsCreate =
|
||||
DistributionSetManagement.Create.builder().type(defaultDsType()).name("name").version("1.0.0").build();
|
||||
final DistributionSet ds = distributionSetManagement.create(dsCreate);
|
||||
assertPermissions(() -> {
|
||||
rolloutManagement.cancelRolloutsForDistributionSet(ds);
|
||||
@@ -251,4 +252,4 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
void findByRolloutWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(1L, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,7 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleUpdate;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractRepositoryManagementSecurityTest;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -24,21 +23,21 @@ import org.junit.jupiter.api.Test;
|
||||
* Story: SecurityTests SoftwareManagement
|
||||
*/
|
||||
class SoftwareManagementSecurityTest
|
||||
extends AbstractRepositoryManagementSecurityTest<SoftwareModule, SoftwareModuleCreate, SoftwareModuleUpdate> {
|
||||
extends AbstractRepositoryManagementSecurityTest<SoftwareModule, SoftwareModuleManagement.Create, SoftwareModuleManagement.Update> {
|
||||
|
||||
@Override
|
||||
protected RepositoryManagement<SoftwareModule, SoftwareModuleCreate, SoftwareModuleUpdate> getRepositoryManagement() {
|
||||
protected RepositoryManagement getRepositoryManagement() {
|
||||
return softwareModuleManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoftwareModuleCreate getCreateObject() {
|
||||
return entityFactory.softwareModule().create().name("name").version("version").type("type");
|
||||
protected SoftwareModuleManagement.Create getCreateObject() {
|
||||
return SoftwareModuleManagement.Create.builder().type(getASmType()).name("name").version("version").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoftwareModuleUpdate getUpdateObject() {
|
||||
return entityFactory.softwareModule().update(1L).locked(true);
|
||||
protected SoftwareModuleManagement.Update getUpdateObject() {
|
||||
return SoftwareModuleManagement.Update.builder().id(1L).locked(true).build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,5 +169,4 @@ class SoftwareManagementSecurityTest
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdsAndTargetVisible(List.of(1L)),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataCreate;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
@@ -61,7 +65,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
private static final PageRequest PAGE_REQUEST_100 = PageRequest.of(0, 100);
|
||||
|
||||
/**
|
||||
* Verifies that management get access reacts as specified on calls for non existing entities by means
|
||||
* Verifies that management get access reacts as specified on calls for non existing entities by means
|
||||
* of Optional not present.
|
||||
*/
|
||||
@Test
|
||||
@@ -79,20 +83,19 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that management queries react as specfied on calls for non existing entities
|
||||
* by means of throwing EntityNotFoundException.
|
||||
* Verifies that management queries react as specfied on calls for non existing entities
|
||||
* by means of throwing EntityNotFoundException.
|
||||
*/
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
|
||||
void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.create(Collections
|
||||
.singletonList(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID))), "SoftwareModuleType");
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID)), "SoftwareModuleType");
|
||||
final SoftwareModuleManagement.Create noType = SoftwareModuleManagement.Create.builder().name("xxx").type(null).build();
|
||||
final List<SoftwareModuleManagement.Create> noTypeList = List.of(noType);
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> softwareModuleManagement.create(noTypeList));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(() -> softwareModuleManagement.create(noType));
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.updateMetadata(
|
||||
@@ -122,7 +125,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.getMetadata(NOT_EXIST_IDL), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByType(NOT_EXIST_IDL, PAGE), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.update(entityFactory.softwareModule().update(NOT_EXIST_IDL)), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.update(SoftwareModuleManagement.Update.builder().id(NOT_EXIST_IDL).build()),
|
||||
"SoftwareModule");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +137,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
.update(entityFactory.softwareModule().update(ah.getId()));
|
||||
.update(SoftwareModuleManagement.Update.builder().id(ah.getId()).build());
|
||||
|
||||
assertThat(updated.getOptLockRevision())
|
||||
.as("Expected version number of updated entity to be equal to created version")
|
||||
@@ -148,7 +152,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
.update(entityFactory.softwareModule().update(ah.getId()).description("changed").vendor("changed"));
|
||||
.update(SoftwareModuleManagement.Update.builder().id(ah.getId()).description("changed").vendor("changed").build());
|
||||
|
||||
assertThat(updated.getOptLockRevision())
|
||||
.as("Expected version number of updated entitity is")
|
||||
@@ -174,17 +178,20 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void findSoftwareModuleByFilters() {
|
||||
final SoftwareModule ah = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.1"));
|
||||
.create(SoftwareModuleManagement.Create.builder().type(appType).name("agent-hub").version("1.0.1").build());
|
||||
final SoftwareModule jvm = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(runtimeType).name("oracle-jre").version("1.7.2"));
|
||||
.create(SoftwareModuleManagement.Create.builder().type(runtimeType).name("oracle-jre").version("1.7.2").build());
|
||||
final SoftwareModule os = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(osType).name("poky").version("3.0.2"));
|
||||
.create(SoftwareModuleManagement.Create.builder().type(osType).name("poky").version("3.0.2").build());
|
||||
|
||||
final SoftwareModule ah2 = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.2"));
|
||||
.create(SoftwareModuleManagement.Create.builder().type(appType).name("agent-hub").version("1.0.2").build());
|
||||
JpaDistributionSet ds = (JpaDistributionSet) distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("ds-1").version("1.0.1").type(standardDsType)
|
||||
.modules(Arrays.asList(os.getId(), jvm.getId(), ah2.getId())));
|
||||
.create(DistributionSetManagement.Create.builder()
|
||||
.type(standardDsType)
|
||||
.name("ds-1").version("1.0.1")
|
||||
.modules(Set.of(os, jvm, ah2))
|
||||
.build());
|
||||
|
||||
final JpaTarget target = (JpaTarget) testdataFactory.createTarget();
|
||||
ds = (JpaDistributionSet) assignSet(target, ds).getDistributionSet();
|
||||
@@ -217,10 +224,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void findSoftwareModulesById() {
|
||||
|
||||
final List<Long> modules = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(),
|
||||
testdataFactory.createSoftwareModuleApp().getId(), 624355263L);
|
||||
|
||||
final List<Long> modules = List.of(testdataFactory.createSoftwareModuleOs().getId(), testdataFactory.createSoftwareModuleApp().getId());
|
||||
assertThat(softwareModuleManagement.get(modules)).hasSize(2);
|
||||
}
|
||||
|
||||
@@ -236,7 +240,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
softwareModuleManagement.delete(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
||||
testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
assertThat(softwareModuleManagement.findByType(osType.getId(), PAGE).getContent())
|
||||
assertThat((List) softwareModuleManagement.findByType(osType.getId(), PAGE).getContent())
|
||||
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
|
||||
.contains(two, one);
|
||||
}
|
||||
@@ -497,8 +501,9 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// one soft deleted
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleApp();
|
||||
final DistributionSet set = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
||||
final DistributionSet set = distributionSetManagement.create(DistributionSetManagement.Create.builder()
|
||||
.type(defaultDsType())
|
||||
.name("set").version("1").modules(Set.of(one, deleted)).build());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.findByAssignedTo(set.getId(), PAGE).getContent())
|
||||
@@ -825,7 +830,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<SoftwareModule> modules = distributionSet.getModules().stream().toList();
|
||||
assertThat(modules).hasSizeGreaterThan(1);
|
||||
|
||||
// try delete while DS is not locked
|
||||
// try to delete while DS is not locked
|
||||
softwareModuleManagement.delete(modules.get(0).getId());
|
||||
|
||||
distributionSetManagement.lock(distributionSet.getId());
|
||||
@@ -833,7 +838,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false))
|
||||
.isTrue();
|
||||
|
||||
// try delete SM of a locked DS
|
||||
// try to delete SM of a locked DS
|
||||
final Long moduleId = modules.get(1).getId();
|
||||
assertThatExceptionOfType(LockedException.class)
|
||||
.as("Attempt to delete a software module of a locked DS should throw an exception")
|
||||
@@ -865,8 +870,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final long countSoftwareModule = softwareModuleRepository.count();
|
||||
|
||||
// create SoftwareModule
|
||||
SoftwareModule softwareModule = softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(type).name(name).version(version).description("description of artifact " + name));
|
||||
SoftwareModule softwareModule = softwareModuleManagement.create(SoftwareModuleManagement.Create.builder()
|
||||
.type(type).name(name).version(version).description("description of artifact " + name).build());
|
||||
|
||||
final int artifactSize = 5 * 1024;
|
||||
for (int i = 0; i < numberArtifacts; i++) {
|
||||
@@ -904,4 +909,4 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,7 @@ import java.util.Random;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractRepositoryManagementSecurityTest;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -25,21 +24,21 @@ import org.junit.jupiter.api.Test;
|
||||
* Story: SecurityTests SoftwareModuleTypeManagement
|
||||
*/
|
||||
class SoftwareModuleTypeManagementSecurityTest
|
||||
extends AbstractRepositoryManagementSecurityTest<SoftwareModuleType, SoftwareModuleTypeCreate, SoftwareModuleTypeUpdate> {
|
||||
extends AbstractRepositoryManagementSecurityTest<SoftwareModuleType, SoftwareModuleTypeManagement.Create, SoftwareModuleTypeManagement.Update> {
|
||||
|
||||
@Override
|
||||
protected RepositoryManagement<SoftwareModuleType, SoftwareModuleTypeCreate, SoftwareModuleTypeUpdate> getRepositoryManagement() {
|
||||
protected RepositoryManagement getRepositoryManagement() {
|
||||
return softwareModuleTypeManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoftwareModuleTypeCreate getCreateObject() {
|
||||
return entityFactory.softwareModuleType().create().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt()));
|
||||
protected SoftwareModuleTypeManagement.Create getCreateObject() {
|
||||
return SoftwareModuleTypeManagement.Create.builder().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt())).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoftwareModuleTypeUpdate getUpdateObject() {
|
||||
return entityFactory.softwareModuleType().update(1L).description("description");
|
||||
protected SoftwareModuleTypeManagement.Update getUpdateObject() {
|
||||
return SoftwareModuleTypeManagement.Update.builder().id(1L).description("description").build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,5 +56,4 @@ class SoftwareModuleTypeManagementSecurityTest
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@ import java.util.List;
|
||||
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
@@ -26,6 +27,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.Slice;
|
||||
|
||||
/**
|
||||
* Feature: Component Tests - Repository<br/>
|
||||
@@ -34,7 +36,7 @@ import org.junit.jupiter.api.Test;
|
||||
class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
* Verifies that management get access reacts as specfied on calls for non existing entities by means
|
||||
* Verifies that management get access reacts as specfied on calls for non existing entities by means
|
||||
* of Optional not present.
|
||||
*/
|
||||
@Test
|
||||
@@ -47,8 +49,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that management queries react as specfied on calls for non existing entities
|
||||
* by means of throwing EntityNotFoundException.
|
||||
* Verifies that management queries react as specfied on calls for non existing entities
|
||||
* by means of throwing EntityNotFoundException.
|
||||
*/
|
||||
@Test
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
|
||||
@@ -56,7 +58,7 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL), "SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleTypeManagement.update(entityFactory.softwareModuleType().update(NOT_EXIST_IDL)),
|
||||
() -> softwareModuleTypeManagement.update(SoftwareModuleTypeManagement.Update.builder().id(NOT_EXIST_IDL).build()),
|
||||
"SoftwareModuleType");
|
||||
}
|
||||
|
||||
@@ -66,10 +68,10 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void updateNothingResultsInUnchangedRepositoryForType() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().key("test-key").name("test-name").build());
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement
|
||||
.update(entityFactory.softwareModuleType().update(created.getId()));
|
||||
.update(SoftwareModuleTypeManagement.Update.builder().id(created.getId()).build());
|
||||
|
||||
assertThat(updated.getOptLockRevision())
|
||||
.as("Expected version number of updated entitity to be equal to created version")
|
||||
@@ -82,10 +84,10 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void updateSoftwareModuleTypeFieldsToNewValue() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().key("test-key").name("test-name").build());
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(created.getId()).description("changed").colour("changed"));
|
||||
SoftwareModuleTypeManagement.Update.builder().id(created.getId()).description("changed").colour("changed").build());
|
||||
|
||||
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entities is")
|
||||
.isEqualTo(created.getOptLockRevision() + 1);
|
||||
@@ -98,9 +100,9 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@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"));
|
||||
final List<SoftwareModuleTypeManagement.Create> created = Arrays.asList(
|
||||
SoftwareModuleTypeManagement.Create.builder().key("test-key").name("test-name").build(),
|
||||
SoftwareModuleTypeManagement.Create.builder().key("test-key2").name("test-name2").build());
|
||||
softwareModuleTypeManagement.create(created);
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.as("should not have worked as module type already exists")
|
||||
@@ -112,32 +114,30 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void deleteAssignedAndUnassignedSoftwareModuleTypes() {
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
|
||||
SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("bundle").name("OSGi Bundle"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().key("bundle").name("OSGi Bundle").build());
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
|
||||
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
|
||||
|
||||
// delete unassigned
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains((JpaSoftwareModuleType) osType,
|
||||
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType);
|
||||
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat((List) softwareModuleTypeRepository.findAll()).hasSize(3).contains(osType, runtimeType, appType);
|
||||
|
||||
type = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("bundle2").name("OSGi Bundle2"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().key("bundle2").name("OSGi Bundle2").build());
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
|
||||
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
|
||||
|
||||
softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(type).name("Test SM").version("1.0"));
|
||||
.create(SoftwareModuleManagement.Create.builder().type(type).name("Test SM").version("1.0").build());
|
||||
|
||||
// delete assigned
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat(softwareModuleTypeManagement.findByRsql("name==*", PAGE)).hasSize(3).contains(osType, runtimeType,
|
||||
appType);
|
||||
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat((Slice) softwareModuleTypeManagement.findByRsql("name==*", PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
||||
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType,
|
||||
@@ -152,11 +152,12 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
void findSoftwareModuleTypeByName() {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
final SoftwareModuleType found = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().key("thetype").name("thename").build());
|
||||
softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype2").name("anothername"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().key("thetype2").name("anothername").build());
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findByName("thename")).as("Type with given name").contains(found);
|
||||
assertThat((((SoftwareModuleTypeManagement<SoftwareModuleType>) softwareModuleTypeManagement)).findByName("thename")).as(
|
||||
"Type with given name").contains(found);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,12 +165,11 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void createSoftwareModuleTypeFailsWithExistingEntity() {
|
||||
final SoftwareModuleTypeCreate create = entityFactory.softwareModuleType().create().key("thetype").name("thename");
|
||||
final SoftwareModuleTypeManagement.Create create = SoftwareModuleTypeManagement.Create.builder().key("thetype").name("thename").build();
|
||||
softwareModuleTypeManagement.create(create);
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.as("should not have worked as module type already exists")
|
||||
.isThrownBy(() -> softwareModuleTypeManagement
|
||||
.create(create));
|
||||
.isThrownBy(() -> softwareModuleTypeManagement.create(create));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,10 +177,10 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@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"),
|
||||
entityFactory.softwareModuleType().create().key("anothertype").name("anothername"));
|
||||
softwareModuleTypeManagement.create(SoftwareModuleTypeManagement.Create.builder().key("thetype").name("thename").build());
|
||||
final List<SoftwareModuleTypeManagement.Create> creates = List.of(
|
||||
SoftwareModuleTypeManagement.Create.builder().key("thetype").name("thename").build(),
|
||||
SoftwareModuleTypeManagement.Create.builder().key("anothertype").name("anothername").build());
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.as("should not have worked as module type already exists")
|
||||
.isThrownBy(() -> softwareModuleTypeManagement.create(creates));
|
||||
@@ -191,7 +191,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() {
|
||||
final SoftwareModuleTypeCreate create = entityFactory.softwareModuleType().create().key("type").name("name").maxAssignments(0);
|
||||
final SoftwareModuleTypeManagement.Create create =
|
||||
SoftwareModuleTypeManagement.Create.builder().key("type").name("name").maxAssignments(0).build();
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("should not have worked as max assignment is invalid. Should be greater than 0")
|
||||
.isThrownBy(() -> softwareModuleTypeManagement.create(create));
|
||||
@@ -202,12 +203,12 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@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")));
|
||||
final List<? extends SoftwareModuleType> created = softwareModuleTypeManagement
|
||||
.create(List.of(
|
||||
SoftwareModuleTypeManagement.Create.builder().key("thetype").name("thename").build(),
|
||||
SoftwareModuleTypeManagement.Create.builder().key("thetype2").name("thename2").build()));
|
||||
|
||||
assertThat(created).as("Number of created types").hasSize(2);
|
||||
assertThat(softwareModuleTypeManagement.count()).as("Number of types in repository").isEqualTo(5);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,11 @@ import org.eclipse.hawkbit.im.authentication.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Feature: SecurityTests - SystemManagement<br/>
|
||||
* Story: SecurityTests SystemManagement
|
||||
*/
|
||||
@Slf4j
|
||||
class SystemManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.AutoAssignDistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryCreate;
|
||||
@@ -588,8 +589,10 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void verifyAutoAssignmentWithIncompleteDs(final TargetFilterQuery targetFilterQuery) {
|
||||
final DistributionSet incompleteDistributionSet = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("incomplete").version("1")
|
||||
.type(testdataFactory.findOrCreateDefaultTestDsType()));
|
||||
.create(DistributionSetManagement.Create.builder()
|
||||
.type(testdataFactory.findOrCreateDefaultTestDsType())
|
||||
.name("incomplete").version("1")
|
||||
.build());
|
||||
|
||||
final AutoAssignDistributionSetUpdate autoAssignDistributionSetUpdate = entityFactory.targetFilterQuery()
|
||||
.updateAutoAssign(targetFilterQuery.getId()).ds(incompleteDistributionSet.getId());
|
||||
|
||||
@@ -16,8 +16,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -62,7 +62,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests different parameter combinations for target search operations.
|
||||
* Tests different parameter combinations for target search operations.
|
||||
* and query definitions by RSQL (named and un-named).
|
||||
*/
|
||||
@Test
|
||||
@@ -278,13 +278,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void shouldNotFindTargetsIncompatibleWithDS() {
|
||||
final DistributionSetType dsType = testdataFactory.findOrCreateDistributionSetType("test-ds-type",
|
||||
"test-ds-type");
|
||||
final DistributionSet testDs = createDistSetWithType(dsType);
|
||||
final TargetType compatibleTargetType = testdataFactory.createTargetType("compTestType",
|
||||
Collections.singletonList(dsType));
|
||||
final TargetType incompatibleTargetType = testdataFactory.createTargetType("incompTestType",
|
||||
Collections.singletonList(testdataFactory.createDistributionSet().getType()));
|
||||
final DistributionSetType dsType = testdataFactory.findOrCreateDistributionSetType("test-ds-type", "test-ds-type");
|
||||
final DistributionSet testDs = distributionSetManagement.create(DistributionSetManagement.Create.builder()
|
||||
.type(dsType).name("test-ds").version("1.0").build());
|
||||
final TargetType compatibleTargetType = testdataFactory.createTargetType("compTestType", List.of(dsType));
|
||||
final TargetType incompatibleTargetType = testdataFactory.createTargetType(
|
||||
"incompTestType", List.of(testdataFactory.createDistributionSet().getType()));
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name("test-filter").query("name==*"));
|
||||
|
||||
@@ -659,10 +658,4 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected);
|
||||
}
|
||||
|
||||
private DistributionSet createDistSetWithType(final DistributionSetType type) {
|
||||
final DistributionSetCreate dsCreate = entityFactory.distributionSet().create().name("test-ds").version("1.0")
|
||||
.type(type);
|
||||
return distributionSetManagement.create(dsCreate);
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,11 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Feature: SecurityTests - TargetManagement<br/>
|
||||
* Story: SecurityTests TargetManagement
|
||||
*/
|
||||
@Slf4j
|
||||
class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
@@ -184,9 +184,9 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> targetManagement.findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(List.of(1L), "controllerId==id",
|
||||
entityFactory.distributionSetType().create().build(), PAGE
|
||||
), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
() -> targetManagement.findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(
|
||||
List.of(1L), "controllerId==id", defaultDsType(), PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,8 +203,10 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable("controllerId==id", List.of(1L),
|
||||
entityFactory.distributionSetType().create().build()), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
assertPermissions(
|
||||
() -> targetManagement.countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(
|
||||
"controllerId==id", List.of(1L), defaultDsType()),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,11 +16,11 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Feature: SecurityTests - TargetTagManagement<br/>
|
||||
* Story: SecurityTests TargetTagManagement
|
||||
*/
|
||||
@Slf4j
|
||||
class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
@@ -106,4 +106,4 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
void updatePermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.update(entityFactory.tag().update(1L)), List.of(SpPermission.UPDATE_TARGET));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@ import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Feature: SecurityTests - TargetTypeManagement<br/>
|
||||
* Story: SecurityTests TargetTypeManagement
|
||||
*/
|
||||
@Slf4j
|
||||
class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
@@ -151,5 +151,4 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
assertPermissions(() -> targetTypeManagement.unassignDistributionSetType(1L, 1L),
|
||||
List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Feature: SecurityTests - TargetManagement<br/>
|
||||
* Story: SecurityTests TargetManagement
|
||||
*/
|
||||
@Slf4j
|
||||
class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
@@ -87,4 +87,4 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe
|
||||
void pollStatusResolverPermissionsCheck() {
|
||||
assertPermissions(() -> tenantConfigurationManagement.pollStatusResolver(), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.jpa.EntityInterceptor;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityInterceptorHolder;
|
||||
@@ -115,7 +116,7 @@ class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
private void executeDeleteAndAssertCallbackResult(final AbstractEntityListener entityInterceptor) {
|
||||
EntityInterceptorHolder.getInstance().getEntityInterceptors().add(entityInterceptor);
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().name("test").key("test"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().name("test").key("test").build());
|
||||
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(entityInterceptor.getEntity()).isNotNull();
|
||||
@@ -198,4 +199,4 @@ class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
setEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -59,12 +60,12 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
void changedEntitiesAreNotEqual() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("test").name("test"));
|
||||
.create(SoftwareModuleTypeManagement.Create.builder().key("test").name("test").build());
|
||||
assertThat(type).as("persited entity is not equal to regular object")
|
||||
.isNotEqualTo(entityFactory.softwareModuleType().create().key("test").name("test").build());
|
||||
.isNotEqualTo(SoftwareModuleTypeManagement.Create.builder().key("test").name("test").build());
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(type.getId()).description("another"));
|
||||
SoftwareModuleTypeManagement.Update.builder().id(type.getId()).description("another").build());
|
||||
assertThat(type).as("Changed entity is not equal to the previous version").isNotEqualTo(updated);
|
||||
}
|
||||
|
||||
@@ -72,9 +73,9 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
* Verify that no proxy of the entity manager has an influence on the equals or hashcode result.
|
||||
*/
|
||||
@Test
|
||||
void managedEntityIsEqualToUnamangedObjectWithSameKey() {
|
||||
void managedEntityIsEqualToUnmanagedObjectWithSameKey() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test").name("test").description("test"));
|
||||
SoftwareModuleTypeManagement.Create.builder().key("test").name("test").description("test").build());
|
||||
|
||||
final JpaSoftwareModuleType mock = new JpaSoftwareModuleType("test", "test", "test", 1);
|
||||
mock.setId(type.getId());
|
||||
@@ -86,5 +87,4 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
.as("managed entity has same hash code as regular object with same content")
|
||||
.hasSameHashCodeAs(mock.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
@@ -33,20 +34,20 @@ class RsqlSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@BeforeEach
|
||||
void setupBeforeTest() {
|
||||
ah = softwareModuleManagement.create(entityFactory.softwareModule().create().type(appType).name("agent-hub")
|
||||
.version("1.0.1").description("agent-hub"));
|
||||
softwareModuleManagement.create(entityFactory.softwareModule().create().type(runtimeType).name("oracle-jre")
|
||||
.version("1.7.2").description("aa"));
|
||||
ah = softwareModuleManagement.create(SoftwareModuleManagement.Create.builder().type(appType).name("agent-hub")
|
||||
.version("1.0.1").description("agent-hub").build());
|
||||
softwareModuleManagement.create(SoftwareModuleManagement.Create.builder().type(runtimeType).name("oracle-jre")
|
||||
.version("1.7.2").description("aa").build());
|
||||
softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().type(osType).name("poki").version("3.0.2").description("aa"));
|
||||
SoftwareModuleManagement.Create.builder().type(osType).name("poki").version("3.0.2").description("aa").build());
|
||||
softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(osType).name("*§$%&/&%ÄÜ*Ö@").version("1.0.0")
|
||||
.description("wildcard testing"));
|
||||
.create(SoftwareModuleManagement.Create.builder().type(osType).name("*§$%&/&%ÄÜ*Ö@").version("1.0.0")
|
||||
.description("wildcard testing").build());
|
||||
softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(osType).name("noDesc").version("noDesc"));
|
||||
.create(SoftwareModuleManagement.Create.builder().type(osType).name("noDesc").version("noDesc").build());
|
||||
|
||||
final JpaSoftwareModule ah2 = (JpaSoftwareModule) softwareModuleManagement.create(entityFactory.softwareModule()
|
||||
.create().type(appType).name("agent-hub2").version("1.0.1").description("agent-hub2"));
|
||||
final JpaSoftwareModule ah2 = (JpaSoftwareModule) softwareModuleManagement.create(
|
||||
SoftwareModuleManagement.Create.builder().type(appType).name("agent-hub2").version("1.0.1").description("agent-hub2").build());
|
||||
|
||||
final SoftwareModuleMetadataCreate softwareModuleMetadata = entityFactory.softwareModuleMetadata()
|
||||
.create(ah.getId()).key("metaKey").value("metaValue");
|
||||
@@ -163,7 +164,7 @@ class RsqlSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsql, final long expectedEntity) {
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final Page<? extends SoftwareModule> find = softwareModuleManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(expectedEntity);
|
||||
|
||||
@@ -87,9 +87,9 @@ class RsqlSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsql, final long expectedEntity) {
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final Page<? extends SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(expectedEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.TagFields;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
@@ -29,12 +29,11 @@ class RsqlTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@BeforeEach
|
||||
void seuptBeforeTest() {
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final TagCreate targetTag = entityFactory.tag().create()
|
||||
.name(Integer.toString(i)).description(Integer.toString(i)).colour(i % 2 == 0 ? "red" : "blue");
|
||||
targetTagManagement.create(targetTag);
|
||||
distributionSetTagManagement.create(targetTag);
|
||||
targetTagManagement.create(entityFactory.tag().create()
|
||||
.name(Integer.toString(i)).description(Integer.toString(i)).colour(i % 2 == 0 ? "red" : "blue"));
|
||||
distributionSetTagManagement.create(DistributionSetTagManagement.Create.builder()
|
||||
.name(Integer.toString(i)).description(Integer.toString(i)).colour(i % 2 == 0 ? "red" : "blue").build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +128,9 @@ class RsqlTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQueryDistributionSet(final String rsql, final long expectedEntities) {
|
||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
final Page<? extends DistributionSetTag> findEntity = distributionSetTagManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAllEntities = findEntity.getTotalElements();
|
||||
assertThat(findEntity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,11 +167,11 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
createDistributionSetForTenant(anotherTenant);
|
||||
|
||||
// ensure both tenants see their distribution sets
|
||||
final Slice<DistributionSet> findDistributionSetsForTenant = findDistributionSetForTenant(tenant);
|
||||
final Slice<? extends DistributionSet> findDistributionSetsForTenant = findDistributionSetForTenant(tenant);
|
||||
assertThat(findDistributionSetsForTenant).hasSize(1);
|
||||
assertThat(findDistributionSetsForTenant.getContent().get(0).getTenant().toUpperCase())
|
||||
.isEqualTo(tenant.toUpperCase());
|
||||
final Slice<DistributionSet> findDistributionSetsForAnotherTenant = findDistributionSetForTenant(anotherTenant);
|
||||
final Slice<? extends DistributionSet> findDistributionSetsForAnotherTenant = findDistributionSetForTenant(anotherTenant);
|
||||
assertThat(findDistributionSetsForAnotherTenant).hasSize(1);
|
||||
assertThat(findDistributionSetsForAnotherTenant.getContent().get(0).getTenant().toUpperCase())
|
||||
.isEqualTo(anotherTenant.toUpperCase());
|
||||
@@ -200,7 +200,7 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
return runAsTenant(tenant, () -> testdataFactory.createDistributionSet());
|
||||
}
|
||||
|
||||
private Slice<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
|
||||
private Slice<? extends DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
|
||||
return runAsTenant(tenant, () -> distributionSetManagement.findByCompleted(true, PAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user