test-data-cleanup-via-raw-tables-and-fix-arc-tests #39

Merged
hsh-michaelhoennig merged 6 commits from test-data-cleanup-via-raw-tables-and-fix-arc-tests into master 2024-04-13 13:55:28 +02:00
78 changed files with 264 additions and 430 deletions

View File

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

View File

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

View File

@ -2,22 +2,11 @@ package net.hostsharing.hsadminng.rbac.rbacdef;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; 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.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.test.cust.TestCustomerEntity; import org.reflections.Reflections;
import net.hostsharing.hsadminng.test.dom.TestDomainEntity; import org.reflections.scanners.TypeAnnotationsScanner;
import net.hostsharing.hsadminng.test.pac.TestPackageEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.persistence.Version; import jakarta.persistence.Version;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@ -27,7 +16,6 @@ import java.nio.file.Path;
import java.util.*; import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.lang.reflect.Modifier.isStatic; import static java.lang.reflect.Modifier.isStatic;
import static java.util.Arrays.stream; 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. * This main method generates the RbacViews (PostgreSQL+diagram) for all given entity classes.
*/ */
public static void main(String[] args) { public static void main(String[] args) throws Exception {
Stream.of( findRbacEntityClasses("net.hostsharing.hsadminng")
TestCustomerEntity.class, .forEach(RbacView::generateRbacView);
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);
} }
} }

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.context.Context;
import net.hostsharing.hsadminng.mapper.Mapper; 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.AllArgsConstructor;
import lombok.Getter; 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.jpa.repository.Query;
import org.springframework.data.repository.Repository; 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.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@ -7,7 +7,7 @@ import lombok.Setter;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject; import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView; import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL; 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 jakarta.persistence.*;
import java.io.IOException; 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.Mapper;
import net.hostsharing.hsadminng.mapper.OptionalFromJson; 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.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@ -7,7 +7,7 @@ import lombok.Setter;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject; import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView; import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL; 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 jakarta.persistence.*;
import java.io.IOException; 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.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;

View File

