From 7decf28293cb948444cccda056beb21381270509 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 19 Sep 2024 13:24:08 +0200 Subject: [PATCH] rename customerOwner -> rbactest.customer_OWNER etc. -- generated --- ...sive-cte-experiments-for-accessible-uuids.sql | 2 +- .../relation/HsOfficeRelationRbacRepository.java | 2 +- .../relation/HsOfficeRelationRealRepository.java | 2 +- .../rbac/generator/InsertTriggerGenerator.java | 2 +- .../hsadminng/rbac/generator/RbacView.java | 5 +++++ .../RolesGrantsAndPermissionsGenerator.java | 16 +++++----------- .../db/changelog/1-rbac/1080-rbac-global.sql | 8 ++++---- .../2013-rbactest-customer-rbac.sql | 6 +++--- .../501-contact/5013-hs-office-contact-rbac.sql | 2 +- .../502-person/5020-hs-office-person.sql | 6 +++--- .../502-person/5023-hs-office-person-rbac.sql | 2 +- .../5028-hs-office-person-test-data.sql | 2 +- .../503-relation/5030-hs-office-relation.sql | 6 +++--- .../5033-hs-office-relation-rbac.sql | 2 +- .../5038-hs-office-relation-test-data.sql | 2 +- .../504-partner/5043-hs-office-partner-rbac.sql | 4 ++-- .../5044-hs-office-partner-details-rbac.sql | 4 ++-- .../5053-hs-office-bankaccount-rbac.sql | 2 +- .../506-debitor/5063-hs-office-debitor-rbac.sql | 4 ++-- .../5073-hs-office-sepamandate-rbac.sql | 2 +- .../5103-hs-office-membership-rbac.sql | 4 ++-- .../511-coopshares/5110-hs-office-coopshares.sql | 6 +++--- .../512-coopassets/5120-hs-office-coopassets.sql | 6 +++--- .../6203-hs-booking-project-rbac.sql | 2 +- .../630-booking-item/6300-hs-booking-item.sql | 6 +++--- .../6303-hs-booking-item-rbac.sql | 6 +++--- .../701-hosting-asset/7010-hs-hosting-asset.sql | 14 +++++++------- .../7013-hs-hosting-asset-rbac.sql | 2 +- .../hs/migration/ImportHostingAssets.java | 2 +- ...HsOfficeRelationControllerAcceptanceTest.java | 3 --- 30 files changed, 64 insertions(+), 68 deletions(-) diff --git a/sql/recursive-cte-experiments-for-accessible-uuids.sql b/sql/recursive-cte-experiments-for-accessible-uuids.sql index bb86d6ec..5988c6d6 100644 --- a/sql/recursive-cte-experiments-for-accessible-uuids.sql +++ b/sql/recursive-cte-experiments-for-accessible-uuids.sql @@ -151,7 +151,7 @@ end transaction; alter table rbacobject -- just for performance testing, we would need a joined enum or a varchar(16) which would make it slow - add column type hs_hosting.hshostingassettype; + add column type hs_hosting.AssetType; -- and fill the type column with hs_hosting.asset types: diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java index e12d0256..3c89a0b7 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java @@ -24,7 +24,7 @@ public interface HsOfficeRelationRbacRepository extends Repository findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java index 220ea6f4..9cf58b86 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java @@ -24,7 +24,7 @@ public interface HsOfficeRelationRealRepository extends Repository findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType); diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/InsertTriggerGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/InsertTriggerGenerator.java index 1654bbc7..8ab6a70d 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/InsertTriggerGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/InsertTriggerGenerator.java @@ -325,7 +325,7 @@ public class InsertTriggerGenerator { private String toRoleDescriptor(final RbacView.RbacRoleDefinition roleDef, final String ref) { - final var functionName = toVar(roleDef); + final var functionName = roleDef.descriptorFunctionName(); if (roleDef.getEntityAlias().isGlobal()) { return functionName + "()"; } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacView.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacView.java index 2c2d339a..c2bc687d 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacView.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacView.java @@ -29,6 +29,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinit import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.Part.AUTO_FETCH; import static org.apache.commons.collections4.SetUtils.hashSet; +import static org.apache.commons.lang3.StringUtils.capitalize; import static org.apache.commons.lang3.StringUtils.uncapitalize; @Getter @@ -830,6 +831,10 @@ public class RbacView { public boolean isGlobal(final Role role) { return entityAlias.isGlobal() && this.role == role; } + + public String descriptorFunctionName() { + return entityAlias.getRawTableNameWithSchema() + "_" + capitalize(role.name()); + } } public RbacSubjectReference findUserRef(final RbacSubjectReference.UserRole userRole) { diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java index 22a9b9d3..6d880144 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java @@ -20,7 +20,6 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinit import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; import static net.hostsharing.hsadminng.rbac.generator.StringWriter.with; import static org.apache.commons.lang3.StringUtils.capitalize; -import static org.apache.commons.lang3.StringUtils.uncapitalize; class RolesGrantsAndPermissionsGenerator { @@ -362,11 +361,10 @@ class RolesGrantsAndPermissionsGenerator { System.out.println("null"); } if (roleDef.getEntityAlias().isGlobal()) { - return "rbac.globalAdmin()"; + return "rbac.global_ADMIN()"; } final String entityRefVar = entityRefVar(rootRefVar, roleDef.getEntityAlias()); - return roleDef.getEntityAlias().simpleName() + capitalize(roleDef.getRole().name()) - + "(" + entityRefVar + ")"; + return roleDef.descriptorFunctionName() + "(" + entityRefVar + ")"; } private String entityRefVar( @@ -389,8 +387,8 @@ class RolesGrantsAndPermissionsGenerator { plPgSql.writeLn(); plPgSql.writeLn("perform rbac.defineRoleWithGrants("); plPgSql.indented(() -> { - plPgSql.writeLn("${simpleVarName)${roleSuffix}(NEW)," - .replace("${simpleVarName)", simpleEntityVarName) + plPgSql.writeLn("${qualifiedRawTableName)_${roleSuffix}(NEW)," + .replace("${qualifiedRawTableName)", qualifiedRawTableName) .replace("${roleSuffix}", capitalize(role.name()))); generatePermissionsForRole(plPgSql, role); @@ -593,16 +591,12 @@ class RolesGrantsAndPermissionsGenerator { final RbacView.RbacRoleDefinition roleDef, final boolean assumed) { final var assumedArg = assumed ? "" : ", rbac.unassumed()"; - return toRoleRef(roleDef) + + return roleDef.descriptorFunctionName() + (roleDef.getEntityAlias().isGlobal() ? ( assumed ? "()" : "(rbac.unassumed())") : rbacDef.isRootEntityAlias(roleDef.getEntityAlias()) ? ("(" + triggerRef.name() + ")") : "(" + toTriggerReference(triggerRef, roleDef.getEntityAlias()) + assumedArg + ")"); } - private static String toRoleRef(final RbacView.RbacRoleDefinition roleDef) { - return uncapitalize(roleDef.getEntityAlias().simpleName()) + capitalize(roleDef.getRole().name()); - } - private static String toTriggerReference( final PostgresTriggerReference triggerRef, final RbacView.EntityAlias entityAlias) { diff --git a/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql b/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql index cf62891f..a5514401 100644 --- a/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql +++ b/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql @@ -30,7 +30,7 @@ create or replace function rbac.isGlobalAdmin() returns boolean language plpgsql as $$ begin - return rbac.isGranted(rbac.currentSubjectOrAssumedRolesUuids(), rbac.findRoleId(rbac.globalAdmin())); + return rbac.isGranted(rbac.currentSubjectOrAssumedRolesUuids(), rbac.findRoleId(rbac.global_ADMIN())); end; $$; --// @@ -109,7 +109,7 @@ commit; /* A rbac.Global administrator role. */ -create or replace function rbac.globalAdmin(assumed boolean = true) +create or replace function rbac.global_ADMIN(assumed boolean = true) returns rbac.RoleDescriptor returns null on null input stable -- leakproof @@ -119,7 +119,7 @@ $$; begin transaction; call base.defineContext('creating role:rbac.global#global:ADMIN', null, null, null); - select rbac.createRole(rbac.globalAdmin()); + select rbac.createRole(rbac.global_ADMIN()); commit; --// @@ -157,7 +157,7 @@ do language plpgsql $$ begin call base.defineContext('creating fake test-realm admin users', null, null, null); - admins = rbac.findRoleId(rbac.globalAdmin()); + admins = rbac.findRoleId(rbac.global_ADMIN()); call rbac.grantRoleToSubjectUnchecked(admins, admins, rbac.create_subject('superuser-alex@hostsharing.net')); call rbac.grantRoleToSubjectUnchecked(admins, admins, rbac.create_subject('superuser-fran@hostsharing.net')); perform rbac.create_subject('selfregistered-user-drew@hostsharing.org'); diff --git a/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql b/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql index f46fdecf..69bc70b3 100644 --- a/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql +++ b/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql @@ -37,7 +37,7 @@ begin perform rbac.defineRoleWithGrants( rbactest.customer_OWNER(NEW), permissions => array['DELETE'], - incomingSuperRoles => array[rbac.globalADMIN(rbac.unassumed())], + incomingSuperRoles => array[rbac.global_ADMIN(rbac.unassumed())], subjectUuids => array[rbac.currentSubjectUuid()] ); @@ -96,7 +96,7 @@ do language plpgsql $$ LOOP call rbac.grantPermissionToRole( rbac.createPermission(row.uuid, 'INSERT', 'rbactest.customer'), - rbac.globalADMIN()); + rbac.global_ADMIN()); END LOOP; end; $$; @@ -112,7 +112,7 @@ begin -- unconditional for all rows in that table call rbac.grantPermissionToRole( rbac.createPermission(NEW.uuid, 'INSERT', 'rbactest.customer'), - rbac.globalADMIN()); + rbac.global_ADMIN()); -- end. return NEW; end; $$; diff --git a/src/main/resources/db/changelog/5-hs-office/501-contact/5013-hs-office-contact-rbac.sql b/src/main/resources/db/changelog/5-hs-office/501-contact/5013-hs-office-contact-rbac.sql index 12c2517e..08bdcfc3 100644 --- a/src/main/resources/db/changelog/5-hs-office/501-contact/5013-hs-office-contact-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/501-contact/5013-hs-office-contact-rbac.sql @@ -37,7 +37,7 @@ begin perform rbac.defineRoleWithGrants( hs_office.contact_OWNER(NEW), permissions => array['DELETE'], - incomingSuperRoles => array[rbac.globalADMIN()], + incomingSuperRoles => array[rbac.global_ADMIN()], subjectUuids => array[rbac.currentSubjectUuid()] ); diff --git a/src/main/resources/db/changelog/5-hs-office/502-person/5020-hs-office-person.sql b/src/main/resources/db/changelog/5-hs-office/502-person/5020-hs-office-person.sql index 81245561..a2e72952 100644 --- a/src/main/resources/db/changelog/5-hs-office/502-person/5020-hs-office-person.sql +++ b/src/main/resources/db/changelog/5-hs-office/502-person/5020-hs-office-person.sql @@ -4,7 +4,7 @@ --changeset michael.hoennig:hs-office-person-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -CREATE TYPE hs_office.HsOfficePersonType AS ENUM ( +CREATE TYPE hs_office.PersonType AS ENUM ( '??', -- unknown 'NP', -- natural person 'LP', -- legal person @@ -12,13 +12,13 @@ CREATE TYPE hs_office.HsOfficePersonType AS ENUM ( 'UF', -- unincorporated firm 'PI'); -- public institution -CREATE CAST (character varying as hs_office.HsOfficePersonType) WITH INOUT AS IMPLICIT; +CREATE CAST (character varying as hs_office.PersonType) WITH INOUT AS IMPLICIT; create table if not exists hs_office.person ( uuid uuid unique references rbac.object (uuid) initially deferred, version int not null default 0, - personType hs_office.HsOfficePersonType not null, + personType hs_office.PersonType not null, tradeName varchar(96), salutation varchar(30), title varchar(20), diff --git a/src/main/resources/db/changelog/5-hs-office/502-person/5023-hs-office-person-rbac.sql b/src/main/resources/db/changelog/5-hs-office/502-person/5023-hs-office-person-rbac.sql index 0a7fabb5..2f8df513 100644 --- a/src/main/resources/db/changelog/5-hs-office/502-person/5023-hs-office-person-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/502-person/5023-hs-office-person-rbac.sql @@ -37,7 +37,7 @@ begin perform rbac.defineRoleWithGrants( hs_office.person_OWNER(NEW), permissions => array['DELETE'], - incomingSuperRoles => array[rbac.globalADMIN()], + incomingSuperRoles => array[rbac.global_ADMIN()], subjectUuids => array[rbac.currentSubjectUuid()] ); diff --git a/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql b/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql index ae02d0d3..26aaae99 100644 --- a/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql @@ -9,7 +9,7 @@ Creates a single person test record. */ create or replace procedure createHsOfficePersonTestData( - newPersonType hs_office.HsOfficePersonType, + newPersonType hs_office.PersonType, newTradeName varchar, newFamilyName varchar = null, newGivenName varchar = null diff --git a/src/main/resources/db/changelog/5-hs-office/503-relation/5030-hs-office-relation.sql b/src/main/resources/db/changelog/5-hs-office/503-relation/5030-hs-office-relation.sql index 8c946f66..a1498fb3 100644 --- a/src/main/resources/db/changelog/5-hs-office/503-relation/5030-hs-office-relation.sql +++ b/src/main/resources/db/changelog/5-hs-office/503-relation/5030-hs-office-relation.sql @@ -4,7 +4,7 @@ --changeset michael.hoennig:hs-office-relation-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -CREATE TYPE hs_office.HsOfficeRelationType AS ENUM ( +CREATE TYPE hs_office.RelationType AS ENUM ( 'UNKNOWN', 'PARTNER', 'EX_PARTNER', @@ -14,7 +14,7 @@ CREATE TYPE hs_office.HsOfficeRelationType AS ENUM ( 'OPERATIONS', 'SUBSCRIBER'); -CREATE CAST (character varying as hs_office.HsOfficeRelationType) WITH INOUT AS IMPLICIT; +CREATE CAST (character varying as hs_office.RelationType) WITH INOUT AS IMPLICIT; create table if not exists hs_office.relation ( @@ -23,7 +23,7 @@ create table if not exists hs_office.relation anchorUuid uuid not null references hs_office.person(uuid), holderUuid uuid not null references hs_office.person(uuid), contactUuid uuid references hs_office.contact(uuid), - type hs_office.HsOfficeRelationType not null, + type hs_office.RelationType not null, mark varchar(24) ); --// diff --git a/src/main/resources/db/changelog/5-hs-office/503-relation/5033-hs-office-relation-rbac.sql b/src/main/resources/db/changelog/5-hs-office/503-relation/5033-hs-office-relation-rbac.sql index b390f638..d23d0d09 100644 --- a/src/main/resources/db/changelog/5-hs-office/503-relation/5033-hs-office-relation-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/503-relation/5033-hs-office-relation-rbac.sql @@ -50,7 +50,7 @@ begin perform rbac.defineRoleWithGrants( hs_office.relation_OWNER(NEW), permissions => array['DELETE'], - incomingSuperRoles => array[rbac.globalADMIN()], + incomingSuperRoles => array[rbac.global_ADMIN()], subjectUuids => array[rbac.currentSubjectUuid()] ); diff --git a/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql b/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql index 0de446e8..d3d97683 100644 --- a/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql @@ -10,7 +10,7 @@ */ create or replace procedure createHsOfficeRelationTestData( holderPersonName varchar, - relationType hs_office.HsOfficeRelationType, + relationType hs_office.RelationType, anchorPersonName varchar, contactCaption varchar, mark varchar default null) diff --git a/src/main/resources/db/changelog/5-hs-office/504-partner/5043-hs-office-partner-rbac.sql b/src/main/resources/db/changelog/5-hs-office/504-partner/5043-hs-office-partner-rbac.sql index c490423b..9186dd7d 100644 --- a/src/main/resources/db/changelog/5-hs-office/504-partner/5043-hs-office-partner-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/504-partner/5043-hs-office-partner-rbac.sql @@ -173,7 +173,7 @@ do language plpgsql $$ LOOP call rbac.grantPermissionToRole( rbac.createPermission(row.uuid, 'INSERT', 'hs_office.partner'), - rbac.globalADMIN()); + rbac.global_ADMIN()); END LOOP; end; $$; @@ -189,7 +189,7 @@ begin -- unconditional for all rows in that table call rbac.grantPermissionToRole( rbac.createPermission(NEW.uuid, 'INSERT', 'hs_office.partner'), - rbac.globalADMIN()); + rbac.global_ADMIN()); -- end. return NEW; end; $$; diff --git a/src/main/resources/db/changelog/5-hs-office/504-partner/5044-hs-office-partner-details-rbac.sql b/src/main/resources/db/changelog/5-hs-office/504-partner/5044-hs-office-partner-details-rbac.sql index 27b2f489..50c7dc92 100644 --- a/src/main/resources/db/changelog/5-hs-office/504-partner/5044-hs-office-partner-details-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/504-partner/5044-hs-office-partner-details-rbac.sql @@ -77,7 +77,7 @@ do language plpgsql $$ LOOP call rbac.grantPermissionToRole( rbac.createPermission(row.uuid, 'INSERT', 'hs_office.partner_details'), - rbac.globalADMIN()); + rbac.global_ADMIN()); END LOOP; end; $$; @@ -93,7 +93,7 @@ begin -- unconditional for all rows in that table call rbac.grantPermissionToRole( rbac.createPermission(NEW.uuid, 'INSERT', 'hs_office.partner_details'), - rbac.globalADMIN()); + rbac.global_ADMIN()); -- end. return NEW; end; $$; diff --git a/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5053-hs-office-bankaccount-rbac.sql b/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5053-hs-office-bankaccount-rbac.sql index 0726cc38..e283c13f 100644 --- a/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5053-hs-office-bankaccount-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5053-hs-office-bankaccount-rbac.sql @@ -37,7 +37,7 @@ begin perform rbac.defineRoleWithGrants( hs_office.bankaccount_OWNER(NEW), permissions => array['DELETE'], - incomingSuperRoles => array[rbac.globalADMIN()], + incomingSuperRoles => array[rbac.global_ADMIN()], subjectUuids => array[rbac.currentSubjectUuid()] ); diff --git a/src/main/resources/db/changelog/5-hs-office/506-debitor/5063-hs-office-debitor-rbac.sql b/src/main/resources/db/changelog/5-hs-office/506-debitor/5063-hs-office-debitor-rbac.sql index 449d42fd..7f23e273 100644 --- a/src/main/resources/db/changelog/5-hs-office/506-debitor/5063-hs-office-debitor-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/506-debitor/5063-hs-office-debitor-rbac.sql @@ -146,7 +146,7 @@ do language plpgsql $$ LOOP call rbac.grantPermissionToRole( rbac.createPermission(row.uuid, 'INSERT', 'hs_office.debitor'), - rbac.globalADMIN()); + rbac.global_ADMIN()); END LOOP; end; $$; @@ -162,7 +162,7 @@ begin -- unconditional for all rows in that table call rbac.grantPermissionToRole( rbac.createPermission(NEW.uuid, 'INSERT', 'hs_office.debitor'), - rbac.globalADMIN()); + rbac.global_ADMIN()); -- end. return NEW; end; $$; diff --git a/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5073-hs-office-sepamandate-rbac.sql b/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5073-hs-office-sepamandate-rbac.sql index 9f60b327..5a693add 100644 --- a/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5073-hs-office-sepamandate-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5073-hs-office-sepamandate-rbac.sql @@ -50,7 +50,7 @@ begin perform rbac.defineRoleWithGrants( hs_office.sepamandate_OWNER(NEW), permissions => array['DELETE'], - incomingSuperRoles => array[rbac.globalADMIN()], + incomingSuperRoles => array[rbac.global_ADMIN()], subjectUuids => array[rbac.currentSubjectUuid()] ); diff --git a/src/main/resources/db/changelog/5-hs-office/510-membership/5103-hs-office-membership-rbac.sql b/src/main/resources/db/changelog/5-hs-office/510-membership/5103-hs-office-membership-rbac.sql index 855b0870..6ad7515f 100644 --- a/src/main/resources/db/changelog/5-hs-office/510-membership/5103-hs-office-membership-rbac.sql +++ b/src/main/resources/db/changelog/5-hs-office/510-membership/5103-hs-office-membership-rbac.sql @@ -108,7 +108,7 @@ do language plpgsql $$ LOOP call rbac.grantPermissionToRole( rbac.createPermission(row.uuid, 'INSERT', 'hs_office.membership'), - rbac.globalADMIN()); + rbac.global_ADMIN()); END LOOP; end; $$; @@ -124,7 +124,7 @@ begin -- unconditional for all rows in that table call rbac.grantPermissionToRole( rbac.createPermission(NEW.uuid, 'INSERT', 'hs_office.membership'), - rbac.globalADMIN()); + rbac.global_ADMIN()); -- end. return NEW; end; $$; diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql index 5cf3ef82..b2bd2441 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql @@ -4,16 +4,16 @@ --changeset michael.hoennig:hs-office-coopshares-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -CREATE TYPE hs_office.HsOfficeCoopSharesTransactionType AS ENUM ('ADJUSTMENT', 'SUBSCRIPTION', 'CANCELLATION'); +CREATE TYPE hs_office.CoopSharesTransactionType AS ENUM ('ADJUSTMENT', 'SUBSCRIPTION', 'CANCELLATION'); -CREATE CAST (character varying as hs_office.HsOfficeCoopSharesTransactionType) WITH INOUT AS IMPLICIT; +CREATE CAST (character varying as hs_office.CoopSharesTransactionType) WITH INOUT AS IMPLICIT; create table if not exists hs_office.coopsharestransaction ( uuid uuid unique references rbac.object (uuid) initially deferred, version int not null default 0, membershipUuid uuid not null references hs_office.membership(uuid), - transactionType hs_office.HsOfficeCoopSharesTransactionType not null, + transactionType hs_office.CoopSharesTransactionType not null, valueDate date not null, shareCount integer not null, reference varchar(48) not null, diff --git a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql index 4da4e0bd..3407247f 100644 --- a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql +++ b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql @@ -4,7 +4,7 @@ --changeset michael.hoennig:hs-office-coopassets-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -CREATE TYPE hs_office.HsOfficeCoopAssetsTransactionType AS ENUM ('ADJUSTMENT', +CREATE TYPE hs_office.CoopAssetsTransactionType AS ENUM ('ADJUSTMENT', 'DEPOSIT', 'DISBURSAL', 'TRANSFER', @@ -13,14 +13,14 @@ CREATE TYPE hs_office.HsOfficeCoopAssetsTransactionType AS ENUM ('ADJUSTMENT', 'LOSS', 'LIMITATION'); -CREATE CAST (character varying as hs_office.HsOfficeCoopAssetsTransactionType) WITH INOUT AS IMPLICIT; +CREATE CAST (character varying as hs_office.CoopAssetsTransactionType) WITH INOUT AS IMPLICIT; create table if not exists hs_office.coopassetstransaction ( uuid uuid unique references rbac.object (uuid) initially deferred, version int not null default 0, membershipUuid uuid not null references hs_office.membership(uuid), - transactionType hs_office.HsOfficeCoopAssetsTransactionType not null, + transactionType hs_office.CoopAssetsTransactionType not null, valueDate date not null, assetValue money not null, reference varchar(48) not null, diff --git a/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql b/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql index 7417338e..80a3403e 100644 --- a/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql +++ b/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql @@ -70,7 +70,7 @@ begin outgoingSubRoles => array[hs_office.relation_TENANT(newDebitorRel)] ); - call rbac.grantPermissionToRole(rbac.createPermission(NEW.uuid, 'DELETE'), rbac.globalAdmin()); + call rbac.grantPermissionToRole(rbac.createPermission(NEW.uuid, 'DELETE'), rbac.global_ADMIN()); call rbac.leaveTriggerForObjectUuid(NEW.uuid); end; $$; diff --git a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql index ad56e436..cf19aa32 100644 --- a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql +++ b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql @@ -4,7 +4,7 @@ --changeset michael.hoennig:booking-item-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -create type hs_booking.HsBookingItemType as enum ( +create type hs_booking.ItemType as enum ( 'PRIVATE_CLOUD', 'CLOUD_SERVER', 'MANAGED_SERVER', @@ -12,14 +12,14 @@ create type hs_booking.HsBookingItemType as enum ( 'DOMAIN_SETUP' ); -CREATE CAST (character varying as hs_booking.HsBookingItemType) WITH INOUT AS IMPLICIT; +CREATE CAST (character varying as hs_booking.ItemType) WITH INOUT AS IMPLICIT; create table if not exists hs_booking.item ( uuid uuid unique references rbac.object (uuid), version int not null default 0, projectUuid uuid null references hs_booking.project(uuid), - type hs_booking.HsBookingItemType not null, + type hs_booking.ItemType not null, parentItemUuid uuid null references hs_booking.item(uuid) initially deferred, validity daterange not null, caption varchar(80) not null, diff --git a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql index 6a955014..097d5671 100644 --- a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql +++ b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql @@ -69,7 +69,7 @@ begin - call rbac.grantPermissionToRole(rbac.createPermission(NEW.uuid, 'DELETE'), rbac.globalAdmin()); + call rbac.grantPermissionToRole(rbac.createPermission(NEW.uuid, 'DELETE'), rbac.global_ADMIN()); call rbac.leaveTriggerForObjectUuid(NEW.uuid); end; $$; @@ -114,7 +114,7 @@ do language plpgsql $$ LOOP call rbac.grantPermissionToRole( rbac.createPermission(row.uuid, 'INSERT', 'hs_booking.item'), - rbac.globalADMIN()); + rbac.global_ADMIN()); END LOOP; end; $$; @@ -130,7 +130,7 @@ begin -- unconditional for all rows in that table call rbac.grantPermissionToRole( rbac.createPermission(NEW.uuid, 'INSERT', 'hs_booking.item'), - rbac.globalADMIN()); + rbac.global_ADMIN()); -- end. return NEW; end; $$; diff --git a/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql b/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql index 30b4b79a..304e7337 100644 --- a/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql +++ b/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql @@ -4,7 +4,7 @@ --changeset michael.hoennig:hosting-asset-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -create type hs_hosting.HsHostingAssetType as enum ( +create type hs_hosting.AssetType as enum ( 'CLOUD_SERVER', 'MANAGED_SERVER', 'MANAGED_WEBSPACE', @@ -26,14 +26,14 @@ create type hs_hosting.HsHostingAssetType as enum ( 'IPV6_NUMBER' ); -CREATE CAST (character varying as hs_hosting.HsHostingAssetType) WITH INOUT AS IMPLICIT; +CREATE CAST (character varying as hs_hosting.AssetType) WITH INOUT AS IMPLICIT; create table if not exists hs_hosting.asset ( uuid uuid unique references rbac.object (uuid), version int not null default 0, bookingItemUuid uuid null references hs_booking.item(uuid), - type hs_hosting.HsHostingAssetType not null, + type hs_hosting.AssetType not null, parentAssetUuid uuid null references hs_hosting.asset(uuid) initially deferred, assignedToAssetUuid uuid null references hs_hosting.asset(uuid) initially deferred, identifier varchar(80) not null, @@ -58,8 +58,8 @@ create or replace function hs_hosting.asset_type_hierarchy_check_tf() returns trigger language plpgsql as $$ declare - actualParentType hs_hosting.HsHostingAssetType; - expectedParentType hs_hosting.HsHostingAssetType; + actualParentType hs_hosting.AssetType; + expectedParentType hs_hosting.AssetType; begin if NEW.parentAssetUuid is not null then actualParentType := (select type @@ -134,8 +134,8 @@ create or replace function hs_hosting.asset_booking_item_hierarchy_check_tf() returns trigger language plpgsql as $$ declare - actualBookingItemType hs_booking.HsBookingItemType; - expectedBookingItemType hs_booking.HsBookingItemType; + actualBookingItemType hs_booking.ItemType; + expectedBookingItemType hs_booking.ItemType; begin actualBookingItemType := (select type from hs_booking.item diff --git a/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql b/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql index fc3492c7..4e2137af 100644 --- a/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql +++ b/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql @@ -52,7 +52,7 @@ begin incomingSuperRoles => array[ hs_booking.item_ADMIN(newBookingItem), hs_hosting.asset_ADMIN(newParentAsset), - rbac.globalADMIN(rbac.unassumed())], + rbac.global_ADMIN(rbac.unassumed())], subjectUuids => array[rbac.currentSubjectUuid()] ); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java index 2fd29b56..9d73ac89 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java @@ -1145,7 +1145,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport { final int expectedCountInTestDataCount, final int minCountExpectedInProdData) { final var q = em.createNativeQuery( - "select count(*) from hs_hosting.asset where type = cast(:type as hs_hosting.HsHostingAssetType)", + "select count(*) from hs_hosting.asset where type = cast(:type as hs_hosting.AssetType)", Integer.class); q.setParameter("type", assetType.name()); final var count = (Integer) q.getSingleResult(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index 44605216..25e1629e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -39,9 +39,6 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean @Autowired Context context; - @Autowired - Context contextMock; - @Autowired HsOfficeRelationRealRepository relationrealRepo;