rbac-optimization #80
@ -13,7 +13,6 @@ 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.stringify.Stringify;
|
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||||
import net.hostsharing.hsadminng.stringify.Stringifyable;
|
import net.hostsharing.hsadminng.stringify.Stringifyable;
|
||||||
import org.hibernate.Hibernate;
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
|
@ -75,6 +75,13 @@ public class HsOfficePartnerEntity implements Stringifyable, RbacObject<HsOffice
|
|||||||
@NotFound(action = NotFoundAction.IGNORE)
|
@NotFound(action = NotFoundAction.IGNORE)
|
||||||
private HsOfficePartnerDetailsEntity details;
|
private HsOfficePartnerDetailsEntity details;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HsOfficePartnerEntity load() {
|
||||||
|
RbacObject.super.load();
|
||||||
|
partnerRel.load();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTaggedPartnerNumber() {
|
public String getTaggedPartnerNumber() {
|
||||||
return PARTNER_NUMBER_TAG + partnerNumber;
|
return PARTNER_NUMBER_TAG + partnerNumber;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class HsOfficeRelationEntity implements RbacObject, Stringifyable {
|
|||||||
private String mark;
|
private String mark;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RbacObject<?> load() {
|
public HsOfficeRelationEntity load() {
|
||||||
RbacObject.super.load();
|
RbacObject.super.load();
|
||||||
anchor.load();
|
anchor.load();
|
||||||
holder.load();
|
holder.load();
|
||||||
|
@ -372,6 +372,7 @@ create table RbacPermission
|
|||||||
op RbacOp not null,
|
op RbacOp not null,
|
||||||
opTableName varchar(60)
|
opTableName varchar(60)
|
||||||
);
|
);
|
||||||
|
-- TODO.perf: check if these indexes are really useful
|
||||||
create index on RbacPermission (objectUuid, op);
|
create index on RbacPermission (objectUuid, op);
|
||||||
create index on RbacPermission (opTableName, op);
|
create index on RbacPermission (opTableName, op);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
|
|||||||
|
|
||||||
private void assertThatBankAccountIsPersisted(final HsOfficeBankAccountEntity saved) {
|
private void assertThatBankAccountIsPersisted(final HsOfficeBankAccountEntity saved) {
|
||||||
final var found = bankAccountRepo.findByUuid(saved.getUuid());
|
final var found = bankAccountRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
private void assertThatContactIsPersisted(final HsOfficeContactEntity saved) {
|
private void assertThatContactIsPersisted(final HsOfficeContactEntity saved) {
|
||||||
final var found = contactRepo.findByUuid(saved.getUuid());
|
final var found = contactRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.vatReverseCharge(false)
|
.vatReverseCharge(false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return debitorRepo.save(newDebitor);
|
return debitorRepo.save(newDebitor).load();
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.debitor;
|
package net.hostsharing.hsadminng.hs.office.debitor;
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
|
@ -4,7 +4,6 @@ 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.rbac.rbacobject.RbacObject;
|
|
||||||
import net.hostsharing.hsadminng.rbac.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;
|
||||||
@ -144,7 +143,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
|||||||
|
|
||||||
private void assertThatMembershipIsPersisted(final HsOfficeMembershipEntity saved) {
|
private void assertThatMembershipIsPersisted(final HsOfficeMembershipEntity saved) {
|
||||||
final var found = membershipRepo.findByUuid(saved.getUuid());
|
final var found = membershipRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString()) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,12 +202,9 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
|||||||
@Test
|
@Test
|
||||||
public void globalAdmin_canUpdateValidityOfArbitraryMembership() {
|
public void globalAdmin_canUpdateValidityOfArbitraryMembership() {
|
||||||
// given
|
// given
|
||||||
final var givenMembership = jpaAttempt.transacted(() -> {
|
context("superuser-alex@hostsharing.net");
|
||||||
context("superuser-alex@hostsharing.net");
|
final var givenMembership = givenSomeTemporaryMembership("First", "11");
|
||||||
final var tempMembership = givenSomeTemporaryMembership("First", "11");
|
assertThatMembershipExistsAndIsAccessibleToCurrentContext(givenMembership);
|
||||||
assertThatMembershipExistsAndIsAccessibleToCurrentContext(tempMembership);
|
|
||||||
return tempMembership;
|
|
||||||
}).assertSuccessful().returnedValue();
|
|
||||||
final var newValidityEnd = LocalDate.now();
|
final var newValidityEnd = LocalDate.now();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -366,8 +362,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
|||||||
.membershipFeeBillable(true)
|
.membershipFeeBillable(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final HsOfficeMembershipEntity entity = membershipRepo.save(newMembership);
|
return toCleanup(membershipRepo.save(newMembership).load());
|
||||||
return toCleanup(entity.load());
|
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
private void assertThatPartnerIsPersisted(final HsOfficePartnerEntity saved) {
|
private void assertThatPartnerIsPersisted(final HsOfficePartnerEntity saved) {
|
||||||
final var found = partnerRepo.findByUuid(saved.getUuid());
|
final var found = partnerRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,10 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
.statusCode(204); // @formatter:on
|
.statusCode(204); // @formatter:on
|
||||||
|
|
||||||
// then the given person is still there
|
// then the given person is still there
|
||||||
assertThat(personRepo.findByUuid(givenPerson.getUuid())).isEmpty();
|
jpaAttempt.transacted(() -> {
|
||||||
|
context.define("superuser-alex@hostsharing.net");
|
||||||
|
assertThat(personRepo.findByUuid(givenPerson.getUuid())).isEmpty();
|
||||||
|
}).assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -124,7 +124,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
|||||||
|
|
||||||
private void assertThatPersonIsPersisted(final HsOfficePersonEntity saved) {
|
private void assertThatPersonIsPersisted(final HsOfficePersonEntity saved) {
|
||||||
final var found = personRepo.findByUuid(saved.getUuid());
|
final var found = personRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
|
|
||||||
private void assertThatRelationIsPersisted(final HsOfficeRelationEntity saved) {
|
private void assertThatRelationIsPersisted(final HsOfficeRelationEntity saved) {
|
||||||
final var found = relationRepo.findByUuid(saved.getUuid());
|
final var found = relationRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
givenRelation.setContact(givenContact);
|
givenRelation.setContact(givenContact);
|
||||||
return toCleanup(relationRepo.save(givenRelation));
|
return toCleanup(relationRepo.save(givenRelation).load());
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
@ -152,7 +152,7 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTestWithC
|
|||||||
|
|
||||||
private void assertThatSepaMandateIsPersisted(final HsOfficeSepaMandateEntity saved) {
|
private void assertThatSepaMandateIsPersisted(final HsOfficeSepaMandateEntity saved) {
|
||||||
final var found = sepaMandateRepo.findByUuid(saved.getUuid());
|
final var found = sepaMandateRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTestWithC
|
|||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isNotEmpty().get()
|
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isNotEmpty().get()
|
||||||
.usingRecursiveComparison().isEqualTo(givenSepaMandate);
|
.extracting(Object::toString).isEqualTo(givenSepaMandate.toString());
|
||||||
}).assertSuccessful();
|
}).assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class TestCustomerRepositoryIntegrationTest extends ContextBasedTest {
|
|||||||
|
|
||||||
private void assertThatCustomerIsPersisted(final TestCustomerEntity saved) {
|
private void assertThatCustomerIsPersisted(final TestCustomerEntity saved) {
|
||||||
final var found = testCustomerRepository.findByUuid(saved.getUuid());
|
final var found = testCustomerRepository.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ spring:
|
|||||||
change-log: classpath:/db/changelog/db.changelog-master.yaml
|
change-log: classpath:/db/changelog/db.changelog-master.yaml
|
||||||
contexts: tc,test,dev
|
contexts: tc,test,dev
|
||||||
|
|
||||||
|
# FIXME: re-activate?
|
||||||
#logging:
|
#logging:
|
||||||
# level:
|
# level:
|
||||||
# liquibase: INFO
|
# liquibase: INFO
|
||||||
|
Loading…
Reference in New Issue
Block a user