Compare commits

...

4 Commits

Author SHA1 Message Date
Michael Hoennig
6152c65282 fix component scan in ContextIntegrationTests 2024-04-11 14:40:44 +02:00
Michael Hoennig
0c969848b0 fix ArchitectureTests and remove @Accept 2024-04-11 14:30:27 +02:00
Michael Hoennig
178930a019 cleanups in ImportOfficeData also need to apply to real import, not just test-data 2024-04-11 13:48:29 +02:00
Michael Hoennig
9f0af9274f add first 3-letters of asset-transaction-type to toShortString 2024-04-11 13:47:12 +02:00
77 changed files with 258 additions and 402 deletions

View File

@ -69,13 +69,13 @@ dependencies {
implementation 'org.modelmapper:modelmapper:3.2.0'
implementation 'org.iban4j:iban4j:3.2.7-RELEASE'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0'
implementation 'org.reflections:reflections:0.9.12'
compileOnly 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

View File

@ -1,14 +1,12 @@
package net.hostsharing.hsadminng.errors;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import java.util.UUID;
public class ReferenceNotFoundException extends RuntimeException {
private final Class<?> entityClass;
private final UUID uuid;
public <E extends RbacObject> ReferenceNotFoundException(final Class<E> entityClass, final UUID uuid, final Throwable exc) {
public <E> ReferenceNotFoundException(final Class<E> entityClass, final UUID uuid, final Throwable exc) {
super(exc);
this.entityClass = entityClass;
this.uuid = uuid;

View File

@ -2,22 +2,11 @@ package net.hostsharing.hsadminng.rbac.rbacdef;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionEntity;
import net.hostsharing.hsadminng.hs.office.coopshares.HsOfficeCoopSharesTransactionEntity;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerDetailsEntity;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.sepamandate.HsOfficeSepaMandateEntity;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.test.cust.TestCustomerEntity;
import net.hostsharing.hsadminng.test.dom.TestDomainEntity;
import net.hostsharing.hsadminng.test.pac.TestPackageEntity;
import org.reflections.Reflections;
import org.reflections.scanners.TypeAnnotationsScanner;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import jakarta.validation.constraints.NotNull;
@ -27,7 +16,6 @@ import java.nio.file.Path;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.lang.reflect.Modifier.isStatic;
import static java.util.Arrays.stream;
@ -1187,25 +1175,24 @@ public class RbacView {
}
}
public static Set<Class<? extends RbacObject>> findRbacEntityClasses(String packageName) {
final var reflections = new Reflections(packageName, TypeAnnotationsScanner.class);
return reflections.getTypesAnnotatedWith(Entity.class).stream()
.filter(c -> stream(c.getInterfaces()).anyMatch(i -> i==RbacObject.class))
.map(RbacView::castToSubclassOfRbacObject)
.collect(Collectors.toSet());
}
@SuppressWarnings("unchecked")
private static Class<? extends RbacObject> castToSubclassOfRbacObject(final Class<?> clazz) {
return (Class<? extends RbacObject>) clazz;
}
/**
* This main method generates the RbacViews (PostgreSQL+diagram) for all given entity classes.
*/
public static void main(String[] args) {
Stream.of(
TestCustomerEntity.class,
TestPackageEntity.class,
TestDomainEntity.class,
HsOfficePersonEntity.class,
HsOfficePartnerEntity.class,
HsOfficePartnerDetailsEntity.class,
HsOfficeBankAccountEntity.class,
HsOfficeDebitorEntity.class,
HsOfficeRelationEntity.class,
HsOfficeCoopAssetsTransactionEntity.class,
HsOfficeContactEntity.class,
HsOfficeSepaMandateEntity.class,
HsOfficeCoopSharesTransactionEntity.class,
HsOfficeMembershipEntity.class
).forEach(RbacView::generateRbacView);
public static void main(String[] args) throws Exception {
findRbacEntityClasses("net.hostsharing.hsadminng")
.forEach(RbacView::generateRbacView);
}
}

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.cust;
package net.hostsharing.hsadminng.rbac.test.cust;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.mapper.Mapper;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.cust;
package net.hostsharing.hsadminng.rbac.test.cust;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.cust;
package net.hostsharing.hsadminng.rbac.test.cust;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.dom;
package net.hostsharing.hsadminng.rbac.test.dom;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -7,7 +7,7 @@ import lombok.Setter;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
import net.hostsharing.hsadminng.test.pac.TestPackageEntity;
import net.hostsharing.hsadminng.rbac.test.pac.TestPackageEntity;
import jakarta.persistence.*;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.pac;
package net.hostsharing.hsadminng.rbac.test.pac;
import net.hostsharing.hsadminng.mapper.Mapper;
import net.hostsharing.hsadminng.mapper.OptionalFromJson;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.pac;
package net.hostsharing.hsadminng.rbac.test.pac;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -7,7 +7,7 @@ import lombok.Setter;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
import net.hostsharing.hsadminng.test.cust.TestCustomerEntity;
import net.hostsharing.hsadminng.rbac.test.cust.TestCustomerEntity;
import jakarta.persistence.*;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.pac;
package net.hostsharing.hsadminng.rbac.test.pac;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;

View File

@ -1,17 +1,24 @@
package net.hostsharing.hsadminng.arch;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchCondition;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.ConditionEvents;
import com.tngtech.archunit.lang.SimpleConditionEvent;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.test.Accepts;
import org.junit.jupiter.api.Test;
import org.springframework.data.jpa.repository.JpaRepository;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import org.springframework.data.repository.Repository;
import org.springframework.web.bind.annotation.RestController;
import jakarta.persistence.Table;
import static com.tngtech.archunit.core.domain.JavaModifier.ABSTRACT;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
import static java.lang.String.format;
@AnalyzeClasses(packages = ArchitectureTest.NET_HOSTSHARING_HSADMINNG)
public class ArchitectureTest {
@ -232,20 +239,6 @@ public class ArchitectureTest {
.should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs.office.migration..");
@ArchTest
@SuppressWarnings("unused")
public static final ArchRule acceptsAnnotationOnMethodsRule = methods()
.that().areAnnotatedWith(Accepts.class)
.should().beDeclaredInClassesThat().haveSimpleNameEndingWith("AcceptanceTest")
.orShould().beDeclaredInClassesThat().haveSimpleNameNotContaining("AcceptanceTest$");
@ArchTest
@SuppressWarnings("unused")
public static final ArchRule acceptsAnnotationOnClasesRule = classes()
.that().areAnnotatedWith(Accepts.class)
.should().haveSimpleNameEndingWith("AcceptanceTest")
.orShould().haveSimpleNameNotContaining("AcceptanceTest$");
@ArchTest
@SuppressWarnings("unused")
public static final ArchRule doNotUseJakartaTransactionAnnotationAtClassLevel = noClasses()
@ -270,18 +263,51 @@ public class ArchitectureTest {
org.junit.jupiter.api.Test.class.getName(),
org.junit.Test.class.getName()));
@Test
public void everythingShouldBeFreeOfCycles() {
slices().matching("net.hostsharing.hsadminng.(*)..").should().beFreeOfCycles();
}
@ArchTest
@SuppressWarnings("unused")
static final ArchRule everythingShouldBeFreeOfCycles =
slices().matching("net.hostsharing.hsadminng.(*)..")
.should().beFreeOfCycles()
.ignoreDependency(
ContextBasedTest.class,
net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService.class);
@Test
public void restControllerNaming() {
@ArchTest
@SuppressWarnings("unused")
static final ArchRule restControllerNaming =
classes().that().areAnnotatedWith(RestController.class).should().haveSimpleNameEndingWith("Controller");
}
@Test
public void repositoryNaming() {
classes().that().implement(JpaRepository.class).should().haveSimpleNameEndingWith("Repository");
@ArchTest
@SuppressWarnings("unused")
static final ArchRule repositoryNaming =
classes().that().areAssignableTo(Repository.class).should().haveSimpleNameEndingWith("Repository");
@ArchTest
@SuppressWarnings("unused")
static final ArchRule tableNamesOfRbacEntitiesShouldEndWith_rv =
classes()
.that().areAnnotatedWith(Table.class)
.and().areAssignableTo(RbacObject.class)
.should(haveTableNameEndingWith_rv())
.because("it's required that the table names of RBAC entities end with '_rv'");
static ArchCondition<JavaClass> haveTableNameEndingWith_rv() {
return new ArchCondition<>("RBAC table name end with _rv") {
@Override
public void check(JavaClass javaClass, ConditionEvents events) {
final var table = javaClass.getAnnotationOfType(Table.class);
if (table == null) {
events.add(SimpleConditionEvent.violated(javaClass,
format("@Table annotation missing for RBAC entity %s",
javaClass.getName(), table.name())));
} else if (!table.name().endsWith("_rv")) {
events.add(SimpleConditionEvent.violated(javaClass,
format("Table name of %s does not end with '_rv' for RBAC entity %s",
javaClass.getName(), table.name())));
}
}
};
}
}

View File

@ -4,9 +4,8 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException;
import org.junit.jupiter.api.*;
@ -19,8 +18,8 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
@ -48,7 +47,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
EntityManager em;
@Nested
@Accepts({ "bankaccount:F(Find)" })
class ListBankAccounts {
@Test
@ -113,7 +111,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Nested
@Accepts({ "bankaccount:C(Create)" })
class CreateBankAccount {
@Test
@ -153,7 +150,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Nested
@Accepts({ "bankaccount:R(Read)" })
class GetBankAccount {
@Test
@ -178,7 +174,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Test
@Accepts({ "bankaccount:X(Access Control)" })
void normalUser_canNotGetUnrelatedBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccountUuid = bankAccountRepo.findByOptionalHolderLike("first").get(0).getUuid();
@ -258,7 +253,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Nested
@Accepts({ "bankaccount:D(Delete)" })
class DeleteBankAccount {
@Test
@ -280,7 +274,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Test
@Accepts({ "bankaccount:X(Access Control)" })
void bankaccountOwner_canDeleteRelatedBankAaccount() {
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");
@ -298,7 +291,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Test
@Accepts({ "bankaccount:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");

View File

@ -1,11 +1,11 @@
package net.hostsharing.hsadminng.hs.office.bankaccount;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@ -24,7 +24,7 @@ import java.util.function.Supplier;
import static net.hostsharing.hsadminng.hs.office.bankaccount.TestHsOfficeBankAccount.hsOfficeBankAccount;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -4,9 +4,8 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException;
import org.junit.jupiter.api.AfterEach;
@ -22,8 +21,8 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
@ -54,7 +53,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
EntityManager em;
@Nested
@Accepts({ "Contact:F(Find)" })
class ListContacts {
@Test
@ -91,7 +89,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Contact:C(Create)" })
class AddContact {
@Test
@ -129,7 +126,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Contact:R(Read)" })
class GetContact {
@Test
@ -154,7 +150,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Contact:X(Access Control)" })
void normalUser_canNotGetUnrelatedContact() {
context.define("superuser-alex@hostsharing.net");
final var givenContactUuid = contactRepo.findContactByOptionalLabelLike("first").get(0).getUuid();
@ -170,7 +165,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Contact:X(Access Control)" })
void contactAdminUser_canGetRelatedContact() {
context.define("superuser-alex@hostsharing.net");
final var givenContactUuid = contactRepo.findContactByOptionalLabelLike("first").get(0).getUuid();
@ -195,7 +189,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Contact:U(Update)" })
class PatchContact {
@Test
@ -284,7 +277,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Contact:D(Delete)" })
class DeleteContact {
@Test
@ -306,7 +298,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Contact:X(Access Control)" })
void contactOwner_canDeleteRelatedContact() {
final var givenContact = givenSomeTemporaryContactCreatedBy("selfregistered-test-user@hostsharing.org");
@ -324,7 +315,6 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Contact:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedContact() {
context.define("superuser-alex@hostsharing.net");
final var givenContact = givenSomeTemporaryContactCreatedBy("selfregistered-test-user@hostsharing.org");

View File

@ -1,6 +1,6 @@
package net.hostsharing.hsadminng.hs.office.contact;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeContactPatchResource;
import org.junit.jupiter.api.TestInstance;

View File

@ -1,11 +1,11 @@
package net.hostsharing.hsadminng.hs.office.contact;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@ -24,7 +24,7 @@ import java.util.function.Supplier;
import static net.hostsharing.hsadminng.hs.office.contact.TestHsOfficeContact.hsOfficeContact;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -5,9 +5,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
@ -24,8 +23,8 @@ import java.time.LocalDate;
import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionType.DEPOSIT;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.startsWith;
@ -56,7 +55,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
EntityManager em;
@Nested
@Accepts({ "CoopAssetsTransaction:F(Find)" })
class ListCoopAssetsTransactions {
@Test
@ -154,7 +152,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
}
@Nested
@Accepts({ "CoopAssetsTransaction:C(Create)" })
class AddCoopAssetsTransaction {
@Test
@ -218,7 +215,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
.reference("test ref")
.build());
}).assertSuccessful().assertNotNull().returnedValue();
toCleanup(HsOfficeCoopAssetsTransactionRawEntity.class, givenTransaction.getUuid());
toCleanup(HsOfficeCoopAssetsTransactionEntity.class, givenTransaction.getUuid());
final var location = RestAssured // @formatter:off
.given()
@ -267,7 +264,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
final var newAssetTxUuid = UUID.fromString(
location.substring(location.lastIndexOf('/') + 1));
assertThat(newAssetTxUuid).isNotNull();
toCleanup(HsOfficeCoopAssetsTransactionRawEntity.class, newAssetTxUuid);
toCleanup(HsOfficeCoopAssetsTransactionEntity.class, newAssetTxUuid);
}
@Test
@ -307,7 +304,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
}
@Nested
@Accepts({ "CoopAssetTransaction:R(Read)" })
class GetCoopAssetTransaction {
@Test
@ -334,7 +330,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
}
@Test
@Accepts({ "CoopAssetTransaction:X(Access Control)" })
void normalUser_canNotGetUnrelatedCoopAssetTransaction() {
context.define("superuser-alex@hostsharing.net");
final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
@ -352,7 +347,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
}
@Test
@Accepts({ "CoopAssetTransaction:X(Access Control)" })
void partnerPersonUser_canGetRelatedCoopAssetTransaction() {
context.define("superuser-alex@hostsharing.net");
final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(

View File

@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.coopassets;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.mapper.Mapper;
import net.hostsharing.test.JsonBuilder;
import net.hostsharing.hsadminng.rbac.test.JsonBuilder;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.springframework.beans.factory.annotation.Autowired;
@ -15,7 +15,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.util.UUID;
import java.util.function.Function;
import static net.hostsharing.test.JsonBuilder.jsonObject;
import static net.hostsharing.hsadminng.rbac.test.JsonBuilder.jsonObject;
import static org.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

View File

@ -1,18 +0,0 @@
package net.hostsharing.hsadminng.hs.office.coopassets;
import lombok.NoArgsConstructor;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.util.UUID;
@Entity
@Table(name = "hs_office_coopassetstransaction")
@NoArgsConstructor
public class HsOfficeCoopAssetsTransactionRawEntity {
@Id
private UUID uuid;
}

View File

@ -2,11 +2,11 @@ package net.hostsharing.hsadminng.hs.office.coopassets;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
@ -26,7 +26,7 @@ import java.util.List;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -5,9 +5,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
@ -22,8 +21,8 @@ import jakarta.persistence.PersistenceContext;
import java.time.LocalDate;
import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.startsWith;
@ -62,7 +61,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
}
@Nested
@Accepts({"CoopSharesTransaction:F(Find)"})
class ListCoopSharesTransactions {
@Test
@ -129,7 +127,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
}
@Nested
@Accepts({"CoopSharesTransaction:C(Create)"})
class AddCoopSharesTransaction {
@Test
@ -190,7 +187,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
}
@Nested
@Accepts({"CoopShareTransaction:R(Read)"})
class GetCoopShareTransaction {
@Test
@ -207,7 +203,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
}
@Test
@Accepts({"CoopShareTransaction:X(Access Control)"})
void normalUser_canNotGetUnrelatedCoopShareTransaction() {
context.define("superuser-alex@hostsharing.net");
final var givenCoopShareTransactionUuid = coopSharesTransactionRepo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(null, LocalDate.of(2010, 3, 15), LocalDate.of(2010, 3, 15)).get(0).getUuid();
@ -217,7 +212,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
}
@Test
@Accepts({"CoopShareTransaction:X(Access Control)"})
void partnerPersonUser_canGetRelatedCoopShareTransaction() {
context.define("superuser-alex@hostsharing.net");
final var givenCoopShareTransactionUuid = coopSharesTransactionRepo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(null, LocalDate.of(2010, 3, 15), LocalDate.of(2010, 3, 15)).get(0).getUuid();

View File

@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.coopshares;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.mapper.Mapper;
import net.hostsharing.test.JsonBuilder;
import net.hostsharing.hsadminng.rbac.test.JsonBuilder;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.springframework.beans.factory.annotation.Autowired;
@ -15,7 +15,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.util.UUID;
import java.util.function.Function;
import static net.hostsharing.test.JsonBuilder.jsonObject;
import static net.hostsharing.hsadminng.rbac.test.JsonBuilder.jsonObject;
import static org.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

View File

@ -2,11 +2,11 @@ package net.hostsharing.hsadminng.hs.office.coopshares;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
@ -25,7 +25,7 @@ import java.util.List;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -10,9 +10,8 @@ import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.json.JSONException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -28,8 +27,8 @@ import jakarta.persistence.PersistenceContext;
import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*;
@ -74,7 +73,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
EntityManager em;
@Nested
@Accepts({ "Debitor:F(Find)" })
class ListDebitors {
@Test
@ -434,7 +432,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Debitor:R(Read)" })
class GetDebitor {
@Test
@ -499,7 +496,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Debitor:X(Access Control)" })
void normalUser_canNotGetUnrelatedDebitor() {
context.define("superuser-alex@hostsharing.net");
final var givenDebitorUuid = debitorRepo.findDebitorByOptionalNameLike("First").get(0).getUuid();
@ -515,7 +511,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Debitor:X(Access Control)" })
void contactAdminUser_canGetRelatedDebitorExceptRefundBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenDebitorUuid = debitorRepo.findDebitorByOptionalNameLike("first contact").get(0).getUuid();
@ -541,7 +536,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Debitor:U(Update)" })
class PatchDebitor {
@Test
@ -654,7 +648,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Debitor:D(Delete)" })
class DeleteDebitor {
@Test
@ -676,7 +669,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Debitor:X(Access Control)" })
void contactAdminUser_canNotDeleteRelatedDebitor() {
context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor();
@ -696,7 +688,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Debitor:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedDebitor() {
context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor();

View File

@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

View File

@ -7,12 +7,12 @@ import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.hibernate.Hibernate;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
@ -33,10 +33,10 @@ import jakarta.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
import static net.hostsharing.hsadminng.hs.office.test.EntityList.one;
import static net.hostsharing.hsadminng.rbac.test.EntityList.one;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -6,9 +6,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.json.JSONException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Nested;
@ -25,8 +24,8 @@ import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipStatus.ACTIVE;
import static net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipStatus.CANCELLED;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*;
@ -61,7 +60,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
EntityManager em;
@Nested
@Accepts({ "Membership:F(Find)" })
class ListMemberships {
@Test
@ -168,7 +166,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Nested
@Accepts({ "Membership:C(Create)" })
class AddMembership {
@Test
@ -215,7 +212,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Nested
@Accepts({ "Membership:R(Read)" })
class GetMembership {
@Test
@ -245,7 +241,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Test
@Accepts({ "Membership:X(Access Control)" })
void normalUser_canNotGetUnrelatedMembership() {
context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000101).getUuid();
@ -261,7 +256,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Test
@Accepts({ "Membership:X(Access Control)" })
void parnerRelAgent_canGetRelatedMembership() {
context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000303).getUuid();
@ -290,7 +284,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Nested
@Accepts({ "Membership:U(Update)" })
class PatchMembership {
@Test
@ -371,7 +364,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Nested
@Accepts({ "Membership:D(Delete)" })
class DeleteMembership {
@Test
@ -393,7 +385,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Test
@Accepts({ "Membership:X(Access Control)" })
void partnerAgentUser_canNotDeleteRelatedMembership() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = givenSomeTemporaryMembershipBessler("First");
@ -413,7 +404,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
}
@Test
@Accepts({ "Membership:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedMembership() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = givenSomeTemporaryMembershipBessler("First");

View File

@ -5,7 +5,7 @@ import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipPatchResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipStatusResource;
import net.hostsharing.hsadminng.mapper.Mapper;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

View File

@ -4,11 +4,11 @@ import io.hypersistence.utils.hibernate.type.range.Range;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,7 +26,7 @@ import java.util.List;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -4,7 +4,7 @@ import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionEntity;
@ -22,7 +22,7 @@ import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
import net.hostsharing.hsadminng.hs.office.sepamandate.HsOfficeSepaMandateEntity;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.*;
@ -433,7 +433,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test
@Order(3001)
void removeSelfRepresentativeRelations() {
assumeThatWeAreImportingControlledTestData();
// this happens if a natural person is marked as 'contractual' for itself
final var idsToRemove = new HashSet<Integer>();
@ -453,7 +452,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test
@Order(3002)
void removeEmptyRelations() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberately invalid partner entry #99
final var idsToRemove = new HashSet<Integer>();
@ -474,7 +472,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test
@Order(3003)
void removeEmptyPartners() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberately invalid partner entry #99
final var idsToRemove = new HashSet<Integer>();
@ -498,7 +495,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test
@Order(3004)
void removeEmptyDebitors() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberately invalid partner entry #99
final var idsToRemove = new HashSet<Integer>();
@ -510,8 +506,10 @@ public class ImportOfficeData extends ContextBasedTest {
idsToRemove.add(id);
}
});
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
idsToRemove.forEach(id -> debitors.remove(id));
assumeThatWeAreImportingControlledTestData();
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
}
@Test

View File

@ -10,9 +10,8 @@ import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@ -22,8 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.EX_PARTNER;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*;
@ -54,7 +53,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
JpaAttempt jpaAttempt;
@Nested
@Accepts({ "Partner:F(Find)" })
@Transactional
class ListPartners {
@ -84,7 +82,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Partner:C(Create)" })
@Transactional
class AddPartner {
@ -226,7 +223,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Partner:R(Read)" })
@Transactional
class GetPartner {
@ -264,7 +260,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Partner:X(Access Control)" })
void normalUser_canNotGetUnrelatedPartner() {
context.define("superuser-alex@hostsharing.net");
final var givenPartnerUuid = partnerRepo.findPartnerByOptionalNameLike("First").get(0).getUuid();
@ -280,7 +275,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Partner:X(Access Control)" })
void contactAdminUser_canGetRelatedPartner() {
context.define("superuser-alex@hostsharing.net");
final var givenPartnerUuid = partnerRepo.findPartnerByOptionalNameLike("first contact").get(0).getUuid();
@ -306,7 +300,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Partner:U(Update)" })
@Transactional
class PatchPartner {
@ -462,7 +455,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Nested
@Accepts({ "Partner:D(Delete)" })
@Transactional
class DeletePartner {
@ -486,7 +478,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Partner:X(Access Control)" })
void contactAdminUser_canNotDeleteRelatedPartner() {
context.define("superuser-alex@hostsharing.net");
final var givenPartner = givenSomeTemporaryPartnerBessler(20014);
@ -506,7 +497,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
}
@Test
@Accepts({ "Partner:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedPartner() {
context.define("superuser-alex@hostsharing.net");
final var givenPartner = givenSomeTemporaryPartnerBessler(20015);

View File

@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

View File

@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

View File

@ -6,11 +6,11 @@ import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@ -30,8 +30,8 @@ import java.util.Objects;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectEntity.objectDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.Array.from;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.Array.from;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -4,9 +4,8 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Nested;
@ -20,8 +19,8 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*;
@ -50,7 +49,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
EntityManager em;
@Nested
@Accepts({ "Person:F(Find)" })
class ListPersons {
@Test
@ -71,7 +69,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Nested
@Accepts({ "Person:C(Create)" })
class AddPerson {
@Test
@ -109,7 +106,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Nested
@Accepts({ "Person:R(Read)" })
@Transactional
class GetPerson {
@ -135,7 +131,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Test
@Accepts({ "Person:X(Access Control)" })
void normalUser_canNotGetUnrelatedPerson() {
final var givenPersonUuid = jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net");
@ -153,7 +148,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Test
@Accepts({ "Person:X(Access Control)" })
void personOwnerUser_canGetRelatedPerson() {
final var givenPersonUuid = jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net");
@ -181,7 +175,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Nested
@Accepts({ "Person:U(Update)" })
@Transactional
class PatchPerson {
@ -269,7 +262,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Nested
@Accepts({ "Person:D(Delete)" })
@Transactional
class DeletePerson {
@ -293,7 +285,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Test
@Accepts({ "Person:X(Access Control)" })
void personOwner_canDeleteRelatedPerson() {
final var givenPerson = givenSomeTemporaryPersonCreatedBy("selfregistered-test-user@hostsharing.org");
@ -311,7 +302,6 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
}
@Test
@Accepts({ "Person:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedPerson() {
final var givenPerson = givenSomeTemporaryPersonCreatedBy("selfregistered-test-user@hostsharing.org");

View File

@ -1,6 +1,6 @@
package net.hostsharing.hsadminng.hs.office.person;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePersonPatchResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePersonTypeResource;
import org.junit.jupiter.api.TestInstance;

View File

@ -1,11 +1,11 @@
package net.hostsharing.hsadminng.hs.office.person;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@ -24,7 +24,7 @@ import java.util.function.Supplier;
import static net.hostsharing.hsadminng.hs.office.person.TestHsOfficePerson.hsOfficePerson;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -2,14 +2,13 @@ package net.hostsharing.hsadminng.hs.office.relation;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationTypeResource;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.json.JSONException;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@ -20,8 +19,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
@ -56,7 +55,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
JpaAttempt jpaAttempt;
@Nested
@Accepts({ "Relation:F(Find)" })
class ListRelations {
@Test
@ -119,7 +117,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Nested
@Accepts({ "Relation:C(Create)" })
class AddRelation {
@Test
@ -269,7 +266,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Nested
@Accepts({ "Relation:R(Read)" })
class GetRelation {
@Test
@ -296,7 +292,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Test
@Accepts({ "Relation:X(Access Control)" })
void normalUser_canNotGetUnrelatedRelation() {
context.define("superuser-alex@hostsharing.net");
final UUID givenRelationUuid = findRelation("First", "Firby").getUuid();
@ -312,7 +307,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Test
@Accepts({ "Relation:X(Access Control)" })
void contactAdminUser_canGetRelatedRelation() {
context.define("superuser-alex@hostsharing.net");
final var givenRelation = findRelation("First", "Firby");
@ -351,7 +345,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Nested
@Accepts({ "Relation:U(Update)" })
class PatchRelation {
@Test
@ -398,7 +391,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Nested
@Accepts({ "Relation:D(Delete)" })
class DeleteRelation {
@Test
@ -420,7 +412,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Test
@Accepts({ "Relation:X(Access Control)" })
void contactAdminUser_canNotDeleteRelatedRelation() {
context.define("superuser-alex@hostsharing.net");
final var givenRelation = givenSomeTemporaryRelationBessler();
@ -440,7 +431,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
}
@Test
@Accepts({ "Relation:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedRelation() {
context.define("superuser-alex@hostsharing.net");
final var givenRelation = givenSomeTemporaryRelationBessler();

View File

@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.relation;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationPatchResource;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

View File

@ -3,11 +3,11 @@ package net.hostsharing.hsadminng.hs.office.relation;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,7 +26,7 @@ import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.NATU
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.UNINCORPORATED_FIRM;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -6,9 +6,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.json.JSONException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -25,8 +24,8 @@ import java.time.LocalDate;
import java.util.UUID;
import static java.util.Optional.ofNullable;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*;
@ -56,7 +55,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
EntityManager em;
@Nested
@Accepts({ "SepaMandate:F(Find)" })
class ListSepaMandates {
@Test
@ -102,7 +100,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Nested
@Accepts({ "SepaMandate:C(Create)" })
class AddSepaMandate {
@Test
@ -234,7 +231,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Nested
@Accepts({ "SepaMandate:R(Read)" })
class GetSepaMandate {
@Test
@ -268,7 +264,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Test
@Accepts({ "SepaMandate:X(Access Control)" })
void normalUser_canNotGetUnrelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net");
final var givenSepaMandateUuid = sepaMandateRepo.findSepaMandateByOptionalIban("DE02120300000000202051")
@ -286,7 +281,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Test
@Accepts({ "SepaMandate:X(Access Control)" })
void bankAccountAdminUser_canGetRelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net");
final var givenSepaMandateUuid = sepaMandateRepo.findSepaMandateByOptionalIban("DE02120300000000202051")
@ -318,7 +312,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Nested
@Accepts({ "SepaMandate:U(Update)" })
class PatchSepaMandate {
@Test
@ -439,7 +432,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Nested
@Accepts({ "SepaMandate:D(Delete)" })
class DeleteSepaMandate {
@Test
@ -461,7 +453,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Test
@Accepts({ "SepaMandate:X(Access Control)" })
void bankAccountAdminUser_canNotDeleteRelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net");
final var givenSepaMandate = givenSomeTemporarySepaMandateForDebitorNumber(1000111);
@ -480,7 +471,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
}
@Test
@Accepts({ "SepaMandate:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net");
final var givenSepaMandate = givenSomeTemporarySepaMandateForDebitorNumber(1000111);

View File

@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.sepamandate;
import io.hypersistence.utils.hibernate.type.range.Range;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeSepaMandatePatchResource;
import net.hostsharing.test.PatchUnitTestBase;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

View File

@ -4,11 +4,11 @@ import io.hypersistence.utils.hibernate.type.range.Range;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,8 +26,8 @@ import java.util.List;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.Array.fromFormatted;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.Array.fromFormatted;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.context;
package net.hostsharing.hsadminng.rbac.context;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;

View File

@ -1,7 +1,9 @@
package net.hostsharing.hsadminng.context;
package net.hostsharing.hsadminng.rbac.context;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.mapper.Mapper;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
@ -15,7 +17,7 @@ import jakarta.servlet.http.HttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest
@ComponentScan(basePackageClasses = { Context.class, JpaAttempt.class })
@ComponentScan(basePackageClasses = { Context.class, JpaAttempt.class, Mapper.class })
@DirtiesContext
class ContextIntegrationTests {
@ -23,6 +25,7 @@ class ContextIntegrationTests {
private Context context;
@MockBean
@SuppressWarnings("unused") // the bean must be present, even though it's not used directly
private HttpServletRequest request;
@Autowired

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.context;
package net.hostsharing.hsadminng.rbac.context;
import net.hostsharing.hsadminng.context.Context;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.context;
package net.hostsharing.hsadminng.rbac.context;
import net.hostsharing.hsadminng.context.HttpServletRequestBodyCache;
import org.junit.jupiter.api.Test;
import java.io.IOException;

View File

@ -4,13 +4,12 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.ValidatableResponse;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleEntity;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository;
import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserEntity;
import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserRepository;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@ -34,7 +33,6 @@ import static org.hamcrest.Matchers.*;
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = { HsadminNgApplication.class, JpaAttempt.class }
)
@Accepts({ "GRT:S(Schema)" })
@Transactional(readOnly = true, propagation = Propagation.NEVER)
class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
@ -60,7 +58,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
class ListGrants {
@Test
@Accepts("GRT:L(List)")
void globalAdmin_withoutAssumedRole_canViewAllGrants() {
RestAssured // @formatter:off
.given()
@ -113,7 +110,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:L(List)", "GRT:X(Access Control)" })
void globalAdmin_withAssumedPackageAdminRole_canViewPacketRelatedGrants() {
RestAssured // @formatter:off
.given()
@ -137,7 +133,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:L(List)", "GRT:X(Access Control)" })
void packageAdmin_withoutAssumedRole_canViewPacketRelatedGrants() {
RestAssured // @formatter:off
.given()
@ -166,7 +161,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
class GetGrantById {
@Test
@Accepts({ "GRT:R(Read)" })
void customerAdmin_withAssumedPacketAdminRole_canReadPacketAdminsGrantById() {
// given
final var givenCurrentUserAsPackageAdmin = new Subject("customer-admin@xxx.example.com");
@ -186,7 +180,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:R(Read)" })
void packageAdmin_withoutAssumedRole_canReadItsOwnGrantById() {
// given
final var givenCurrentUserAsPackageAdmin = new Subject("pac-admin-xxx00@xxx.example.com");
@ -206,7 +199,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:R(Read)", "GRT:X(Access Control)" })
void packageAdmin_withAssumedPackageAdmin_canStillReadItsOwnGrantById() {
// given
final var givenCurrentUserAsPackageAdmin = new Subject(
@ -228,7 +220,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:R(Read)", "GRT:X(Access Control)" })
void packageAdmin_withAssumedPackageTenantRole_canNotReadItsOwnGrantByIdAnymore() {
// given
@ -250,7 +241,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
class GrantRoleToUser {
@Test
@Accepts({ "GRT:C(Create)" })
void packageAdmin_canGrantOwnPackageAdminRole_toArbitraryUser() {
// given
@ -280,7 +270,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:C(Create)", "GRT:X(Access Control)" })
void packageAdmin_canNotGrantAlienPackageAdminRole_toArbitraryUser() {
// given
@ -309,7 +298,6 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
class RevokeRoleFromUser {
@Test
@Accepts({ "GRT:D(Delete)" })
@Transactional(propagation = Propagation.NEVER)
void packageAdmin_canRevokePackageAdminRole_grantedByPackageAdmin_fromArbitraryUser() {

View File

@ -1,12 +1,11 @@
package net.hostsharing.hsadminng.rbac.rbacgrant;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository;
import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserEntity;
import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserRepository;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,7 +22,7 @@ import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.UUID;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest
@ -58,7 +57,6 @@ class RbacGrantRepositoryIntegrationTest extends ContextBasedTest {
class FindAllGrantsOfUser {
@Test
@Accepts({ "GRT:L(List)" })
public void packageAdmin_canViewItsRbacGrants() {
// given
context("pac-admin-xxx00@xxx.example.com", null);
@ -73,7 +71,6 @@ class RbacGrantRepositoryIntegrationTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:L(List)" })
public void customerAdmin_canViewItsRbacGrants() {
// given
context("customer-admin@xxx.example.com", null);
@ -91,7 +88,6 @@ class RbacGrantRepositoryIntegrationTest extends ContextBasedTest {
}
@Test
@Accepts({ "GRT:L(List)" })
public void customerAdmin_withAssumedRole_canOnlyViewRbacGrantsVisibleByAssumedRole() {
// given:
context("customer-admin@xxx.example.com", "test_package#xxx00:ADMIN");

View File

@ -1,9 +1,9 @@
package net.hostsharing.hsadminng.rbac.rbacgrant;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService.Include;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

View File

@ -4,7 +4,6 @@ import io.restassured.RestAssured;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.rbac.rbacuser.RbacUserRepository;
import net.hostsharing.test.Accepts;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@ -16,7 +15,6 @@ import static org.hamcrest.Matchers.*;
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = HsadminNgApplication.class
)
@Accepts({ "ROL:*:S:Schema" })
class RbacRoleControllerAcceptanceTest {
@LocalServerPort
@ -32,7 +30,6 @@ class RbacRoleControllerAcceptanceTest {
RbacRoleRepository rbacRoleRepository;
@Test
@Accepts({ "ROL:L(List)" })
void globalAdmin_withoutAssumedRole_canViewAllRoles() {
// @formatter:off
@ -58,7 +55,6 @@ class RbacRoleControllerAcceptanceTest {
}
@Test
@Accepts({ "ROL:L(List)", "ROL:X(Access Control)" })
void globalAdmin_withAssumedPackageAdminRole_canViewPackageAdminRoles() {
// @formatter:off
@ -92,7 +88,6 @@ class RbacRoleControllerAcceptanceTest {
}
@Test
@Accepts({ "ROL:L(List)", "ROL:X(Access Control)" })
void packageAdmin_withoutAssumedRole_canViewPackageAdminRoles() {
// @formatter:off

View File

@ -1,8 +1,8 @@
package net.hostsharing.hsadminng.rbac.rbacrole;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -15,7 +15,7 @@ import jakarta.persistence.EntityManager;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -4,8 +4,7 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.test.Accepts;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -41,7 +40,6 @@ class RbacUserControllerAcceptanceTest {
class CreateRbacUser {
@Test
@Accepts({ "USR:C(Create)", "USR:X(Access Control)" })
void anybody_canCreateANewUser() {
// @formatter:off
@ -77,7 +75,6 @@ class RbacUserControllerAcceptanceTest {
class GetRbacUser {
@Test
@Accepts({ "USR:R(Read)" })
void globalAdmin_withoutAssumedRole_canGetArbitraryUser() {
final var givenUser = findRbacUserByName("pac-admin-xxx00@xxx.example.com");
@ -96,7 +93,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:R(Read)", "USR:X(Access Control)" })
void globalAdmin_withAssumedCustomerAdminRole_canGetUserWithinInItsRealm() {
final var givenUser = findRbacUserByName("pac-admin-yyy00@yyy.example.com");
@ -116,7 +112,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:R(Read)", "USR:X(Access Control)" })
void customerAdmin_withoutAssumedRole_canGetUserWithinInItsRealm() {
final var givenUser = findRbacUserByName("pac-admin-yyy00@yyy.example.com");
@ -135,7 +130,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:R(Read)", "USR:X(Access Control)" })
void customerAdmin_withoutAssumedRole_canNotGetUserOutsideOfItsRealm() {
final var givenUser = findRbacUserByName("pac-admin-yyy00@yyy.example.com");
@ -156,7 +150,6 @@ class RbacUserControllerAcceptanceTest {
class ListRbacUsers {
@Test
@Accepts({ "USR:L(List)" })
void globalAdmin_withoutAssumedRole_canViewAllUsers() {
// @formatter:off
@ -182,7 +175,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:F(Filter)" })
void globalAdmin_withoutAssumedRole_canViewAllUsersByName() {
// @formatter:off
@ -203,7 +195,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:L(List)", "USR:X(Access Control)" })
void globalAdmin_withAssumedCustomerAdminRole_canViewUsersInItsRealm() {
// @formatter:off
@ -226,7 +217,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:L(List)", "USR:X(Access Control)" })
void customerAdmin_withoutAssumedRole_canViewUsersInItsRealm() {
// @formatter:off
@ -248,7 +238,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:L(List)", "USR:X(Access Control)" })
void packetAdmin_withoutAssumedRole_canViewAllUsersOfItsPackage() {
// @formatter:off
@ -271,7 +260,6 @@ class RbacUserControllerAcceptanceTest {
class ListRbacUserPermissions {
@Test
@Accepts({ "PRM:L(List)" })
void globalAdmin_withoutAssumedRole_canViewArbitraryUsersPermissions() {
final var givenUser = findRbacUserByName("pac-admin-yyy00@yyy.example.com");
@ -301,7 +289,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "PRM:L(List)" })
void globalAdmin_withAssumedCustomerAdminRole_canViewArbitraryUsersPermissions() {
final var givenUser = findRbacUserByName("pac-admin-yyy00@yyy.example.com");
@ -332,7 +319,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "PRM:L(List)" })
void packageAdmin_withoutAssumedRole_canViewPermissionsOfUsersInItsRealm() {
final var givenUser = findRbacUserByName("pac-admin-yyy00@yyy.example.com");
@ -362,7 +348,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "PRM:L(List)" })
void packageAdmin_canViewPermissionsOfUsersOutsideOfItsRealm() {
final var givenUser = findRbacUserByName("pac-admin-xxx00@xxx.example.com");
@ -385,7 +370,6 @@ class RbacUserControllerAcceptanceTest {
class DeleteRbacUser {
@Test
@Accepts({ "USR:D(Create)" })
void anybody_canDeleteTheirOwnUser() {
// given
@ -407,7 +391,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:D(Create)", "USR:X(Access Control)" })
void customerAdmin_canNotDeleteOtherUser() {
// given
@ -430,7 +413,6 @@ class RbacUserControllerAcceptanceTest {
}
@Test
@Accepts({ "USR:D(Create)", "USR:X(Access Control)" })
void globalAdmin_canDeleteArbitraryUser() {
// given

View File

@ -21,7 +21,7 @@ import jakarta.persistence.SynchronizationType;
import java.util.Map;
import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;

View File

@ -1,9 +1,9 @@
package net.hostsharing.hsadminng.rbac.rbacuser;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,7 +21,7 @@ import java.util.List;
import java.util.UUID;
import static java.util.Comparator.comparing;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import java.util.ArrayList;
import java.util.Arrays;

View File

@ -1,13 +1,12 @@
package net.hostsharing.hsadminng.hs.office.test;
package net.hostsharing.hsadminng.rbac.test;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantEntity;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleEntity;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository;
import net.hostsharing.test.JpaAttempt;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -25,7 +24,7 @@ import static java.util.stream.Collectors.toSet;
import static org.apache.commons.collections4.SetUtils.difference;
import static org.assertj.core.api.Assertions.assertThat;
// TODO: cleanup the whole class
// TODO.impl: cleanup the whole class
public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
private static final boolean DETAILED_BUT_SLOW_CHECK = true;
@ -64,9 +63,8 @@ public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
return merged;
}
// TODO.test: back to `Class<? extends RbacObject> entityClass` but delete on raw table
// remove HsOfficeCoopAssetsTransactionRawEntity, which is not needed anymore after this change
public UUID toCleanup(final Class entityClass, final UUID uuidToCleanup) {
public UUID toCleanup(final Class<? extends RbacObject> entityClass, final UUID uuidToCleanup) {
out.println("toCleanup(" + entityClass.getSimpleName() + ", " + uuidToCleanup + ")");
entitiesToCleanup.put(uuidToCleanup, entityClass);
return uuidToCleanup;
@ -178,16 +176,19 @@ public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
}
private void cleanupTemporaryTestData() {
entitiesToCleanup.forEach((uuid, entityClass) -> {
final var caughtException = jpaAttempt.transacted(() -> {
jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null);
em.remove(em.getReference(entityClass, uuid));
out.println("DELETING temporary " + entityClass.getSimpleName() + "#" + uuid + " generated");
}).caughtException();
if (caughtException != null) {
out.println("DELETING temporary " + entityClass.getSimpleName() + "#" + uuid + " failed: " + caughtException);
entitiesToCleanup.reversed().forEach((uuid, entityClass) -> {
final var rvTableName = entityClass.getAnnotation(Table.class).name();
if ( !rvTableName.endsWith("_rv") ) {
throw new IllegalStateException();
}
final var rawTableName = rvTableName.substring(0, rvTableName.length() - "_rv".length());
final var deletedRows = em.createNativeQuery("DELETE FROM " + rawTableName + " WHERE uuid=:uuid")
.setParameter("uuid", uuid).executeUpdate();
out.println("DELETING temporary " + entityClass.getSimpleName() + "#" + uuid + " deleted " + deletedRows + " rows");
});
}).assertSuccessful();
}
private long assertNoNewRbacObjectsRolesAndGrantsLeaked() {

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.hs.office.test;
package net.hostsharing.hsadminng.rbac.test;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import org.assertj.core.api.ObjectAssert;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import org.json.JSONException;
import org.json.JSONObject;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import org.junit.jupiter.api.Test;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import lombok.*;
import net.hostsharing.hsadminng.errors.DisplayName;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
import org.junit.jupiter.api.Test;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.mapper.EntityPatcher;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import lombok.experimental.UtilityClass;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test;
package net.hostsharing.hsadminng.rbac.test;
import lombok.*;
import lombok.experimental.FieldNameConstants;

View File

@ -1,5 +1,4 @@
package net.hostsharing.hsadminng.test.cust;
package net.hostsharing.hsadminng.rbac.test.cust;
public class TestCustomer {

View File

@ -1,10 +1,10 @@
package net.hostsharing.hsadminng.test.cust;
package net.hostsharing.hsadminng.rbac.test.cust;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.cust;
package net.hostsharing.hsadminng.rbac.test.cust;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test;

View File

@ -1,8 +1,8 @@
package net.hostsharing.hsadminng.test.cust;
package net.hostsharing.hsadminng.rbac.test.cust;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -15,7 +15,7 @@ import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.UUID;
import static net.hostsharing.test.JpaAttempt.attempt;
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest

View File

@ -1,7 +1,7 @@
package net.hostsharing.hsadminng.test.pac;
package net.hostsharing.hsadminng.rbac.test.pac;
import net.hostsharing.hsadminng.test.cust.TestCustomer;
import net.hostsharing.hsadminng.test.cust.TestCustomerEntity;
import net.hostsharing.hsadminng.rbac.test.cust.TestCustomer;
import net.hostsharing.hsadminng.rbac.test.cust.TestCustomerEntity;
import static java.util.UUID.randomUUID;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.pac;
package net.hostsharing.hsadminng.rbac.test.pac;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;

View File

@ -1,4 +1,4 @@
package net.hostsharing.hsadminng.test.pac;
package net.hostsharing.hsadminng.rbac.test.pac;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test;

View File

@ -1,8 +1,8 @@
package net.hostsharing.hsadminng.test.pac;
package net.hostsharing.hsadminng.rbac.test.pac;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.test.JpaAttempt;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,13 +0,0 @@
package net.hostsharing.test;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface Accepts {
String[] value();
}