1
0

replace unixuser test entities with domain

This commit is contained in:
Michael Hoennig
2022-08-31 14:57:15 +02:00
parent 84ce90b28f
commit a117258085
14 changed files with 163 additions and 163 deletions

View File

@ -8,7 +8,7 @@ create table if not exists Domain
(
uuid uuid unique references RbacObject (uuid),
name character varying(32),
unixUserUuid uuid references unixuser (uuid)
domainUuid uuid references domain (uuid)
);
drop trigger if exists createRbacObjectForDomain_Trigger on Domain;
@ -48,7 +48,7 @@ create or replace function createRbacRulesForDomain()
language plpgsql
strict as $$
declare
parentUser UnixUser;
parentUser domain;
parentPackage package;
domainOwnerRoleUuid uuid;
domainAdminRoleUuid uuid;
@ -57,10 +57,10 @@ begin
raise exception 'invalid usage of TRIGGER AFTER INSERT';
end if;
select * from UnixUser where uuid = NEW.unixUserUuid into parentUser;
select * from domain where uuid = NEW.domainUuid into parentUser;
select * from Package where uuid = parentUser.packageuuid into parentPackage;
-- a domain owner role is created and assigned to the unixuser's admin role
-- a domain owner role is created and assigned to the domain's admin role
domainOwnerRoleUuid = createRole(
domainOwner(NEW),
grantingPermissions(forObjectUuid => NEW.uuid, permitOps => array ['*']),
@ -79,7 +79,7 @@ begin
domainTenant(NEW),
grantingPermissions(forObjectUuid => NEW.uuid, permitOps => array ['*']),
beneathRole(domainAdminRoleUuid),
beingItselfA(createUnixUserTenantRoleIfNotExists(parentUser))
beingItselfA(createdomainTenantRoleIfNotExists(parentUser))
);
return NEW;
@ -118,7 +118,7 @@ do language plpgsql $$
set hsadminng.currentUser to '';
for uu in (select u.uuid, u.name, u.packageuuid, c.reference
from unixuser u
from domain u
join package p on u.packageuuid = p.uuid
join customer c on p.customeruuid = c.uuid
-- WHERE c.reference >= 18000
@ -127,7 +127,7 @@ do language plpgsql $$
if (random() < 0.3) then
for t in 0..1
loop
currentTask = 'creating RBAC test Domain #' || t || ' for UnixUser ' || uu.name || ' #' || uu.uuid;
currentTask = 'creating RBAC test Domain #' || t || ' for domain ' || uu.name || ' #' || uu.uuid;
raise notice 'task: %', currentTask;
select * from package where uuid = uu.packageUuid into pac;
@ -137,7 +137,7 @@ do language plpgsql $$
set local hsadminng.assumedRoles = '';
insert
into Domain (name, unixUserUuid)
into Domain (name, domainUuid)
values ('dom-' || t || '.' || uu.name || '.example.org', uu.uuid);
commit;

View File

@ -48,7 +48,7 @@ begin
select d.*
from domain d
left join unixuser u on u.uuid = d.unixuseruuid
left join domain u on u.uuid = d.domainuuid
where d.uuid = NEW.domainUuid
into parentDomain;
@ -59,7 +59,7 @@ begin
beneathRole(domainAdmin(parentDomain))
);
-- and an admin role is created and assigned to the unixuser owner as well
-- and an admin role is created and assigned to the domain owner as well
perform createRole(
emailAddressAdmin(NEW),
grantingPermissions(forObjectUuid => NEW.uuid, permitOps => array ['edit']),
@ -102,7 +102,7 @@ do language plpgsql $$
for dom in (select d.uuid, d.name, p.name as packageName
from domain d
join unixuser u on u.uuid = d.unixuseruuid
join domain u on u.uuid = d.domainuuid
join package p on u.packageuuid = p.uuid
join customer c on p.customeruuid = c.uuid
-- WHERE c.reference >= 18000

View File

@ -49,7 +49,7 @@ BEGIN
SET LOCAL hsadminng.assumedRoles = '';
-- SELECT *
SELECT count(*) INTO resultCount
FROM unixuser_rv;
FROM domain_rv;
call expectBetween(resultCount, 20, 50);
-- hostsharing admin assuming customer role and listing all accessible packages
@ -61,13 +61,13 @@ BEGIN
FROM test_package_rv p;
call expectBetween(resultCount, 2, 10);
-- hostsharing admin assuming two customer admin roles and listing all accessible unixusers
-- hostsharing admin assuming two customer admin roles and listing all accessible domains
SET SESSION SESSION AUTHORIZATION restricted;
SET LOCAL hsadminng.currentUser = 'mike@example.org';
SET LOCAL hsadminng.assumedRoles = 'test_customer#aab.admin;test_customer#aac.admin';
-- SELECT c.prefix, c.reference, uu.*
SELECT count(*) INTO resultCount
FROM unixuser_rv uu
FROM domain_rv uu
JOIN test_package_rv p ON p.uuid = uu.packageuuid
JOIN test_customer_rv c ON c.uuid = p.customeruuid;
call expectBetween(resultCount, 40, 60);
@ -80,7 +80,7 @@ BEGIN
-- SELECT p.name, uu.name, dom.name
SELECT count(*) INTO resultCount
FROM domain_rv dom
JOIN unixuser_rv uu ON uu.uuid = dom.unixuseruuid
JOIN domain_rv uu ON uu.uuid = dom.domainuuid
JOIN test_package_rv p ON p.uuid = uu.packageuuid
JOIN test_customer_rv c ON c.uuid = p.customeruuid;
call expectBetween(resultCount, 20, 40);
@ -94,7 +94,7 @@ BEGIN
SELECT count(*) INTO resultCount
FROM emailaddress_rv ema
JOIN domain_rv dom ON dom.uuid = ema.domainuuid
JOIN unixuser_rv uu ON uu.uuid = dom.unixuseruuid
JOIN domain_rv uu ON uu.uuid = dom.domainuuid
JOIN test_package_rv p ON p.uuid = uu.packageuuid
JOIN test_customer_rv c ON c.uuid = p.customeruuid;
call expectBetween(resultCount, 100, 300);
@ -112,7 +112,7 @@ END; $$;
no count required factor table
1 7 000 7 000 1.000 customers
2 17 436 15 000 1.162 packages
3 174 360 150 000 1.162 unixuser
3 174 360 150 000 1.162 domain
4 105 206 100 000 1.052 domain
5 526 030 500 000 1.052 emailaddress
@ -126,7 +126,7 @@ in average +9,33%
no count required factor table
1 10 000 7 000 1.429 customers
2 24 904 15 000 1.660 packages
3 249 040 150 000 1.660 unixuser
3 249 040 150 000 1.660 domain
4 149 946 100 000 1.499 domain
5 749 730 500 000 1.499 emailaddress

View File

@ -15,8 +15,8 @@ select no,
select 2 as no, count(*) as "count", 15000 as "required", 'packages' as "table"
from package
union
select 3 as no, count(*) as "count", 150000 as "required", 'unixuser' as "table"
from unixuser
select 3 as no, count(*) as "count", 150000 as "required", 'domain' as "table"
from domain
union
select 4 as no, count(*) as "count", 100000 as "required", 'domain' as "table"
from domain