From 8a2257c1f673412523b5071be7ca28449f50d8c5 Mon Sep 17 00:00:00 2001
From: Vasil Ilchev
Date: Mon, 25 Aug 2025 15:24:10 +0300
Subject: [PATCH] Remove obsolete *ManagementSecuritiyTest classes with manual
method tests in favor of new dynamic ManagementSecurityTest (#2620)
Co-authored-by: vasilchev
---
.../jpa/AbstractJpaIntegrationTest.java | 87 ----
...tractRepositoryManagementSecurityTest.java | 132 ------
.../ArtifactManagementSecurityTest.java | 56 ---
.../ConfirmationManagementSecurityTest.java | 81 ----
.../ControllerManagementSecurityTest.java | 312 --------------
.../DeploymentManagementSecurityTest.java | 301 -------------
...DistributionSetManagementSecurityTest.java | 221 ----------
...tributionSetTagManagementSecurityTest.java | 44 --
...ributionSetTypeManagementSecurityTest.java | 85 ----
.../RolloutGroupManagementSecurityTest.java | 106 -----
.../RolloutManagementSecurityTest.java | 249 -----------
.../SoftwareManagementSecurityTest.java | 145 -------
...twareModuleTypeManagementSecurityTest.java | 59 ---
.../SystemManagementSecurityTest.java | 118 -----
...rgetFilterQueryManagementSecurityTest.java | 132 ------
.../TargetManagementSecurityTest.java | 406 ------------------
.../TargetTagManagementSecurityTest.java | 105 -----
.../TargetTypeManagementSecurityTest.java | 140 ------
...ntConfigurationManagementSecurityTest.java | 90 ----
19 files changed, 2869 deletions(-)
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java
delete mode 100644 hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java
index a406687a7..214b142a3 100644
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java
+++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java
@@ -10,28 +10,18 @@
package org.eclipse.hawkbit.repository.jpa;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.runAs;
-import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.withUser;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.stream.StreamSupport;
-
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.PersistenceContext;
-
-import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
-import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException;
import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaBaseEntity_;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction_;
@@ -55,7 +45,6 @@ import org.eclipse.hawkbit.repository.jpa.repository.TargetTagRepository;
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
import org.eclipse.hawkbit.repository.jpa.repository.TenantMetaDataRepository;
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
-import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionStatusCreate;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -224,82 +213,6 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
assertThat(running.getTotalElements()).as("Action count").isEqualTo(count);
}
- /**
- * Asserts that the given callable throws an InsufficientPermissionException.
- * If callable succeeds without any exception or exception other than InsufficientPermissionException, it will be considered as an assert failure.
- *
- * @param callable the callable to call
- */
- protected void assertPermissions(final Callable> callable, List requiredPermissions) {
- assertPermissions(callable, requiredPermissions, null);
- }
-
- /**
- * Asserts that the given callable throws an InsufficientPermissionException.
- *
- * @param callable the callable to call
- * @param requiredPermissions required permissions for the callable
- * @param insufficientPermissions can be null, if null, it will be resolved automatically. But in some cases (e.g. @PreAuthorized Permissions with OR, it is safer to pass directly the insufficient permissions)
- */
- @SneakyThrows
- protected void assertPermissions(final Callable> callable, final List requiredPermissions,
- final List insufficientPermissions) {
- // if READ_PERMISSION is required and required permissions are multiple, give only READ_PERMISSION to eliminate internal read_permission check failure that would confuse the actual test
- final List resolvedInsufficientPermissions = insufficientPermissions != null
- ? insufficientPermissions
- : requiredPermissions.contains(SpPermission.READ_REPOSITORY) && requiredPermissions.size() > 1
- ? List.of(SpPermission.READ_REPOSITORY)
- : REPOSITORY_AND_TARGET_PERMISSIONS.stream().filter(p -> !requiredPermissions.contains(p)).toList();
- // check if the user has the correct permissions
- runAs(withUser("user_with_permissions", requiredPermissions.toArray(new String[0])), () -> {
- assertPermissionWorks(callable);
- log.info("assertPermissionWorks Passed");
- });
-
- // check if the user has the insufficient permissions
- runAs(withUser("user_without_permissions", resolvedInsufficientPermissions.toArray(new String[0])), () -> {
- assertInsufficientPermission(callable);
- log.info("assertInsufficientPermission Passed");
- });
- }
-
- /**
- * Asserts that the given callable throws an InsufficientPermissionException.
- * If callable succeeds without any exception or exception other than InsufficientPermissionException, it will be considered as an assert failure.
- *
- * @param callable the callable to call
- */
- private void assertInsufficientPermission(final Callable> callable) {
- try {
- callable.call();
- throw new AssertionError(
- "Expected Exception 'InsufficientPermissionException' to be thrown, but request passed with no exception.");
- } catch (Exception ex) {
- assertThat(ex).isInstanceOf(InsufficientPermissionException.class);
- }
- }
-
- /**
- * Asserts that the given callable succeeds.
- *
- * 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.
- *
- * @param callable the callable to call
- */
- private void assertPermissionWorks(final Callable> callable) {
- try {
- callable.call();
- } catch (final Throwable th) {
- if (th instanceof EntityNotFoundException) {
- log.info("Expected (at most) EntityNotFoundException catch: {}", th.getMessage());
- } else {
- throw new AssertionError("Expected no Exception (other then EntityNotFound) to be thrown, but got: " + th.getMessage(), th);
- }
- }
- }
-
protected void finishAction(final Action action) {
controllerManagement.addUpdateActionStatus(
ActionStatusCreate.builder().actionId(action.getId()).status(Action.Status.FINISHED).build());
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java
deleted file mode 100644
index 3d7d1f99a..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-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> extends AbstractJpaIntegrationTest {
-
- /**
- * @return the repository management to test with
- */
- protected abstract RepositoryManagement findRepositoryManagement();
-
- /**
- * @return the object to create
- */
- protected abstract C findCreateObject();
-
- /**
- * @return the object to update
- */
- protected abstract U findUpdateObject();
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createCollectionPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().create(List.of(findCreateObject())), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().create(findCreateObject()), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updatePermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().update(findUpdateObject()), List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deletePermissionCheck() {
- assertPermissions(() -> {
- findRepositoryManagement().delete(1L);
- return null;
- }, List.of(SpPermission.DELETE_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().count(), List.of(SpPermission.READ_REPOSITORY));
- }
-
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteCollectionRepositoryManagement() {
- assertPermissions(() -> {
- findRepositoryManagement().delete(List.of(1L));
- return null;
- }, List.of(SpPermission.DELETE_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().find(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findCollectionPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().get(List.of(1L)), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void existsCollectionPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().exists(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findAllPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().findAll(Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlPermissionCheck() {
- assertPermissions(() -> findRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java
deleted file mode 100644
index ec690a6b6..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.io.ByteArrayInputStream;
-import java.util.List;
-
-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.model.ArtifactUpload;
-import org.eclipse.hawkbit.repository.test.util.WithUser;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - ArtifactManagement
- * Story: SecurityTests ArtifactManagement
- */
-class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ArtifactManagement#create() method
- */
- @Test
- void createPermissionCheck() {
- ArtifactUpload artifactUpload = new ArtifactUpload(new ByteArrayInputStream("RandomString".getBytes()), 1L, "filename", false, 1024);
- assertPermissions(() -> artifactManagement.create(artifactUpload), List.of(SpPermission.CREATE_REPOSITORY));
- }
-
- /**
- * Tests ArtifactManagement#delete() method
- */
- @Test
- void deletePermissionCheck() {
- assertPermissions(() -> {
- artifactManagement.delete(1);
- return null;
- }, List.of(SpPermission.DELETE_REPOSITORY));
- }
-
- /**
- * Tests ArtifactManagement#loadArtifactBinary() method
- */
- @Test
- void loadArtifactBinaryPermissionCheck() {
- assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpPermission.DOWNLOAD_REPOSITORY_ARTIFACT), List.of(SpPermission.CREATE_REPOSITORY));
- assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java
deleted file mode 100644
index ae311ed8f..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.im.authentication.SpRole;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - ConfirmationManagement
- * Story: SecurityTests ConfirmationManagement
- */
-class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ConfirmationManagement#findActiveActionsWaitingConfirmation() method
- */
- @Test
- void findActiveActionsWaitingConfirmationPermissionsCheck() {
- assertPermissions(() -> confirmationManagement.findActiveActionsWaitingConfirmation("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ConfirmationManagement#activateAutoConfirmation() method
- */
- @Test
- void activateAutoConfirmationPermissionsCheck() {
- assertPermissions(() -> confirmationManagement.activateAutoConfirmation("controllerId", "initiator", "remark"),
- List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ConfirmationManagement#getStatus() method
- */
- @Test
- void getStatusPermissionsCheck() {
- assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpPermission.READ_TARGET),
- List.of(SpPermission.CREATE_TARGET));
- assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ConfirmationManagement#confirmAction() method
- */
- @Test
- void confirmActionPermissionsCheck() {
- assertPermissions(() -> confirmationManagement.confirmAction(1L, null, null),
- List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ConfirmationManagement#denyAction() method
- */
- @Test
- void denyActionPermissionsCheck() {
- assertPermissions(() -> confirmationManagement.denyAction(1L, null, null),
- List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ConfirmationManagement#deactivateAutoConfirmation() method
- */
- @Test
- void deactivateAutoConfirmationPermissionsCheck() {
- assertPermissions(() -> {
- confirmationManagement.deactivateAutoConfirmation("controllerId");
- return null;
- }, List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java
deleted file mode 100644
index b7f42ff53..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.hawkbit.im.authentication.SpRole;
-import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
-import org.eclipse.hawkbit.repository.model.Action;
-import org.eclipse.hawkbit.repository.model.Action.ActionStatusCreate;
-import org.eclipse.hawkbit.repository.model.Target;
-import org.junit.jupiter.api.Test;
-import org.springframework.data.domain.Pageable;
-
-/**
- * Feature: SecurityTests - ControllerManagement
- * Story: SecurityTests ControllerManagement
- */
-class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ControllerManagement#cancelActionStatus() method
- */
- @Test
- void addCancelActionStatusPermissionsCheck() {
- assertPermissions(() -> controllerManagement.addCancelActionStatus(
- ActionStatusCreate.builder().actionId(0L).status(Action.Status.DOWNLOADED).build()),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getSoftwareModule() method
- */
- @Test
- void getSoftwareModulePermissionsCheck() {
- assertPermissions(() -> controllerManagement.getSoftwareModule(1L), List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#findTargetVisibleMetaDataBySoftwareModuleId() method
- */
- @Test
- void findTargetVisibleMetaDataBySoftwareModuleIdPermissionsCheck() {
- assertPermissions(() -> controllerManagement.findTargetVisibleMetaDataBySoftwareModuleId(List.of(1L)),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#addInformationalActionStatus() method
- */
- @Test
- void addInformationalActionStatusPermissionsCheck() {
- assertPermissions(() -> controllerManagement.addInformationalActionStatus(
- ActionStatusCreate.builder().actionId(0L).status(Action.Status.DOWNLOADED).build()),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#addUpdateActionStatus() method
- */
- @Test
- void addUpdateActionStatusPermissionsCheck() {
- assertPermissions(() -> controllerManagement.addUpdateActionStatus(
- ActionStatusCreate.builder().actionId(0L).status(Action.Status.DOWNLOADED).build()),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#findActiveActionWithHighestWeight() method
- */
- @Test
- void findActiveActionWithHighestWeightPermissionsCheck() {
- assertPermissions(() -> controllerManagement.findActiveActionWithHighestWeight("controllerId"),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#findActiveActionsWithHighestWeight() method
- */
- @Test
- void findActiveActionsWithHighestWeightPermissionsCheck() {
- assertPermissions(() -> controllerManagement.findActiveActionsWithHighestWeight("controllerId", 1),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#findActionWithDetails() method
- */
- @Test
- void findActionWithDetailsPermissionsCheck() {
- assertPermissions(() -> controllerManagement.findActionWithDetails(1L), List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#findActionStatusByAction() method
- */
- @Test
- void findActionStatusByActionPermissionsCheck() {
- assertPermissions(() -> controllerManagement.findActionStatusByAction(1L, Pageable.unpaged()),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#findOrRegisterTargetIfItDoesNotExist() method
- */
- @Test
- void findOrRegisterTargetIfItDoesNotExistPermissionsCheck() {
- assertPermissions(() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist("controllerId", URI.create("someaddress")),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#findOrRegisterTargetIfItDoesNotExist() method
- */
- @Test
- void findOrRegisterTargetIfItDoesNotExistWithDetailsPermissionsCheck() {
- assertPermissions(
- () -> controllerManagement.findOrRegisterTargetIfItDoesNotExist("controllerId", URI.create("someaddress"), "name", "type"),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getActionForDownloadByTargetAndSoftwareModule() method
- */
- @Test
- void getActionForDownloadByTargetAndSoftwareModulePermissionsCheck() {
- assertPermissions(() -> controllerManagement.getActionForDownloadByTargetAndSoftwareModule("controllerId", 1L),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getPollingTime() method
- */
- @Test
- void getPollingTimePermissionsCheck() {
- assertPermissions(() -> controllerManagement.getPollingTime(null), List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getPollingTimeForAction() method
- */
- @Test
- void getPollingTimeForActionPermissionsCheck() {
- final JpaAction action = new JpaAction();
- action.setId(1L);
- assertPermissions(() -> {
- try {
- controllerManagement.getPollingTimeForAction(action.getTarget(), action);
- } catch (final CancelActionNotAllowedException e) {
- // expected since action is not found
- }
- return null;
- }, List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#hasTargetArtifactAssigned() method
- */
- @Test
- void hasTargetArtifactAssignedPermissionsCheck() {
- assertPermissions(() -> controllerManagement.hasTargetArtifactAssigned("controllerId", "sha1Hash"),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#hasTargetArtifactAssigned() method
- */
- @Test
- void hasTargetArtifactAssignedByIdPermissionsCheck() {
- assertPermissions(() -> controllerManagement.hasTargetArtifactAssigned(1L, "sha1Hash"),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#updateControllerAttributes() method
- */
- @Test
- void updateControllerAttributesPermissionsCheck() {
- assertPermissions(() -> controllerManagement.updateControllerAttributes("controllerId", Map.of(), null),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getByControllerId() method
- */
- @Test
- void findByControllerIdPermissionsCheck() {
- assertPermissions(() -> controllerManagement.findByControllerId("controllerId"),
- List.of(SpRole.CONTROLLER_ROLE));
- assertPermissions(() -> controllerManagement.findByControllerId("controllerId"),
- List.of(SpRole.SYSTEM_ROLE));
- }
-
- /**
- * Tests ControllerManagement#get() method
- */
- @Test
- void getPermissionsCheck() {
- assertPermissions(() -> controllerManagement.find(1L), List.of(SpRole.CONTROLLER_ROLE));
- assertPermissions(() -> controllerManagement.find(1L), List.of(SpRole.SYSTEM_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getActionHistoryMessages() method
- */
- @Test
- void getActionHistoryMessagesPermissionsCheck() {
- assertPermissions(() -> controllerManagement.getActionHistoryMessages(1L, 1),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#cancelAction() method
- */
- @Test
- void cancelActionPermissionsCheck() {
- final JpaAction action = new JpaAction();
- action.setId(1L);
- assertPermissions(() -> {
- try {
- controllerManagement.cancelAction(action);
- } catch (final CancelActionNotAllowedException e) {
- // expected since action is not found
- }
- return null;
- }, List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#updateActionExternalRef() method
- */
- @Test
- void updateActionExternalRefPermissionsCheck() {
- assertPermissions(() -> {
- controllerManagement.updateActionExternalRef(1L, "externalRef");
- return null;
- }, List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getActionByExternalRef() method
- */
- @Test
- void getActionByExternalRefPermissionsCheck() {
- assertPermissions(() -> controllerManagement.getActionByExternalRef("externalRef"),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#deleteExistingTarget() method
- */
- @Test
- void deleteExistingTargetPermissionsCheck() {
- assertPermissions(() -> {
- controllerManagement.deleteExistingTarget("controllerId");
- return null;
- }, List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#getInstalledActionByTarget() method
- */
- @Test
- void getInstalledActionByTargetPermissionsCheck() {
- final Target target = testdataFactory.createTarget();
- assertPermissions(
- () -> controllerManagement.getInstalledActionByTarget(target),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#activateAutoConfirmation() method
- */
- @Test
- void activateAutoConfirmationPermissionsCheck() {
- assertPermissions(
- () -> controllerManagement.activateAutoConfirmation("controllerId", "initiator", "remark"),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#deactivateAutoConfirmation() method
- */
- @Test
- void deactivateAutoConfirmationPermissionsCheck() {
- assertPermissions(() -> {
- controllerManagement.deactivateAutoConfirmation("controllerId");
- return null;
- }, List.of(SpRole.CONTROLLER_ROLE));
- }
-
- /**
- * Tests ControllerManagement#updateOfflineAssignedVersion() method
- */
- @Test
- void updateOfflineAssignedVersionPermissionsCheck() {
- assertPermissions(() -> controllerManagement.updateOfflineAssignedVersion("controllerId", "distributionName", "version"),
- List.of(SpRole.CONTROLLER_ROLE));
- }
-
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java
deleted file mode 100644
index c646bff2b..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-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.ActionCancellationType;
-import org.eclipse.hawkbit.repository.model.DeploymentRequest;
-import org.junit.jupiter.api.Test;
-import org.springframework.data.domain.Pageable;
-
-/**
- * Feature: SecurityTests - DeploymentManagement
- * Story: SecurityTests DeploymentManagement
- */
-class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignDistributionSetsPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.assignDistributionSets(
- List.of(new DeploymentRequest("controllerId", 1L, Action.ActionType.SOFT, 1L, 1, "maintenanceSchedule",
- "maintenanceWindowDuration", "maintenanceWindowTimeZone", true))),
- List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignDistributionSetsWithInitiatedByPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.assignDistributionSets("initiator",
- List.of(new DeploymentRequest("controllerId", 1L, Action.ActionType.SOFT, 1L, 1, "maintenanceSchedule",
- "maintenanceWindowDuration", "maintenanceWindowTimeZone", true)), "message"),
- List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void offlineAssignedDistributionSetsPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.offlineAssignedDistributionSets(List.of()),
- List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void offlineAssignedDistributionSetsWithInitiatedByPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.offlineAssignedDistributionSets("initiator", List.of()),
- List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void cancelActionPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.cancelAction(1L), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countActionsByTargetWithFilterPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.countActionsByTarget("rsqlParam", "controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countActionsByTargetPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.countActionsByTarget("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countActionsAllPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.countActionsAll(), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countActionsPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.countActions("id==1"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActionPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findAction(1L), List.of(SpPermission.READ_TARGET));
- }
-
- @Test
- void findActionsAllPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActionsAll(Pageable.unpaged()), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActionsPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActions("id==1", Pageable.unpaged()), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActionsByTargetPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActionsByTarget("rsql==param", "controllerId", Pageable.unpaged()),
- List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActionsByTargetWithControllerIdPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActionsByTarget("controllerId", Pageable.unpaged()),
- List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActionStatusByActionPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActionStatusByAction(1L, Pageable.unpaged()), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countActionStatusByActionPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.countActionStatusByAction(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findMessagesByActionStatusIdPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(1L, PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActionWithDetailsPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActionWithDetails(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActiveActionsByTargetPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActiveActionsByTarget("controllerId", Pageable.unpaged()),
- List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findInActiveActionsByTargetPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget("controllerId", Pageable.unpaged()),
- List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActiveActionsWithHighestWeightPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.findActiveActionsWithHighestWeight("controllerId", 1), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void forceQuitActionPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.forceQuitAction(1L), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void forceTargetActionPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.forceTargetAction(1L), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void cancelInactiveScheduledActionsForTargetsPermissionsCheck() {
- assertPermissions(() -> {
- deploymentManagement.cancelInactiveScheduledActionsForTargets(List.of(1L));
- return null;
- }, List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void startScheduledActionsByRolloutGroupParentPermissionsCheck() {
- assertPermissions(() -> {
- deploymentManagement.startScheduledActionsByRolloutGroupParent(1L, 1L, 1L);
- return null;
- }, List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void startScheduledActionsPermissionsCheck() {
- assertPermissions(() -> {
- deploymentManagement.startScheduledActions(List.of());
- return null;
- }, List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getAssignedDistributionSetPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.getAssignedDistributionSet("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getInstalledDistributionSetPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.getInstalledDistributionSet("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteActionsByStatusAndLastModifiedBeforePermissionsCheck() {
- assertPermissions(() -> deploymentManagement.deleteActionsByStatusAndLastModifiedBefore(Set.of(Action.Status.CANCELED), 1L),
- List.of(SpRole.SYSTEM_ROLE));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void hasPendingCancellationsPermissionsCheck() {
- assertPermissions(() -> deploymentManagement.hasPendingCancellations(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void cancelActionsForDistributionSetPermissionsCheck() {
- assertPermissions(() -> {
- deploymentManagement.cancelActionsForDistributionSet(
- ActionCancellationType.FORCE, new JpaDistributionSet());
- return null;
- }, List.of(SpPermission.UPDATE_TARGET));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java
deleted file mode 100644
index f2d2d8a91..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.DistributionSetManagement;
-import org.eclipse.hawkbit.repository.jpa.AbstractRepositoryManagementSecurityTest;
-import org.eclipse.hawkbit.repository.model.DistributionSet;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - DistributionSetManagement
- * Story: SecurityTests DistributionSetManagement
- */
-class DistributionSetManagementSecurityTest
- extends AbstractRepositoryManagementSecurityTest {
-
- @Override
- protected DistributionSetManagement findRepositoryManagement() {
- return distributionSetManagement;
- }
-
- @Override
- protected DistributionSetManagement.Create findCreateObject() {
- return DistributionSetManagement.Create.builder().name("name").version("1.0.0").type(defaultDsType()).build();
- }
-
- @Override
- protected DistributionSetManagement.Update findUpdateObject() {
- return DistributionSetManagement.Update.builder().id(0L).name("a new name")
- .description("a new description").version("a new version").requiredMigrationStep(true).build();
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignSoftwareModulesPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.assignSoftwareModules(1L, List.of(1L)), List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignTagPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.assignTag(List.of(1L), 1L),
- List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests that the method throws InsufficientPermissionException when the user does not have the correct permission
- */
- @Test
- void unassignTagPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.unassignTag(List.of(1L), 1L),
- List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createMetadataMapPermissionsCheck() {
- assertPermissions(
- () -> {
- distributionSetManagement.createMetadata(1L, Map.of("key", "value"));
- return null;
- },
- List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getMetadataPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.getMetadata(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createMetadataPermissionsCheck() {
- assertPermissions(() -> {
- distributionSetManagement.createMetadata(1L, "key", "value");
- return null;
- },
- List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteMetadataPermissionsCheck() {
- assertPermissions(() -> {
- distributionSetManagement.deleteMetadata(1L, "key");
- return null;
- }, List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void lockPermissionsCheck() {
- final DistributionSet ds = testdataFactory.createDistributionSet();
- assertPermissions(() -> distributionSetManagement.lock(ds), List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void unlockPermissionsCheck() {
- final DistributionSet ds = testdataFactory.createDistributionSet();
- assertPermissions(() -> distributionSetManagement.unlock(ds), List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getWithDetailsPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.getWithDetails(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByNameAndVersionPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.findByNameAndVersion("name", "version"), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getValidAndCompletePermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.getValidAndComplete(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.get(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByTagPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlAndTagPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.findByRsqlAndTag("rsql", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void unassignSoftwareModulePermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.unassignSoftwareModule(1L, 1L), List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countRolloutsByStatusForDistributionSetPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.countRolloutsByStatusForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countActionsByStatusForDistributionSetPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.countActionsByStatusForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countAutoAssignmentsForDistributionSetPermissionsCheck() {
- assertPermissions(() -> distributionSetManagement.countAutoAssignmentsForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void invalidatePermissionsCheck() {
- final DistributionSet ds = testdataFactory.createDistributionSet();
- assertPermissions(() -> distributionSetManagement.invalidate(ds),
- List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java
deleted file mode 100644
index 47da9f9bc..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-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.jpa.AbstractRepositoryManagementSecurityTest;
-import org.eclipse.hawkbit.repository.model.DistributionSetTag;
-import org.junit.jupiter.api.Test;
-import org.springframework.data.domain.Pageable;
-
-/**
- * Feature: SecurityTests - DistributionSetTagManagement
- * Story: SecurityTests DistributionSetTagManagement
- */
-class DistributionSetTagManagementSecurityTest
- extends AbstractRepositoryManagementSecurityTest {
-
- @Override
- protected RepositoryManagement findRepositoryManagement() {
- return distributionSetTagManagement;
- }
-
- @Override
- protected DistributionSetTagManagement.Create findCreateObject() {
- return DistributionSetTagManagement.Create.builder().name(String.format("tag-%d", new Random().nextInt())).build();
- }
-
- @Override
- protected DistributionSetTagManagement.Update findUpdateObject() {
- return DistributionSetTagManagement.Update.builder().id(1L).name("tag").build();
- }
-}
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java
deleted file mode 100644
index 0f66e3ca0..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-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.jpa.AbstractRepositoryManagementSecurityTest;
-import org.eclipse.hawkbit.repository.model.DistributionSetType;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - DistributionSetTypeManagement
- * Story: SecurityTests DistributionSetTypeManagement
- */
-class DistributionSetTypeManagementSecurityTest
- extends AbstractRepositoryManagementSecurityTest {
-
- @Override
- protected RepositoryManagement findRepositoryManagement() {
- return distributionSetTypeManagement;
- }
-
- @Override
- protected DistributionSetTypeManagement.Create findCreateObject() {
- return DistributionSetTypeManagement.Create.builder().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt())).build();
- }
-
- @Override
- protected DistributionSetTypeManagement.Update findUpdateObject() {
- return DistributionSetTypeManagement.Update.builder().id(1L).description("description").build();
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByKeyPermissionsCheck() {
- assertPermissions(() -> distributionSetTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByNamePermissionsCheck() {
- assertPermissions(() -> distributionSetTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignOptionalSoftwareModuleTypesPermissionsCheck() {
- assertPermissions(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(1L, List.of(1L)),
- List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignMandatorySoftwareModuleTypesPermissionsCheck() {
- assertPermissions(() -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(1L, List.of(1L)),
- List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void unassignSoftwareModuleTypePermissionsCheck() {
- assertPermissions(() -> distributionSetTypeManagement.unassignSoftwareModuleType(1L, 1L), List.of(SpPermission.UPDATE_REPOSITORY));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java
deleted file mode 100644
index 7b383c9b1..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - RolloutGroupManagement
- * Story: SecurityTests RolloutGroupManagement
- */
-class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.get(1L), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getWithDetailedStatusPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.getWithDetailedStatus(1L), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByRolloutPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.countByRollout(1L), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countTargetsOfRolloutsGroupPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.countTargetsOfRolloutsGroup(1L), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRolloutPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findByRollout(1L, PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRolloutAndRsqlPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsql(1L, "name==*", PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findTargetsOfRolloutGroupPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(1L, PAGE),
- List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findTargetsOfRolloutGroupByRsqlPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(1L, "name==*", PAGE),
- List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(1L, "name==*", PAGE),
- List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRolloutWithDetailedStatusPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(1L, PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-}
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java
deleted file mode 100644
index f0e16bc26..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.DistributionSetManagement;
-import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
-import org.eclipse.hawkbit.repository.RolloutManagement;
-import org.eclipse.hawkbit.repository.RolloutManagement.Create;
-import org.eclipse.hawkbit.repository.RolloutManagement.GroupCreate;
-import org.eclipse.hawkbit.repository.RolloutManagement.Update;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.eclipse.hawkbit.repository.model.ActionCancellationType;
-import org.eclipse.hawkbit.repository.model.DistributionSet;
-import org.eclipse.hawkbit.repository.model.Rollout;
-import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
-import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
-import org.eclipse.hawkbit.repository.test.util.WithUser;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * Feature: SecurityTests - RolloutManagement
- * Story: SecurityTests RolloutManagement
- */
-@Slf4j
-class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- @Autowired
- private TestdataFactory testdataFactory;
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.find(1L), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByNamePermissionsCheck() {
- assertPermissions(() -> rolloutManagement.getByName("name"), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findWithDetailedStatusPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.getWithDetailedStatus(1L), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void approveOrDenyPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.approveOrDeny(1L, Rollout.ApprovalDecision.APPROVED), List.of(SpPermission.APPROVE_ROLLOUT));
- assertPermissions(() -> rolloutManagement.approveOrDeny(1L, Rollout.ApprovalDecision.APPROVED, "comment"),
- List.of(SpPermission.APPROVE_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void pauseRolloutPermissionsCheck() {
- assertPermissions(() -> {
- rolloutManagement.pauseRollout(1L);
- return null;
- }, List.of(SpPermission.HANDLE_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void resumeRolloutPermissionsCheck() {
- assertPermissions(() -> {
- rolloutManagement.resumeRollout(1L);
- return null;
- }, List.of(SpPermission.HANDLE_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findActiveRolloutsPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.findActiveRollouts(), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void cancelRolloutsForDistributionSetPermissionsCheck() {
- final DistributionSetTypeManagement.Create key = DistributionSetTypeManagement.Create.builder().name("type").key("type").build();
- distributionSetTypeManagement.create(key);
- 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, ActionCancellationType.SOFT);
- return null;
- }, List.of(SpPermission.UPDATE_ROLLOUT, SpPermission.READ_REPOSITORY, SpPermission.CREATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.count(), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByDistributionSetIdAndRolloutIsStoppablePermissionsCheck() {
- assertPermissions(() -> rolloutManagement.countByDistributionSetIdAndRolloutIsStoppable(1L), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createPermissionsCheck() {
- testdataFactory.createTarget(); // to have matching
- final DistributionSet ds = testdataFactory.createDistributionSetLocked("createPermissionsCheck");
- final List permissions = List.of(SpPermission.CREATE_ROLLOUT, SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY);
- assertPermissions(() -> rolloutManagement.create(
- Create.builder().name("createPermissionsCheck").distributionSet(ds).targetFilterQuery("controllerid==*").build(),
- 1, false, new RolloutGroupConditionBuilder().withDefaults().build()),
- permissions);
- assertPermissions(() -> rolloutManagement.create(
- Create.builder().name("createPermissionsCheck2").distributionSet(ds).targetFilterQuery("controllerid==*").dynamic(true).build(),
- 1, false, new RolloutGroupConditionBuilder().withDefaults().build(), RolloutManagement.DynamicRolloutGroupTemplate.builder().build()),
- permissions);
- assertPermissions(
- () -> rolloutManagement.create(
- Create.builder().name("createPermissionsCheck3").distributionSet(ds).targetFilterQuery("controllerid==*").build(),
- List.of(GroupCreate.builder().name("group").build()), new RolloutGroupConditionBuilder().withDefaults().build()),
- permissions);
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findAllPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.findAll(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.findByRsql("id==1", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findAllWithDetailedStatusPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlWithDetailedStatusPermissionsCheck() {
- assertPermissions(() ->
- rolloutManagement.findByRsqlWithDetailedStatus("name==*", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void startPermissionsCheck() {
- assertPermissions(() -> rolloutManagement.start(1L), List.of(SpPermission.HANDLE_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updatePermissionsCheck() {
- assertPermissions(() -> rolloutManagement.update(Update.builder().id(1L).build()), List.of(SpPermission.UPDATE_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deletePermissionsCheck() {
- assertPermissions(() -> {
- rolloutManagement.delete(1L);
- return null;
- }, List.of(SpPermission.DELETE_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void triggerNextGroupPermissionsCheck() {
- assertPermissions(() -> {
- rolloutManagement.triggerNextGroup(1L);
- return null;
- }, List.of(SpPermission.UPDATE_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- @WithUser(principal = "user", authorities = { SpPermission.READ_ROLLOUT })
- void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(1L, "name==*", PAGE),
- List.of(SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRolloutWithDetailedStatusPermissionsCheck() {
- assertPermissions(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(1L, PAGE), List.of(SpPermission.READ_ROLLOUT));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java
deleted file mode 100644
index c7af40a2c..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.im.authentication.SpRole;
-import org.eclipse.hawkbit.repository.RepositoryManagement;
-import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
-import org.eclipse.hawkbit.repository.jpa.AbstractRepositoryManagementSecurityTest;
-import org.eclipse.hawkbit.repository.model.SoftwareModule;
-import org.eclipse.hawkbit.repository.model.SoftwareModule.MetadataValueCreate;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - SoftwareManagement
- * Story: SecurityTests SoftwareManagement
- */
-class SoftwareManagementSecurityTest
- extends AbstractRepositoryManagementSecurityTest {
-
- @Override
- protected RepositoryManagement findRepositoryManagement() {
- return softwareModuleManagement;
- }
-
- @Override
- protected SoftwareModuleManagement.Create findCreateObject() {
- return SoftwareModuleManagement.Create.builder().type(getASmType()).name("name").version("version").build();
- }
-
- @Override
- protected SoftwareModuleManagement.Update findUpdateObject() {
- return SoftwareModuleManagement.Update.builder().id(1L).locked(true).build();
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createMetaDataPermissionsCheck() {
- assertPermissions(
- () -> {
- softwareModuleManagement.createMetadata(1L, "key", new MetadataValueCreate("value"));
- return null;
- },
- List.of(SpPermission.UPDATE_REPOSITORY));
- assertPermissions(() -> {
- softwareModuleManagement.createMetadata(
- 1L,
- Map.of("key", new MetadataValueCreate("value")));
- return null;
- }, List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteMetaDataPermissionsCheck() {
- assertPermissions(() -> {
- softwareModuleManagement.deleteMetadata(1L, "key");
- return null;
- }, List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByAssignedToPermissionsCheck() {
- assertPermissions(() -> softwareModuleManagement.findByAssignedTo(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getMetaDataBySoftwareModuleIdPermissionsCheck() {
- assertPermissions(() -> softwareModuleManagement.getMetadata(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findMetaDataBySoftwareModuleIdPermissionsCheck() {
- assertPermissions(() -> softwareModuleManagement.getMetadata(1L), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void lockPermissionsCheck() {
- final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleOs();
- assertPermissions(() -> {
- softwareModuleManagement.lock(softwareModule);
- return null;
- }, List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void unlockPermissionsCheck() {
- final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleOs();
- assertPermissions(() -> {
- softwareModuleManagement.unlock(softwareModule);
- return null;
- }, List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updateMetaDataPermissionsCheck() {
- assertPermissions(
- () -> {
- softwareModuleManagement.createMetadata(1L, "key", new MetadataValueCreate("value"));
- return null;
- },
- List.of(SpPermission.UPDATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findMetaDataBySoftwareModuleIdsAndTargetVisiblePermissionsCheck() {
- assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdsAndTargetVisible(List.of(1L)),
- List.of(SpRole.SYSTEM_ROLE));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java
deleted file mode 100644
index 82cc6c994..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-import java.util.Random;
-
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.RepositoryManagement;
-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;
-
-/**
- * Feature: SecurityTests - SoftwareModuleTypeManagement
- * Story: SecurityTests SoftwareModuleTypeManagement
- */
-class SoftwareModuleTypeManagementSecurityTest
- extends AbstractRepositoryManagementSecurityTest {
-
- @Override
- protected RepositoryManagement findRepositoryManagement() {
- return softwareModuleTypeManagement;
- }
-
- @Override
- protected SoftwareModuleTypeManagement.Create findCreateObject() {
- return SoftwareModuleTypeManagement.Create.builder().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt())).build();
- }
-
- @Override
- protected SoftwareModuleTypeManagement.Update findUpdateObject() {
- return SoftwareModuleTypeManagement.Update.builder().id(1L).description("description").build();
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByKeyPermissionsCheck() {
- assertPermissions(() -> softwareModuleTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByNamePermissionsCheck() {
- assertPermissions(() -> softwareModuleTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java
deleted file mode 100644
index 16c6bc701..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.im.authentication.SpRole;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - SystemManagement
- * Story: SecurityTests SystemManagement
- */
-@Slf4j
-class SystemManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findTenantsPermissionWorks() {
- assertPermissions(() -> systemManagement.findTenants(PAGE), List.of(SpPermission.SYSTEM_ADMIN));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteTenantPermissionsCheck() {
- assertPermissions(() -> {
- systemManagement.deleteTenant("tenant");
- return null;
- }, List.of(SpPermission.SYSTEM_ADMIN));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void forEachTenantTenantPermissionsCheck() {
- assertPermissions(() -> {
- systemManagement.forEachTenant(log::info);
- return null;
- }, List.of(SpRole.SYSTEM_ROLE));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getSystemUsageStatisticsWithTenantsPermissionsCheck() {
- assertPermissions(() -> systemManagement.getSystemUsageStatisticsWithTenants(), List.of(SpPermission.SYSTEM_ADMIN));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getSystemUsageStatisticsPermissionsCheck() {
- assertPermissions(() -> systemManagement.getSystemUsageStatistics(), List.of(SpPermission.SYSTEM_ADMIN));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getTenantMetadataPermissionsCheck() {
- assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY));
- assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_TARGET), List.of(SpPermission.CREATE_REPOSITORY));
- assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_TENANT_CONFIGURATION), List.of(SpPermission.CREATE_REPOSITORY));
- assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getTenantMetadataWithoutDetailsPermissionsCheck() {
- assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY));
- assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_TARGET), List.of(SpPermission.CREATE_REPOSITORY));
- assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_TENANT_CONFIGURATION), List.of(SpPermission.CREATE_REPOSITORY));
- assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getTenantMetadataByTenantPermissionsCheck() {
- assertPermissions(() -> systemManagement.getTenantMetadata(1L), List.of(SpRole.SYSTEM_ROLE));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createTenantMetadataPermissionsCheck() {
- assertPermissions(() -> systemManagement.createTenantMetadata("tenant"), List.of(SpRole.SYSTEM_ROLE));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updateTenantMetadataPermissionsCheck() {
- assertPermissions(() -> systemManagement.updateTenantMetadata(1L), List.of(SpPermission.TENANT_CONFIGURATION));
- }
-}
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java
deleted file mode 100644
index 65657f640..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.TargetFilterQueryManagement.AutoAssignDistributionSetUpdate;
-import org.eclipse.hawkbit.repository.TargetFilterQueryManagement.Create;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - TargetFilterQueryManagement
- * Story: SecurityTests TargetFilterQueryManagement
- */
-class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createPermissionsCheck() {
- assertPermissions(
- () -> targetFilterQueryManagement.create(Create.builder().name("name").query("controllerId==id").build()),
- List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deletePermissionsCheck() {
- assertPermissions(() -> {
- targetFilterQueryManagement.delete(1L);
- return null;
- }, List.of(SpPermission.DELETE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void verifyTargetFilterQuerySyntaxPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.verifyTargetFilterQuerySyntax("controllerId==id"),
- List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findAllPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.count(), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByAutoAssignDistributionSetIdPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.countByAutoAssignDistributionSetId(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.findByRsql("name==id", PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByAutoAssignDSAndRsqlPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(1L, "rsqlParam", PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findWithAutoAssignDSPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.findWithAutoAssignDS(PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getTargetFilterQueryByIdPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.find(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updateAutoAssignDSPermissionsCheck() {
- assertPermissions(() -> targetFilterQueryManagement.updateAutoAssignDS(new AutoAssignDistributionSetUpdate(1L).weight(1)),
- List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void cancelAutoAssignmentForDistributionSetPermissionsCheck() {
- assertPermissions(() -> {
- targetFilterQueryManagement.cancelAutoAssignmentForDistributionSet(1L);
- return null;
- }, List.of(SpPermission.UPDATE_TARGET));
- }
-}
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java
deleted file mode 100644
index 5411abe91..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-import java.util.Map;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.TargetManagement.Create;
-import org.eclipse.hawkbit.repository.TargetManagement.Update;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.eclipse.hawkbit.repository.test.util.WithUser;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - TargetManagement
- * Story: SecurityTests TargetManagement
- */
-@Slf4j
-class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByRsqlPermissionsCheck() {
- assertPermissions(() -> targetManagement.countByRsql("controllerId==id"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByRsqlAndCompatiblePermissionsCheck() {
- assertPermissions(() -> targetManagement.countByRsqlAndCompatible("controllerId==id", 1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByFailedInRolloutPermissionsCheck() {
- assertPermissions(() -> targetManagement.countByFailedInRollout("1", 1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countPermissionsCheck() {
- assertPermissions(() -> targetManagement.count(), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createPermissionsCheck() {
- assertPermissions(() -> targetManagement.create(Create.builder().controllerId("controller").name("name").build()),
- List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createCollectionPermissionsCheck() {
- assertPermissions(() -> targetManagement.create(List.of(Create.builder().controllerId("controller").name("name").build())),
- List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deletePermissionsCheck() {
- assertPermissions(() -> {
- targetManagement.delete(List.of(1L));
- return null;
- }, List.of(SpPermission.DELETE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteByControllerIdPermissionsCheck() {
- assertPermissions(() -> {
- targetManagement.deleteByControllerId("controllerId");
- return null;
- }, List.of(SpPermission.DELETE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() {
- assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id", PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByRsqlAndNonDsAndCompatibleAndUpdatablePermissionsCheck() {
- assertPermissions(() -> targetManagement.countByRsqlAndNonDsAndCompatibleAndUpdatable(1L, "controllerId==id"),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
- assertPermissions(
- () -> targetManagement.findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(
- List.of(1L), "controllerId==id", defaultDsType(), PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByActionsInRolloutGroupPermissionsCheck() {
- assertPermissions(() -> targetManagement.countByActionsInRolloutGroup(1L),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() {
- assertPermissions(
- () -> targetManagement.countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(
- "controllerId==id", List.of(1L), defaultDsType()),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByFailedRolloutAndNotInRolloutGroups("1", List.of(1L), PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
- assertPermissions(() -> targetManagement.countByFailedRolloutAndNotInRolloutGroups("1", List.of(1L)),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByInRolloutGroupWithoutActionPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(1L, PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByAssignedDistributionSetPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByAssignedDistributionSet(1L, PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByAssignedDistributionSetAndRsqlPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(1L, "controllerId==id", PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByControllerCollectionIDPermissionsCheck() {
- assertPermissions(() -> targetManagement.getByControllerId(List.of("controllerId")), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByControllerIdPermissionsCheck() {
- assertPermissions(() -> targetManagement.getByControllerId("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByInstalledDistributionSetPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByInstalledDistributionSet(1L, PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByInstalledDistributionSetAndRsqlPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(1L, "controllerId==id", PAGE),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findAllPermissionsCheck() {
- assertPermissions(() -> targetManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByRsql("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByTagPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlAndTagPermissionsCheck() {
- assertPermissions(() -> targetManagement.findByRsqlAndTag("controllerId==id", 1L, PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void unassignTypeByIdPermissionsCheck() {
- assertPermissions(() -> targetManagement.unassignType("controllerId"), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignTagWithHandlerPermissionsCheck() {
- assertPermissions(() -> targetManagement.assignTag(List.of("controllerId"), 1L, strings -> {}),
- List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignTagPermissionsCheck() {
- assertPermissions(() -> targetManagement.assignTag(List.of("controllerId"), 1L),
- List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void unassignTagPermissionsCheck() {
- assertPermissions(() -> targetManagement.unassignTag(List.of("controllerId"), 1L), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void unassignTagWithHandlerPermissionsCheck() {
- assertPermissions(() -> targetManagement.unassignTag(List.of("controllerId"), 1L, strings -> {}),
- List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignTypeByIdPermissionsCheck() {
- assertPermissions(() -> targetManagement.assignType("controllerId", 1L), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updatePermissionsCheck() {
- assertPermissions(() -> targetManagement.update(Update.builder().id(1L).build()), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getPermissionsCheck() {
- assertPermissions(() -> targetManagement.find(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getCollectionPermissionsCheck() {
- assertPermissions(() -> targetManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatablePermissionsCheck() {
- assertPermissions(
- () -> targetManagement.isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatable("controllerId", 1L, "controllerId==id"),
- List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getTagsPermissionsCheck() {
- assertPermissions(() -> targetManagement.getTags("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getControllerAttributesPermissionsCheck() {
- assertPermissions(() -> targetManagement.getControllerAttributes("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createMetadataMapPermissionsCheck() {
- assertPermissions(
- () -> {
- targetManagement.createMetadata("controllerId", Map.of("key", "value"));
- return null;
- },
- List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getMetadataPermissionsCheck() {
- assertPermissions(() -> targetManagement.getMetadata("controllerId"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- @WithUser(principal = "user", authorities = { SpPermission.UPDATE_TARGET })
- void createMetadataPermissionsCheck() {
- assertPermissions(() -> {
- targetManagement.createMetadata("controllerId", "key", "value");
- return null;
- },
- List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteMetadataPermissionsCheck() {
- assertPermissions(() -> {
- targetManagement.deleteMetadata("controllerId", "key");
- return null;
- }, List.of(SpPermission.UPDATE_TARGET));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java
deleted file mode 100644
index f7a9b31ae..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.TargetTagManagement;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - TargetTagManagement
- * Story: SecurityTests TargetTagManagement
- */
-@Slf4j
-class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countPermissionsCheck() {
- assertPermissions(() -> targetTagManagement.count(), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createPermissionsCheck() {
- assertPermissions(
- () -> targetTagManagement.create(TargetTagManagement.Create.builder().name("name").build()),
- List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createCollectionPermissionsCheck() {
- assertPermissions(
- () -> targetTagManagement.create(List.of(TargetTagManagement.Create.builder().name("name").build())),
- List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deletePermissionsCheck() {
- assertPermissions(() -> {
- targetTagManagement.delete(1);
- return null;
- }, List.of(SpPermission.DELETE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findAllPermissionsCheck() {
- assertPermissions(() -> targetTagManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlPermissionsCheck() {
- assertPermissions(() -> targetTagManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getPermissionsCheck() {
- assertPermissions(() -> targetTagManagement.find(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getCollectionPermissionsCheck() {
- assertPermissions(() -> targetTagManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updatePermissionsCheck() {
- assertPermissions(() -> targetTagManagement.update(TargetTagManagement.Update.builder().id(1L).build()), List.of(SpPermission.UPDATE_TARGET));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java
deleted file mode 100644
index ae1c94e25..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.TargetTypeManagement.Create;
-import org.eclipse.hawkbit.repository.TargetTypeManagement.Update;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.eclipse.hawkbit.repository.test.util.WithUser;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - TargetTypeManagement
- * Story: SecurityTests TargetTypeManagement
- */
-@Slf4j
-class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByKeyPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.getByKey("key"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getByNamePermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.getByName("name"), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void countPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.count(), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.create(Create.builder().name("name").build()),
- List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void createCollectionPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.create(List.of(Create.builder().name("name").build())),
- List.of(SpPermission.CREATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deletePermissionsCheck() {
- assertPermissions(() -> {
- targetTypeManagement.delete(1L);
- return null;
- }, List.of(SpPermission.DELETE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findAllPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void findByRsqlPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.find(1L), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getCollectionPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void updatePermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.update(Update.builder().id(1L).build()), List.of(SpPermission.UPDATE_TARGET));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void assignCompatibleDistributionSetTypesPermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.assignCompatibleDistributionSetTypes(1L, List.of(1L)),
- List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- @WithUser(principal = "user", authorities = { SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY })
- void unassignDistributionSetTypePermissionsCheck() {
- assertPermissions(() -> targetTypeManagement.unassignDistributionSetType(1L, 1L),
- List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY));
- }
-}
\ No newline at end of file
diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java
deleted file mode 100644
index be09dd1a5..000000000
--- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright (c) 2022 Bosch.IO GmbH and others
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.hawkbit.repository.jpa.management;
-
-import java.util.List;
-import java.util.Map;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.hawkbit.im.authentication.SpPermission;
-import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
-import org.junit.jupiter.api.Test;
-
-/**
- * Feature: SecurityTests - TargetManagement
- * Story: SecurityTests TargetManagement
- */
-@Slf4j
-class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTest {
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void addOrUpdateConfigurationPermissionsCheck() {
- assertPermissions(() -> tenantConfigurationManagement.addOrUpdateConfiguration("authentication.header.enabled", true),
- List.of(SpPermission.TENANT_CONFIGURATION));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void addOrUpdateConfigurationWithMapPermissionsCheck() {
- assertPermissions(() -> tenantConfigurationManagement.addOrUpdateConfiguration(Map.of("authentication.header.enabled", true)),
- List.of(SpPermission.TENANT_CONFIGURATION));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void deleteConfigurationPermissionsCheck() {
- assertPermissions(() -> {
- tenantConfigurationManagement.deleteConfiguration("authentication.header.enabled");
- return null;
- }, List.of(SpPermission.TENANT_CONFIGURATION));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getConfigurationValuePermissionsCheck() {
- assertPermissions(() -> tenantConfigurationManagement.getConfigurationValue("authentication.header.enabled"),
- List.of(SpPermission.READ_TENANT_CONFIGURATION));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getConfigurationValueWithTypePermissionsCheck() {
- assertPermissions(() -> tenantConfigurationManagement.getConfigurationValue("authentication.header.enabled", Boolean.class),
- List.of(SpPermission.READ_TENANT_CONFIGURATION));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void getGlobalConfigurationValuePermissionsCheck() {
- assertPermissions(() -> tenantConfigurationManagement.getGlobalConfigurationValue("authentication.header.enabled", Boolean.class),
- List.of(SpPermission.READ_TENANT_CONFIGURATION));
- }
-
- /**
- * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
- */
- @Test
- void pollStatusResolverPermissionsCheck() {
- assertPermissions(() -> tenantConfigurationManagement.pollStatusResolver(), List.of(SpPermission.READ_TARGET));
- }
-}
\ No newline at end of file