From 18ce4fd8e919b20cfd0dc00f59561b89ce592de0 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 6 Mar 2024 16:04:34 +0100 Subject: [PATCH] WIP --- .../resources/db/changelog/050-rbac-base.sql | 7 +++++++ .../test/cust/TestCustomerEntityTest.java | 12 ++++++------ .../TestCustomerRepositoryIntegrationTest.java | 1 - .../test/pac/TestPackageEntityTest.java | 16 ++++++++-------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/resources/db/changelog/050-rbac-base.sql b/src/main/resources/db/changelog/050-rbac-base.sql index 9a8926c6..2eeff958 100644 --- a/src/main/resources/db/changelog/050-rbac-base.sql +++ b/src/main/resources/db/changelog/050-rbac-base.sql @@ -609,6 +609,13 @@ begin end; $$; +create or replace procedure grantPermissionToRole(roleDesc RbacRoleDescriptor, permissionUuid uuid) + language plpgsql as $$ +begin + call grantPermissionToRole(findRoleId(roleDesc), permissionUuid); +end; +$$; + -- TODO: deprecated, remove and use grantPermissionToRole(...) create or replace procedure grantPermissionsToRole(roleUuid uuid, permissionIds uuid[]) language plpgsql as $$ diff --git a/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntityTest.java b/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntityTest.java index abec1250..4ff123d5 100644 --- a/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntityTest.java +++ b/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerEntityTest.java @@ -29,9 +29,9 @@ class TestCustomerEntityTest { subgraph customer:permissions[ ] style customer:permissions fill:#dd4901,stroke:white - perm:customer:delete{{customer:delete}} - perm:customer:update{{customer:update}} - perm:customer:select{{customer:select}} + perm:customer:DELETE{{customer:DELETE}} + perm:customer:UPDATE{{customer:UPDATE}} + perm:customer:SELECT{{customer:SELECT}} end end @@ -44,9 +44,9 @@ class TestCustomerEntityTest { role:customer:admin ==> role:customer:tenant %% granting permissions to roles - role:customer:owner ==> perm:customer:delete - role:customer:admin ==> perm:customer:add-package - role:customer:tenant ==> perm:customer:select + role:customer:owner ==> perm:customer:DELETE + role:customer:admin ==> perm:customer:UPDATE + role:customer:tenant ==> perm:customer:SELECT """); } } diff --git a/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerRepositoryIntegrationTest.java index ca535142..018adc72 100644 --- a/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/test/cust/TestCustomerRepositoryIntegrationTest.java @@ -43,7 +43,6 @@ class TestCustomerRepositoryIntegrationTest extends ContextBasedTest { final var count = testCustomerRepository.count(); // when - final var result = attempt(em, () -> { final var newCustomer = new TestCustomerEntity( UUID.randomUUID(), "www", 90001, "customer-admin@www.example.com"); diff --git a/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageEntityTest.java b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageEntityTest.java index 3cda6d74..534da710 100644 --- a/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageEntityTest.java +++ b/src/test/java/net/hostsharing/hsadminng/test/pac/TestPackageEntityTest.java @@ -29,10 +29,10 @@ class TestPackageEntityTest { subgraph package:permissions[ ] style package:permissions fill:#dd4901,stroke:white - perm:package:insert{{package:insert}} - perm:package:delete{{package:delete}} - perm:package:update{{package:update}} - perm:package:select{{package:select}} + perm:package:INSERT{{package:INSERT}} + perm:package:DELETE{{package:DELETE}} + perm:package:UPDATE{{package:UPDATE}} + perm:package:SELECT{{package:SELECT}} end end @@ -62,10 +62,10 @@ class TestPackageEntityTest { role:package:tenant ==> role:customer:tenant %% granting permissions to roles - role:customer:admin ==> perm:package:insert - role:package:owner ==> perm:package:delete - role:package:owner ==> perm:package:update - role:package:tenant ==> perm:package:select + role:customer:admin ==> perm:package:INSERT + role:package:owner ==> perm:package:DELETE + role:package:owner ==> perm:package:UPDATE + role:package:tenant ==> perm:package:SELECT """); } }