Rename Congregations to more meaningful Roles

This commit is contained in:
sfigato 2022-02-03 12:16:34 +01:00
parent ef08fe5997
commit 593255e853
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
5 changed files with 29 additions and 29 deletions

View File

@ -11,7 +11,7 @@ from phi.async_ldap.model import (
Robots,
Service,
Group,
Congregations,
Roles,
)
from phi.async_ldap.mixins import build_heritage
from phi.async_ldap.client import AsyncClient
@ -36,7 +36,7 @@ cl = AsyncClient(
async def clean_db():
h = Hackers(cl)
r = Robots(cl)
c = Congregations(cl)
c = Roles(cl)
h.delete_cascade = True
r.delete_cascade = True
c.delete_cascade = True
@ -227,7 +227,7 @@ async def test_Group_init():
u = await init_achilles()
g = await init_group("achaeans", [u])
c = Congregations(cl)
c = Roles(cl)
res = await c.search("achaeans")
@ -246,9 +246,9 @@ async def test_Group_describe():
res = await g.describe()
assert res == {
"ou": "Congregations",
"ou": "Roles",
"cn": "achaeans",
"dn": f"cn=achaeans,ou=Congregations,{BASE_DN}",
"dn": f"cn=achaeans,ou=Roles,{BASE_DN}",
"member": [u1.dn, u2.dn],
}

View File

@ -16,10 +16,10 @@ objectClass: top
objectClass: organizationalUnit
ou: Robots
dn: ou=Congregations,dc=unit,dc=macaomilano,dc=org
dn: ou=Roles,dc=unit,dc=macaomilano,dc=org
objectClass: top
objectClass: organizationalUnit
ou: Congregations
ou: Roles
dn: uid=phi,ou=Robots,dc=unit,dc=macaomilano,dc=org
objectClass: account
@ -47,9 +47,9 @@ objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
memberOf: cn=Admins,ou=Congregations,dc=unit,dc=macaomilano,dc=org
memberOf: cn=GitUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
memberOf: cn=IRCUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
memberOf: cn=Admins,ou=Roles,dc=unit,dc=macaomilano,dc=org
memberOf: cn=GitUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
memberOf: cn=IRCUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
cn: Raffaello
sn: Mascetti
mail: rmascetti@autistici.org
@ -61,8 +61,8 @@ objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
memberOf: cn=GitUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
memberOf: cn=IRCUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
memberOf: cn=GitUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
memberOf: cn=IRCUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
cn: Guido
sn: Necchi
mail: gnecchi@autistici.org
@ -74,20 +74,20 @@ objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
memberOf: cn=GitUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
memberOf: cn=GitUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
cn: Giorgio
sn: Perozzi
mail: gperozzi@autistici.org
uid: perozzi
userPassword: {SHA}0+CRQKqsTj1I82PHxvZ4ebbddXQ=
dn: cn=Admins,ou=Congregations,dc=unit,dc=macaomilano,dc=org
dn: cn=Admins,ou=Roles,dc=unit,dc=macaomilano,dc=org
member: uid=conte_mascetti,ou=Hackers,dc=unit,dc=macaomilano,dc=org
cn: Admins
objectClass: groupOfNames
objectClass: top
dn: cn=GitUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
dn: cn=GitUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
member: uid=conte_mascetti,ou=Hackers,dc=unit,dc=macaomilano,dc=org
member: uid=necchi,ou=Hackers,dc=unit,dc=macaomilano,dc=org
member: uid=perozzi,ou=Hackers,dc=unit,dc=macaomilano,dc=org
@ -95,7 +95,7 @@ cn: GitUsers
objectClass: groupOfNames
objectClass: top
dn: cn=IRCUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
dn: cn=IRCUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
member: uid=conte_mascetti,ou=Hackers,dc=unit,dc=macaomilano,dc=org
member: uid=necchi,ou=Hackers,dc=unit,dc=macaomilano,dc=org
cn: IRCUsers

View File

@ -84,7 +84,7 @@ class Group(mixins.Member, mixins.Entry, mixins.Singleton):
object_class = ["groupOfNames", "top"]
_instances = dict() # type: ignore
id_tag = "cn"
ou = "Congregations"
ou = "Roles"
ldap_attributes = ["cn", "ou", "member"]
memeber_classes = {"Hackers": User, "Robots": Service}
empty = False
@ -110,9 +110,9 @@ class Group(mixins.Member, mixins.Entry, mixins.Singleton):
yield self.memeber_classes.get(dn["ou"])(self.client, dn["uid"])
class Congregations(mixins.OrganizationalUnit, mixins.Entry, mixins.Singleton):
class Roles(mixins.OrganizationalUnit, mixins.Entry, mixins.Singleton):
_instances = dict() # type: ignore
ou = "Congregations"
ou = "Roles"
child_class = Group

View File

@ -2,7 +2,7 @@
from aiohttp.web import middleware, HTTPFound
from phi import app
from phi.async_ldap.model import Hackers, Robots, Congregations
from phi.async_ldap.model import Hackers, Robots, Roles
@middleware
@ -17,7 +17,7 @@ async def authenticated(request, handler):
request.app["ldap_client"] = client
request.app["users"] = Hackers(client)
request.app["services"] = Robots(client)
request.app["groups"] = Congregations(client)
request.app["groups"] = Roles(client)
resp = await handler(request)
return resp

View File

@ -9,7 +9,7 @@ from phi.async_ldap.model import (
Robots,
Service,
Group,
Congregations,
Roles,
)
from phi.async_ldap.mixins import build_heritage
from phi.async_ldap.client import AsyncClient
@ -36,7 +36,7 @@ cl = AsyncClient(
async def get_all_children():
h = Hackers(cl)
r = Robots(cl)
g = Congregations(cl)
g = Roles(cl)
hackers = await dlv(h, User)
robots = await dlv(r, Service)
@ -69,7 +69,7 @@ def sync_await(awaitable):
h = Hackers(cl)
r = Robots(cl)
c = Congregations(cl)
c = Roles(cl)
# asyncio.run(print_async("hackers:", describe(h)))
@ -81,7 +81,7 @@ c = Congregations(cl)
# asyncio.run(print_async("Hackers members:", get_members(h)))
# asyncio.run(print_async("Robots members:", get_members(r)))
# asyncio.run(print_async("Congregations members:", get_members(c)))
# asyncio.run(print_async("Roles members:", get_members(c)))
#
async def add_new(obj, name, **kw):
@ -139,17 +139,17 @@ async def remove_member(group, member):
# asyncio.run(print_async("Robots members:", get_members(r)))
asyncio.run(safe_search(c, "GitUsers"))
asyncio.run(print_async("Congregations members:", get_members(c)))
asyncio.run(print_async("Roles members:", get_members(c)))
asyncio.run(
add_new(Group, "naughty", member=[User(cl, "conte_mascetti"), User(cl, "necchi")])
)
asyncio.run(print_async("Congregations members:", get_members(c)))
asyncio.run(print_async("Roles members:", get_members(c)))
asyncio.run(safe_delete(Group(cl, "naughty")))
asyncio.run(print_async("Congregations members:", get_members(c)))
asyncio.run(print_async("Roles members:", get_members(c)))
asyncio.run(
add_new(Group, "naughty", member=[User(cl, "conte_mascetti"), User(cl, "necchi")])
)
asyncio.run(print_async("Congregations members:", get_members(c)))
asyncio.run(print_async("Roles members:", get_members(c)))
print("==> HERE <==")
naughty = sync_await(Group(cl, "naughty").sync())
print("NAUGHTY =>>", [m for m in naughty.get_members()])