Compare commits

..

No commits in common. "c67af5948b6bd4a8fc6d855dc57a20b92a086155" and "8b78265e512008b1ce0caf6360cc9ae51c4258dc" have entirely different histories.

10 changed files with 13 additions and 21 deletions

View File

@ -20,7 +20,6 @@ import net.hostsharing.hsadminng.test.dom.TestDomainEntity;
import net.hostsharing.hsadminng.test.pac.TestPackageEntity;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import jakarta.validation.constraints.NotNull;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -30,7 +29,6 @@ import java.util.function.Consumer;
import java.util.stream.Stream;
import static java.lang.reflect.Modifier.isStatic;
import static java.util.Arrays.stream;
import static java.util.Optional.ofNullable;
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.RbacUserReference.UserRole.CREATOR;
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL.autoFetched;
@ -78,7 +76,7 @@ public class RbacView {
public RbacView withUpdatableColumns(final String... columnNames) {
Collections.addAll(updatableColumns, columnNames);
verifyVersionColumnExists();
// TODO: automatically add @Version column, otherwise optimistic locking won't work
return this;
}
@ -216,14 +214,6 @@ public class RbacView {
return this;
}
private void verifyVersionColumnExists() {
if (stream(rootEntityAlias.entityClass.getDeclaredFields())
.noneMatch(f -> f.getAnnotation(Version.class) != null)) {
// TODO: convert this into throw Exception once RbacEntity is a base class with @Version field
System.err.println("@Version field required in updatable entity " + rootEntityAlias.entityClass);
}
}
public RbacGrantBuilder toRole(final String entityAlias, final Role role) {
return new RbacGrantBuilder(entityAlias, role);
}
@ -811,7 +801,7 @@ public class RbacView {
HsOfficeCoopSharesTransactionEntity.class,
HsOfficeMembershipEntity.class
).forEach(c -> {
final Method mainMethod = stream(c.getMethods()).filter(
final Method mainMethod = Arrays.stream(c.getMethods()).filter(
m -> isStatic(m.getModifiers()) && m.getName().equals("main")
)
.findFirst()

View File

@ -127,9 +127,9 @@ public class RbacGrantsDiagramService {
: "";
final var grants = graph.stream()
.map(g -> quoted(g.getAscendantIdName())
+ " -->" + (g.isAssumed() ? " " : "|XX| ")
+ quoted(g.getDescendantIdName()))
.map(g -> quoted(g.getAscendantIdName()) +
(g.isAssumed() ? " --> " : " -.-> ") +
quoted(g.getDescendantIdName()))
.sorted()
.collect(joining("\n"));

View File

@ -53,6 +53,7 @@ public class TestCustomerController implements TestCustomersApi {
context.define(currentUser, assumedRoles);
final var saved = testCustomerRepository.save(mapper.map(customer, TestCustomerEntity.class));
em.flush();
final var uri =
MvcUriComponentsBuilder.fromController(getClass())
.path("/api/test/customers/{id}")

View File

@ -41,7 +41,7 @@ public class TestCustomerEntity implements HasUuid {
.withIdentityView(SQL.projection("prefix"))
.withRestrictedViewOrderBy(SQL.expression("reference"))
.withUpdatableColumns("reference", "prefix", "adminUserName")
// TODO: do we want explicit specification of parent-independent insert permissions?
// TODO: do we want explicit specification of parent-indenpendent insert permissions?
// .toRole("global", ADMIN).grantPermission("customer", INSERT)
.createRole(OWNER, (with) -> {

View File

@ -1,4 +1,4 @@
### rbac customer 2024-03-11T09:06:04.484587070
### rbac customer 2024-03-10T11:42:41.089596517
```mermaid
%%{init:{'flowchart':{'htmlLabels':false}}}%%

View File

@ -1,5 +1,5 @@
--liquibase formatted sql
-- This code generated was by RbacViewPostgresGenerator at 2024-03-11T09:06:04.497071201.
-- This code generated was by RbacViewPostgresGenerator at 2024-03-10T11:42:41.121556631.
-- ============================================================================
--changeset test-customer-rbac-OBJECT:1 endDelimiter:--//

View File

@ -1,4 +1,4 @@
### rbac package 2024-03-11T09:06:04.536081351
### rbac package 2024-03-10T11:42:41.162678472
```mermaid
%%{init:{'flowchart':{'htmlLabels':false}}}%%

View File

@ -1,5 +1,5 @@
--liquibase formatted sql
-- This code generated was by RbacViewPostgresGenerator at 2024-03-11T09:06:04.536525766.
-- This code generated was by RbacViewPostgresGenerator at 2024-03-10T11:42:41.163393064.
-- ============================================================================
--changeset test-package-rbac-OBJECT:1 endDelimiter:--//

View File

@ -1,5 +1,5 @@
--liquibase formatted sql
-- This code generated was by RbacViewPostgresGenerator at 2024-03-11T09:06:04.558752062.
-- This code generated was by RbacViewPostgresGenerator at 2024-03-10T11:42:41.186902574.
-- ============================================================================
--changeset test-domain-rbac-OBJECT:1 endDelimiter:--//

View File

@ -473,6 +473,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
.contact(givenContact)
.build();
relationshipRepo.save(partnerRole);
em.flush(); // TODO: why is that necessary?
final var newPartner = HsOfficePartnerEntity.builder()
.partnerNumber(partnerNumber)