@ -1,17 +1,24 @@
package net.hostsharing.hsadminng.arch; package net.hostsharing.hsadminng.arch;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.junit.AnalyzeClasses; import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchCondition;
import com.tngtech.archunit.lang.ArchRule; 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.hsadminng.HsadminNgApplication;
import net.hostsharing.test.Accepts; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import org.junit.jupiter.api.Test; import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.Repository;
import org.springframework.web.bind.annotation.RestController; 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.core.domain.JavaModifier.ABSTRACT;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices; import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
import static java.lang.String.format;
@AnalyzeClasses(packages = ArchitectureTest.NET_HOSTSHARING_HSADMINNG) @AnalyzeClasses(packages = ArchitectureTest.NET_HOSTSHARING_HSADMINNG)
public class ArchitectureTest { public class ArchitectureTest {
@ -232,20 +239,6 @@ public class ArchitectureTest {
.should().onlyBeAccessed().byClassesThat() .should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs.office.migration.."); .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 @ArchTest
@SuppressWarnings("unused") @SuppressWarnings("unused")
public static final ArchRule doNotUseJakartaTransactionAnnotationAtClassLevel = noClasses() public static final ArchRule doNotUseJakartaTransactionAnnotationAtClassLevel = noClasses()
@ -270,18 +263,51 @@ public class ArchitectureTest {
org.junit.jupiter.api.Test.class.getName(), org.junit.jupiter.api.Test.class.getName(),
org.junit.Test.class.getName())); org.junit.Test.class.getName()));
@Test @ArchTest
public void everythingShouldBeFreeOfCycles() { @SuppressWarnings("unused")
slices().matching("net.hostsharing.hsadminng.(*)..").should().beFreeOfCycles(); 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"); classes().that().areAnnotatedWith(RestController.class).should().haveSimpleNameEndingWith("Controller");
}
@Test @ArchTest
public void repositoryNaming() { @SuppressWarnings("unused")
classes().that().implement(JpaRepository.class).should().haveSimpleNameEndingWith("Repository"); 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 io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import net.hostsharing.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException; import org.json.JSONException;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
@ -19,8 +18,8 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith; import static org.hamcrest.Matchers.startsWith;
@ -48,7 +47,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
EntityManager em; EntityManager em;
@Nested @Nested
@Accepts({ "bankaccount:F(Find)" })
class ListBankAccounts { class ListBankAccounts {
@Test @Test
@ -113,7 +111,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
@Accepts({ "bankaccount:C(Create)" })
class CreateBankAccount { class CreateBankAccount {
@Test @Test
@ -153,7 +150,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
@Accepts({ "bankaccount:R(Read)" })
class GetBankAccount { class GetBankAccount {
@Test @Test
@ -178,7 +174,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
@Accepts({ "bankaccount:X(Access Control)" })
void normalUser_canNotGetUnrelatedBankAccount() { void normalUser_canNotGetUnrelatedBankAccount() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenBankAccountUuid = bankAccountRepo.findByOptionalHolderLike("first").get(0).getUuid(); final var givenBankAccountUuid = bankAccountRepo.findByOptionalHolderLike("first").get(0).getUuid();
@ -258,7 +253,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
@Accepts({ "bankaccount:D(Delete)" })
class DeleteBankAccount { class DeleteBankAccount {
@Test @Test
@ -280,7 +274,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
@Accepts({ "bankaccount:X(Access Control)" })
void bankaccountOwner_canDeleteRelatedBankAaccount() { void bankaccountOwner_canDeleteRelatedBankAaccount() {
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org"); final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");
@ -298,7 +291,6 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
@Accepts({ "bankaccount:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedBankAccount() { void normalUser_canNotDeleteUnrelatedBankAccount() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org"); final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");

View File

@ -1,11 +1,11 @@
package net.hostsharing.hsadminng.hs.office.bankaccount; package net.hostsharing.hsadminng.hs.office.bankaccount;
import net.hostsharing.hsadminng.context.Context; 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.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; 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.hs.office.bankaccount.TestHsOfficeBankAccount.hsOfficeBankAccount;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf; import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest

View File

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

View File

@ -1,6 +1,6 @@
package net.hostsharing.hsadminng.hs.office.contact; 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 net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeContactPatchResource;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;

View File

@ -1,11 +1,11 @@
package net.hostsharing.hsadminng.hs.office.contact; package net.hostsharing.hsadminng.hs.office.contact;
import net.hostsharing.hsadminng.context.Context; 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.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; 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.hs.office.contact.TestHsOfficeContact.hsOfficeContact;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf; import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest

View File

@ -5,9 +5,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository; 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.test.Accepts; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import net.hostsharing.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
@ -24,8 +23,8 @@ import java.time.LocalDate;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionType.DEPOSIT; import static net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionType.DEPOSIT;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.startsWith; import static org.hamcrest.Matchers.startsWith;
@ -56,7 +55,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
EntityManager em; EntityManager em;
@Nested @Nested
@Accepts({ "CoopAssetsTransaction:F(Find)" })
class ListCoopAssetsTransactions { class ListCoopAssetsTransactions {
@Test @Test
@ -168,7 +166,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
} }
@Nested @Nested
@Accepts({ "CoopAssetsTransaction:C(Create)" })
class AddCoopAssetsTransaction { class AddCoopAssetsTransaction {
@Test @Test
@ -232,7 +229,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
.reference("test ref") .reference("test ref")
.build()); .build());
}).assertSuccessful().assertNotNull().returnedValue(); }).assertSuccessful().assertNotNull().returnedValue();
toCleanup(HsOfficeCoopAssetsTransactionRawEntity.class, givenTransaction.getUuid()); toCleanup(HsOfficeCoopAssetsTransactionEntity.class, givenTransaction.getUuid());
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -281,7 +278,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
final var newAssetTxUuid = UUID.fromString( final var newAssetTxUuid = UUID.fromString(
location.substring(location.lastIndexOf('/') + 1)); location.substring(location.lastIndexOf('/') + 1));
assertThat(newAssetTxUuid).isNotNull(); assertThat(newAssetTxUuid).isNotNull();
toCleanup(HsOfficeCoopAssetsTransactionRawEntity.class, newAssetTxUuid); toCleanup(HsOfficeCoopAssetsTransactionEntity.class, newAssetTxUuid);
} }
@Test @Test
@ -321,7 +318,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
} }
@Nested @Nested
@Accepts({ "CoopAssetTransaction:R(Read)" })
class GetCoopAssetTransaction { class GetCoopAssetTransaction {
@Test @Test
@ -348,7 +344,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
} }
@Test @Test
@Accepts({ "CoopAssetTransaction:X(Access Control)" })
void normalUser_canNotGetUnrelatedCoopAssetTransaction() { void normalUser_canNotGetUnrelatedCoopAssetTransaction() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
@ -366,7 +361,6 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased
} }
@Test @Test
@Accepts({ "CoopAssetTransaction:X(Access Control)" })
void partnerPersonUser_canGetRelatedCoopAssetTransaction() { void partnerPersonUser_canGetRelatedCoopAssetTransaction() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenCoopAssetTransactionUuid = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( 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.context.Context;
import net.hostsharing.hsadminng.mapper.Mapper; 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.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.EnumSource;
import org.springframework.beans.factory.annotation.Autowired; 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.UUID;
import java.util.function.Function; 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.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 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.context.Context;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository; 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.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested; 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.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest

View File

@ -4,12 +4,9 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType; import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionEntity;
import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionRawEntity;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository; 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.test.Accepts; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import net.hostsharing.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
@ -22,13 +19,11 @@ import org.springframework.transaction.annotation.Transactional;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionType.DEPOSIT; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.startsWith; import static org.hamcrest.Matchers.startsWith;
@ -67,7 +62,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
} }
@Nested @Nested
@Accepts({"CoopSharesTransaction:F(Find)"})
class ListCoopSharesTransactions { class ListCoopSharesTransactions {
@Test @Test
@ -163,7 +157,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
} }
@Nested @Nested
@Accepts({"CoopSharesTransaction:C(Create)"})
class AddCoopSharesTransaction { class AddCoopSharesTransaction {
@Test @Test
@ -213,7 +206,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
.reference("test ref") .reference("test ref")
.build()); .build());
}).assertSuccessful().assertNotNull().returnedValue(); }).assertSuccessful().assertNotNull().returnedValue();
toCleanup(HsOfficeCoopSharesTransactionRawEntity.class, givenTransaction.getUuid()); toCleanup(HsOfficeCoopSharesTransactionEntity.class, givenTransaction.getUuid());
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -262,7 +255,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
final var newShareTxUuid = UUID.fromString( final var newShareTxUuid = UUID.fromString(
location.substring(location.lastIndexOf('/') + 1)); location.substring(location.lastIndexOf('/') + 1));
assertThat(newShareTxUuid).isNotNull(); assertThat(newShareTxUuid).isNotNull();
toCleanup(HsOfficeCoopSharesTransactionRawEntity.class, newShareTxUuid); toCleanup(HsOfficeCoopSharesTransactionEntity.class, newShareTxUuid);
} }
@Test @Test
@ -292,7 +285,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
} }
@Nested @Nested
@Accepts({"CoopShareTransaction:R(Read)"})
class GetCoopShareTransaction { class GetCoopShareTransaction {
@Test @Test
@ -309,7 +301,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
} }
@Test @Test
@Accepts({"CoopShareTransaction:X(Access Control)"})
void normalUser_canNotGetUnrelatedCoopShareTransaction() { void normalUser_canNotGetUnrelatedCoopShareTransaction() {
context.define("superuser-alex@hostsharing.net"); 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(); final var givenCoopShareTransactionUuid = coopSharesTransactionRepo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(null, LocalDate.of(2010, 3, 15), LocalDate.of(2010, 3, 15)).get(0).getUuid();
@ -319,7 +310,6 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
} }
@Test @Test
@Accepts({"CoopShareTransaction:X(Access Control)"})
void partnerPersonUser_canGetRelatedCoopShareTransaction() { void partnerPersonUser_canGetRelatedCoopShareTransaction() {
context.define("superuser-alex@hostsharing.net"); 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(); 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.context.Context;
import net.hostsharing.hsadminng.mapper.Mapper; 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.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.EnumSource;
import org.springframework.beans.factory.annotation.Autowired; 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.UUID;
import java.util.function.Function; 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.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

View File

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

View File

@ -2,11 +2,11 @@ package net.hostsharing.hsadminng.hs.office.coopshares;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository; 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.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested; 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.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @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.person.HsOfficePersonRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.test.Accepts; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import net.hostsharing.test.JpaAttempt;
import org.json.JSONException; import org.json.JSONException;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -28,8 +27,8 @@ import jakarta.persistence.PersistenceContext;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR; import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -74,7 +73,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
EntityManager em; EntityManager em;
@Nested @Nested
@Accepts({ "Debitor:F(Find)" })
class ListDebitors { class ListDebitors {
@Test @Test
@ -434,7 +432,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
@Accepts({ "Debitor:R(Read)" })
class GetDebitor { class GetDebitor {
@Test @Test
@ -499,7 +496,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Debitor:X(Access Control)" })
void normalUser_canNotGetUnrelatedDebitor() { void normalUser_canNotGetUnrelatedDebitor() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitorUuid = debitorRepo.findDebitorByOptionalNameLike("First").get(0).getUuid(); final var givenDebitorUuid = debitorRepo.findDebitorByOptionalNameLike("First").get(0).getUuid();
@ -515,7 +511,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Debitor:X(Access Control)" })
void contactAdminUser_canGetRelatedDebitorExceptRefundBankAccount() { void contactAdminUser_canGetRelatedDebitorExceptRefundBankAccount() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitorUuid = debitorRepo.findDebitorByOptionalNameLike("first contact").get(0).getUuid(); final var givenDebitorUuid = debitorRepo.findDebitorByOptionalNameLike("first contact").get(0).getUuid();
@ -541,7 +536,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
@Accepts({ "Debitor:U(Update)" })
class PatchDebitor { class PatchDebitor {
@Test @Test
@ -654,7 +648,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
@Accepts({ "Debitor:D(Delete)" })
class DeleteDebitor { class DeleteDebitor {
@Test @Test
@ -676,7 +669,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Debitor:X(Access Control)" })
void contactAdminUser_canNotDeleteRelatedDebitor() { void contactAdminUser_canNotDeleteRelatedDebitor() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor(); final var givenDebitor = givenSomeTemporaryDebitor();
@ -696,7 +688,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Debitor:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedDebitor() { void normalUser_canNotDeleteUnrelatedDebitor() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor(); 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.bankaccount.HsOfficeBankAccountEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity; 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.BeforeEach;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith; 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.person.HsOfficePersonRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; 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.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService; import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
@ -33,10 +33,10 @@ import jakarta.servlet.http.HttpServletRequest;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; 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.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest

View File

@ -6,9 +6,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; 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.test.Accepts; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import net.hostsharing.test.JpaAttempt;
import org.json.JSONException; import org.json.JSONException;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Nested; 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.ACTIVE;
import static net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipStatus.CANCELLED; import static net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipStatus.CANCELLED;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -61,7 +60,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
EntityManager em; EntityManager em;
@Nested @Nested
@Accepts({ "Membership:F(Find)" })
class ListMemberships { class ListMemberships {
@Test @Test
@ -168,7 +166,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Nested @Nested
@Accepts({ "Membership:C(Create)" })
class AddMembership { class AddMembership {
@Test @Test
@ -215,7 +212,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Nested @Nested
@Accepts({ "Membership:R(Read)" })
class GetMembership { class GetMembership {
@Test @Test
@ -245,7 +241,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Test @Test
@Accepts({ "Membership:X(Access Control)" })
void normalUser_canNotGetUnrelatedMembership() { void normalUser_canNotGetUnrelatedMembership() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000101).getUuid(); final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000101).getUuid();
@ -261,7 +256,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Test @Test
@Accepts({ "Membership:X(Access Control)" })
void parnerRelAgent_canGetRelatedMembership() { void parnerRelAgent_canGetRelatedMembership() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000303).getUuid(); final var givenMembershipUuid = membershipRepo.findMembershipByMemberNumber(1000303).getUuid();
@ -290,7 +284,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Nested @Nested
@Accepts({ "Membership:U(Update)" })
class PatchMembership { class PatchMembership {
@Test @Test
@ -371,7 +364,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Nested @Nested
@Accepts({ "Membership:D(Delete)" })
class DeleteMembership { class DeleteMembership {
@Test @Test
@ -393,7 +385,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Test @Test
@Accepts({ "Membership:X(Access Control)" })
void partnerAgentUser_canNotDeleteRelatedMembership() { void partnerAgentUser_canNotDeleteRelatedMembership() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMembership = givenSomeTemporaryMembershipBessler("First"); final var givenMembership = givenSomeTemporaryMembershipBessler("First");
@ -413,7 +404,6 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
} }
@Test @Test
@Accepts({ "Membership:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedMembership() { void normalUser_canNotDeleteUnrelatedMembership() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMembership = givenSomeTemporaryMembershipBessler("First"); 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.HsOfficeMembershipPatchResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipStatusResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipStatusResource;
import net.hostsharing.hsadminng.mapper.Mapper; 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.BeforeEach;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith; 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.context.Context;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository; import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; 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.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; 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.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest

View File

@ -4,7 +4,7 @@ import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader; import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder; import com.opencsv.CSVReaderBuilder;
import net.hostsharing.hsadminng.context.Context; 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.bankaccount.HsOfficeBankAccountEntity;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionEntity; 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.relation.HsOfficeRelationType;
import net.hostsharing.hsadminng.hs.office.sepamandate.HsOfficeSepaMandateEntity; import net.hostsharing.hsadminng.hs.office.sepamandate.HsOfficeSepaMandateEntity;
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject; 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.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
@ -360,10 +360,10 @@ public class ImportOfficeData extends ContextBasedTest {
assertThat(toFormattedString(coopShares)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(coopShares)).isEqualToIgnoringWhitespace("""
{ {
33443=CoopShareTransaction(M-1001700, 2000-12-06, SUBSCRIPTION, 20, legacy data import, initial share subscription), 33443=CoopShareTransaction(M-1001700: 2000-12-06, SUBSCRIPTION, 20, legacy data import, initial share subscription),
33451=CoopShareTransaction(M-1002000, 2000-12-06, SUBSCRIPTION, 2, legacy data import, initial share subscription), 33451=CoopShareTransaction(M-1002000: 2000-12-06, SUBSCRIPTION, 2, legacy data import, initial share subscription),
33701=CoopShareTransaction(M-1001700, 2005-01-10, SUBSCRIPTION, 40, legacy data import, increase), 33701=CoopShareTransaction(M-1001700: 2005-01-10, SUBSCRIPTION, 40, legacy data import, increase),
33810=CoopShareTransaction(M-1002000, 2016-12-31, CANCELLATION, 22, legacy data import, membership ended) 33810=CoopShareTransaction(M-1002000: 2016-12-31, CANCELLATION, 22, legacy data import, membership ended)
} }
"""); """);
} }
@ -433,7 +433,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test @Test
@Order(3001) @Order(3001)
void removeSelfRepresentativeRelations() { void removeSelfRepresentativeRelations() {
assumeThatWeAreImportingControlledTestData();
// this happens if a natural person is marked as 'contractual' for itself // this happens if a natural person is marked as 'contractual' for itself
final var idsToRemove = new HashSet<Integer>(); final var idsToRemove = new HashSet<Integer>();
@ -453,7 +452,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test @Test
@Order(3002) @Order(3002)
void removeEmptyRelations() { void removeEmptyRelations() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberately invalid partner entry #99 // avoid a error when persisting the deliberately invalid partner entry #99
final var idsToRemove = new HashSet<Integer>(); final var idsToRemove = new HashSet<Integer>();
@ -474,7 +472,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test @Test
@Order(3003) @Order(3003)
void removeEmptyPartners() { void removeEmptyPartners() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberately invalid partner entry #99 // avoid a error when persisting the deliberately invalid partner entry #99
final var idsToRemove = new HashSet<Integer>(); final var idsToRemove = new HashSet<Integer>();
@ -498,7 +495,6 @@ public class ImportOfficeData extends ContextBasedTest {
@Test @Test
@Order(3004) @Order(3004)
void removeEmptyDebitors() { void removeEmptyDebitors() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberately invalid partner entry #99 // avoid a error when persisting the deliberately invalid partner entry #99
final var idsToRemove = new HashSet<Integer>(); final var idsToRemove = new HashSet<Integer>();
@ -510,8 +506,10 @@ public class ImportOfficeData extends ContextBasedTest {
idsToRemove.add(id); idsToRemove.add(id);
} }
}); });
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
idsToRemove.forEach(id -> debitors.remove(id)); idsToRemove.forEach(id -> debitors.remove(id));
assumeThatWeAreImportingControlledTestData();
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
} }
@Test @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.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; 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.test.Accepts; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import net.hostsharing.test.JpaAttempt;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@ -22,8 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.EX_PARTNER; import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.EX_PARTNER;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -54,7 +53,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
JpaAttempt jpaAttempt; JpaAttempt jpaAttempt;
@Nested @Nested
@Accepts({ "Partner:F(Find)" })
@Transactional @Transactional
class ListPartners { class ListPartners {
@ -84,7 +82,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
@Accepts({ "Partner:C(Create)" })
@Transactional @Transactional
class AddPartner { class AddPartner {
@ -226,7 +223,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
@Accepts({ "Partner:R(Read)" })
@Transactional @Transactional
class GetPartner { class GetPartner {
@ -264,7 +260,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Partner:X(Access Control)" })
void normalUser_canNotGetUnrelatedPartner() { void normalUser_canNotGetUnrelatedPartner() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartnerUuid = partnerRepo.findPartnerByOptionalNameLike("First").get(0).getUuid(); final var givenPartnerUuid = partnerRepo.findPartnerByOptionalNameLike("First").get(0).getUuid();
@ -280,7 +275,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Partner:X(Access Control)" })
void contactAdminUser_canGetRelatedPartner() { void contactAdminUser_canGetRelatedPartner() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartnerUuid = partnerRepo.findPartnerByOptionalNameLike("first contact").get(0).getUuid(); final var givenPartnerUuid = partnerRepo.findPartnerByOptionalNameLike("first contact").get(0).getUuid();
@ -306,7 +300,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
@Accepts({ "Partner:U(Update)" })
@Transactional @Transactional
class PatchPartner { class PatchPartner {
@ -462,7 +455,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
@Accepts({ "Partner:D(Delete)" })
@Transactional @Transactional
class DeletePartner { class DeletePartner {
@ -486,7 +478,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Partner:X(Access Control)" })
void contactAdminUser_canNotDeleteRelatedPartner() { void contactAdminUser_canNotDeleteRelatedPartner() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = givenSomeTemporaryPartnerBessler(20014); final var givenPartner = givenSomeTemporaryPartnerBessler(20014);
@ -506,7 +497,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
@Accepts({ "Partner:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedPartner() { void normalUser_canNotDeleteUnrelatedPartner() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = givenSomeTemporaryPartnerBessler(20015); 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.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; 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.BeforeEach;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith; 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.generated.api.v1.model.HsOfficePartnerPatchResource;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity; 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.BeforeEach;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith; 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.HsOfficeRelationEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; 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.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; 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.AfterEach;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; 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.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectEntity.objectDisplaysOf; import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectEntity.objectDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.Array.from; import static net.hostsharing.hsadminng.rbac.test.Array.from;
import static net.hostsharing.test.JpaAttempt.attempt; import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest

View File

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

View File

@ -1,6 +1,6 @@
package net.hostsharing.hsadminng.hs.office.person; 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.HsOfficePersonPatchResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePersonTypeResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePersonTypeResource;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;

View File

@ -1,11 +1,11 @@
package net.hostsharing.hsadminng.hs.office.person; package net.hostsharing.hsadminng.hs.office.person;
import net.hostsharing.hsadminng.context.Context; 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.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; 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.hs.office.person.TestHsOfficePerson.hsOfficePerson;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf; import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest

View File

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

View File

@ -6,9 +6,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository; 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.test.Accepts; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import net.hostsharing.test.JpaAttempt;
import org.json.JSONException; import org.json.JSONException;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -25,8 +24,8 @@ import java.time.LocalDate;
import java.util.UUID; import java.util.UUID;
import static java.util.Optional.ofNullable; import static java.util.Optional.ofNullable;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -56,7 +55,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
EntityManager em; EntityManager em;
@Nested @Nested
@Accepts({ "SepaMandate:F(Find)" })
class ListSepaMandates { class ListSepaMandates {
@Test @Test
@ -102,7 +100,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
@Accepts({ "SepaMandate:C(Create)" })
class AddSepaMandate { class AddSepaMandate {
@Test @Test
@ -234,7 +231,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
@Accepts({ "SepaMandate:R(Read)" })
class GetSepaMandate { class GetSepaMandate {
@Test @Test
@ -268,7 +264,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
@Accepts({ "SepaMandate:X(Access Control)" })
void normalUser_canNotGetUnrelatedSepaMandate() { void normalUser_canNotGetUnrelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenSepaMandateUuid = sepaMandateRepo.findSepaMandateByOptionalIban("DE02120300000000202051") final var givenSepaMandateUuid = sepaMandateRepo.findSepaMandateByOptionalIban("DE02120300000000202051")
@ -286,7 +281,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
@Accepts({ "SepaMandate:X(Access Control)" })
void bankAccountAdminUser_canGetRelatedSepaMandate() { void bankAccountAdminUser_canGetRelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenSepaMandateUuid = sepaMandateRepo.findSepaMandateByOptionalIban("DE02120300000000202051") final var givenSepaMandateUuid = sepaMandateRepo.findSepaMandateByOptionalIban("DE02120300000000202051")
@ -318,7 +312,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
@Accepts({ "SepaMandate:U(Update)" })
class PatchSepaMandate { class PatchSepaMandate {
@Test @Test
@ -439,7 +432,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
@Accepts({ "SepaMandate:D(Delete)" })
class DeleteSepaMandate { class DeleteSepaMandate {
@Test @Test
@ -461,7 +453,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
@Accepts({ "SepaMandate:X(Access Control)" })
void bankAccountAdminUser_canNotDeleteRelatedSepaMandate() { void bankAccountAdminUser_canNotDeleteRelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenSepaMandate = givenSomeTemporarySepaMandateForDebitorNumber(1000111); final var givenSepaMandate = givenSomeTemporarySepaMandateForDebitorNumber(1000111);
@ -480,7 +471,6 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
@Accepts({ "SepaMandate:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedSepaMandate() { void normalUser_canNotDeleteUnrelatedSepaMandate() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenSepaMandate = givenSomeTemporarySepaMandateForDebitorNumber(1000111); 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 io.hypersistence.utils.hibernate.type.range.Range;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeSepaMandatePatchResource; 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.BeforeEach;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith; 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.context.Context;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository; 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.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array; import net.hostsharing.hsadminng.rbac.test.Array;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; 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.rbacgrant.RawRbacGrantEntity.distinctGrantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf; import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.distinctRoleNamesOf;
import static net.hostsharing.test.Array.fromFormatted; import static net.hostsharing.hsadminng.rbac.test.Array.fromFormatted;
import static net.hostsharing.test.JpaAttempt.attempt; import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @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 net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo; 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.hsadminng.context.Context;
import net.hostsharing.test.JpaAttempt; 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.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @DataJpaTest
@ComponentScan(basePackageClasses = { Context.class, JpaAttempt.class }) @ComponentScan(basePackageClasses = { Context.class, JpaAttempt.class, Mapper.class })
@DirtiesContext @DirtiesContext
class ContextIntegrationTests { class ContextIntegrationTests {
@ -23,6 +25,7 @@ class ContextIntegrationTests {
private Context context; private Context context;
@MockBean @MockBean
@SuppressWarnings("unused") // the bean must be present, even though it's not used directly
private HttpServletRequest request; private HttpServletRequest request;
@Autowired @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.BeforeEach;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; 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 org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ import jakarta.persistence.SynchronizationType;
import java.util.Map; import java.util.Map;
import java.util.UUID; 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.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.argThat;

View File

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

View File

@ -1,4 +1,4 @@
package net.hostsharing.test; package net.hostsharing.hsadminng.rbac.test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; 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.rbacobject.RbacObject;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantEntity; import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantEntity;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantRepository; import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService; import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleEntity; import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleEntity;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository; import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository;
import net.hostsharing.test.JpaAttempt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; 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.apache.commons.collections4.SetUtils.difference;
import static org.assertj.core.api.Assertions.assertThat; 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 { public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
private static final boolean DETAILED_BUT_SLOW_CHECK = true; private static final boolean DETAILED_BUT_SLOW_CHECK = true;
@ -64,9 +63,8 @@ public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
return merged; 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 // remove HsOfficeCoopAssetsTransactionRawEntity, which is not needed anymore after this change

Kommentar kann weg

Kommentar kann weg
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 + ")"); out.println("toCleanup(" + entityClass.getSimpleName() + ", " + uuidToCleanup + ")");
entitiesToCleanup.put(uuidToCleanup, entityClass); entitiesToCleanup.put(uuidToCleanup, entityClass);
return uuidToCleanup; return uuidToCleanup;
@ -178,16 +176,19 @@ public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
} }
private void cleanupTemporaryTestData() { private void cleanupTemporaryTestData() {
entitiesToCleanup.forEach((uuid, entityClass) -> { jpaAttempt.transacted(() -> {
final var caughtException = jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null); context.define("superuser-alex@hostsharing.net", null);
em.remove(em.getReference(entityClass, uuid)); entitiesToCleanup.reversed().forEach((uuid, entityClass) -> {
out.println("DELETING temporary " + entityClass.getSimpleName() + "#" + uuid + " generated"); final var rvTableName = entityClass.getAnnotation(Table.class).name();
}).caughtException(); if ( !rvTableName.endsWith("_rv") ) {
if (caughtException != null) { throw new IllegalStateException();
out.println("DELETING temporary " + entityClass.getSimpleName() + "#" + uuid + " failed: " + caughtException);
} }
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() { 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; 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.BaseMatcher;
import org.hamcrest.Description; 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.assertj.core.api.ObjectAssert;
import org.springframework.beans.factory.annotation.Autowired; 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.JSONException;
import org.json.JSONObject; 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.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; 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; 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 lombok.*;
import net.hostsharing.hsadminng.errors.DisplayName; 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 net.hostsharing.hsadminng.mapper.OptionalFromJson;
import org.junit.jupiter.api.Test; 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.rbac.rbacobject.RbacObject;
import net.hostsharing.hsadminng.mapper.EntityPatcher; 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; import lombok.experimental.UtilityClass;

View File

@ -1,4 +1,4 @@
package net.hostsharing.test; package net.hostsharing.hsadminng.rbac.test;
import lombok.*; import lombok.*;
import lombok.experimental.FieldNameConstants; 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 { 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.RestAssured;
import io.restassured.http.ContentType; import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context; 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.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested; 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 net.hostsharing.hsadminng.rbac.rbacdef.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test; 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.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -15,7 +15,7 @@ import jakarta.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.UUID; 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; import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest @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.rbac.test.cust.TestCustomer;
import net.hostsharing.hsadminng.test.cust.TestCustomerEntity; import net.hostsharing.hsadminng.rbac.test.cust.TestCustomerEntity;
import static java.util.UUID.randomUUID; 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.RestAssured;
import io.restassured.http.ContentType; 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 net.hostsharing.hsadminng.rbac.rbacdef.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test; 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.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; 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();
}