Rename Congregations to more meaningful Roles
This commit is contained in:
parent
ef08fe5997
commit
593255e853
|
@ -11,7 +11,7 @@ from phi.async_ldap.model import (
|
||||||
Robots,
|
Robots,
|
||||||
Service,
|
Service,
|
||||||
Group,
|
Group,
|
||||||
Congregations,
|
Roles,
|
||||||
)
|
)
|
||||||
from phi.async_ldap.mixins import build_heritage
|
from phi.async_ldap.mixins import build_heritage
|
||||||
from phi.async_ldap.client import AsyncClient
|
from phi.async_ldap.client import AsyncClient
|
||||||
|
@ -36,7 +36,7 @@ cl = AsyncClient(
|
||||||
async def clean_db():
|
async def clean_db():
|
||||||
h = Hackers(cl)
|
h = Hackers(cl)
|
||||||
r = Robots(cl)
|
r = Robots(cl)
|
||||||
c = Congregations(cl)
|
c = Roles(cl)
|
||||||
h.delete_cascade = True
|
h.delete_cascade = True
|
||||||
r.delete_cascade = True
|
r.delete_cascade = True
|
||||||
c.delete_cascade = True
|
c.delete_cascade = True
|
||||||
|
@ -227,7 +227,7 @@ async def test_Group_init():
|
||||||
u = await init_achilles()
|
u = await init_achilles()
|
||||||
g = await init_group("achaeans", [u])
|
g = await init_group("achaeans", [u])
|
||||||
|
|
||||||
c = Congregations(cl)
|
c = Roles(cl)
|
||||||
|
|
||||||
res = await c.search("achaeans")
|
res = await c.search("achaeans")
|
||||||
|
|
||||||
|
@ -246,9 +246,9 @@ async def test_Group_describe():
|
||||||
res = await g.describe()
|
res = await g.describe()
|
||||||
|
|
||||||
assert res == {
|
assert res == {
|
||||||
"ou": "Congregations",
|
"ou": "Roles",
|
||||||
"cn": "achaeans",
|
"cn": "achaeans",
|
||||||
"dn": f"cn=achaeans,ou=Congregations,{BASE_DN}",
|
"dn": f"cn=achaeans,ou=Roles,{BASE_DN}",
|
||||||
"member": [u1.dn, u2.dn],
|
"member": [u1.dn, u2.dn],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ objectClass: top
|
||||||
objectClass: organizationalUnit
|
objectClass: organizationalUnit
|
||||||
ou: Robots
|
ou: Robots
|
||||||
|
|
||||||
dn: ou=Congregations,dc=unit,dc=macaomilano,dc=org
|
dn: ou=Roles,dc=unit,dc=macaomilano,dc=org
|
||||||
objectClass: top
|
objectClass: top
|
||||||
objectClass: organizationalUnit
|
objectClass: organizationalUnit
|
||||||
ou: Congregations
|
ou: Roles
|
||||||
|
|
||||||
dn: uid=phi,ou=Robots,dc=unit,dc=macaomilano,dc=org
|
dn: uid=phi,ou=Robots,dc=unit,dc=macaomilano,dc=org
|
||||||
objectClass: account
|
objectClass: account
|
||||||
|
@ -47,9 +47,9 @@ objectClass: inetOrgPerson
|
||||||
objectClass: organizationalPerson
|
objectClass: organizationalPerson
|
||||||
objectClass: person
|
objectClass: person
|
||||||
objectClass: top
|
objectClass: top
|
||||||
memberOf: cn=Admins,ou=Congregations,dc=unit,dc=macaomilano,dc=org
|
memberOf: cn=Admins,ou=Roles,dc=unit,dc=macaomilano,dc=org
|
||||||
memberOf: cn=GitUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
|
memberOf: cn=GitUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
|
||||||
memberOf: cn=IRCUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
|
memberOf: cn=IRCUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
|
||||||
cn: Raffaello
|
cn: Raffaello
|
||||||
sn: Mascetti
|
sn: Mascetti
|
||||||
mail: rmascetti@autistici.org
|
mail: rmascetti@autistici.org
|
||||||
|
@ -61,8 +61,8 @@ objectClass: inetOrgPerson
|
||||||
objectClass: organizationalPerson
|
objectClass: organizationalPerson
|
||||||
objectClass: person
|
objectClass: person
|
||||||
objectClass: top
|
objectClass: top
|
||||||
memberOf: cn=GitUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
|
memberOf: cn=GitUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
|
||||||
memberOf: cn=IRCUsers,ou=Congregations,dc=unit,dc=macaomilano,dc=org
|
memberOf: cn=IRCUsers,ou=Roles,dc=unit,dc=macaomilano,dc=org
|
||||||
cn: Guido
|
cn: Guido
|
||||||
sn: Necchi
|
sn: Necchi
|
||||||
mail: gnecchi@autistici.org
|
mail: gnecchi@autistici.org
|
||||||
|
@ -74,20 +74,20 @@ objectClass: inetOrgPerson
|
||||||
objectClass: organizationalPerson
|
objectClass: organizationalPerson
|
||||||
objectClass: person
|
objectClass: person
|
||||||
objectClass: top
|
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
|
cn: Giorgio
|
||||||
sn: Perozzi
|
sn: Perozzi
|
||||||
mail: gperozzi@autistici.org
|
mail: gperozzi@autistici.org
|
||||||
uid: perozzi
|
uid: perozzi
|
||||||
userPassword: {SHA}0+CRQKqsTj1I82PHxvZ4ebbddXQ=
|
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
|
member: uid=conte_mascetti,ou=Hackers,dc=unit,dc=macaomilano,dc=org
|
||||||
cn: Admins
|
cn: Admins
|
||||||
objectClass: groupOfNames
|
objectClass: groupOfNames
|
||||||
objectClass: top
|
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=conte_mascetti,ou=Hackers,dc=unit,dc=macaomilano,dc=org
|
||||||
member: uid=necchi,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
|
member: uid=perozzi,ou=Hackers,dc=unit,dc=macaomilano,dc=org
|
||||||
|
@ -95,7 +95,7 @@ cn: GitUsers
|
||||||
objectClass: groupOfNames
|
objectClass: groupOfNames
|
||||||
objectClass: top
|
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=conte_mascetti,ou=Hackers,dc=unit,dc=macaomilano,dc=org
|
||||||
member: uid=necchi,ou=Hackers,dc=unit,dc=macaomilano,dc=org
|
member: uid=necchi,ou=Hackers,dc=unit,dc=macaomilano,dc=org
|
||||||
cn: IRCUsers
|
cn: IRCUsers
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Group(mixins.Member, mixins.Entry, mixins.Singleton):
|
||||||
object_class = ["groupOfNames", "top"]
|
object_class = ["groupOfNames", "top"]
|
||||||
_instances = dict() # type: ignore
|
_instances = dict() # type: ignore
|
||||||
id_tag = "cn"
|
id_tag = "cn"
|
||||||
ou = "Congregations"
|
ou = "Roles"
|
||||||
ldap_attributes = ["cn", "ou", "member"]
|
ldap_attributes = ["cn", "ou", "member"]
|
||||||
memeber_classes = {"Hackers": User, "Robots": Service}
|
memeber_classes = {"Hackers": User, "Robots": Service}
|
||||||
empty = False
|
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"])
|
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
|
_instances = dict() # type: ignore
|
||||||
ou = "Congregations"
|
ou = "Roles"
|
||||||
child_class = Group
|
child_class = Group
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from aiohttp.web import middleware, HTTPFound
|
from aiohttp.web import middleware, HTTPFound
|
||||||
|
|
||||||
from phi import app
|
from phi import app
|
||||||
from phi.async_ldap.model import Hackers, Robots, Congregations
|
from phi.async_ldap.model import Hackers, Robots, Roles
|
||||||
|
|
||||||
|
|
||||||
@middleware
|
@middleware
|
||||||
|
@ -17,7 +17,7 @@ async def authenticated(request, handler):
|
||||||
request.app["ldap_client"] = client
|
request.app["ldap_client"] = client
|
||||||
request.app["users"] = Hackers(client)
|
request.app["users"] = Hackers(client)
|
||||||
request.app["services"] = Robots(client)
|
request.app["services"] = Robots(client)
|
||||||
request.app["groups"] = Congregations(client)
|
request.app["groups"] = Roles(client)
|
||||||
resp = await handler(request)
|
resp = await handler(request)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
|
@ -9,7 +9,7 @@ from phi.async_ldap.model import (
|
||||||
Robots,
|
Robots,
|
||||||
Service,
|
Service,
|
||||||
Group,
|
Group,
|
||||||
Congregations,
|
Roles,
|
||||||
)
|
)
|
||||||
from phi.async_ldap.mixins import build_heritage
|
from phi.async_ldap.mixins import build_heritage
|
||||||
from phi.async_ldap.client import AsyncClient
|
from phi.async_ldap.client import AsyncClient
|
||||||
|
@ -36,7 +36,7 @@ cl = AsyncClient(
|
||||||
async def get_all_children():
|
async def get_all_children():
|
||||||
h = Hackers(cl)
|
h = Hackers(cl)
|
||||||
r = Robots(cl)
|
r = Robots(cl)
|
||||||
g = Congregations(cl)
|
g = Roles(cl)
|
||||||
|
|
||||||
hackers = await dlv(h, User)
|
hackers = await dlv(h, User)
|
||||||
robots = await dlv(r, Service)
|
robots = await dlv(r, Service)
|
||||||
|
@ -69,7 +69,7 @@ def sync_await(awaitable):
|
||||||
|
|
||||||
h = Hackers(cl)
|
h = Hackers(cl)
|
||||||
r = Robots(cl)
|
r = Robots(cl)
|
||||||
c = Congregations(cl)
|
c = Roles(cl)
|
||||||
|
|
||||||
|
|
||||||
# asyncio.run(print_async("hackers:", describe(h)))
|
# 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("Hackers members:", get_members(h)))
|
||||||
# asyncio.run(print_async("Robots members:", get_members(r)))
|
# 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):
|
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(print_async("Robots members:", get_members(r)))
|
||||||
|
|
||||||
asyncio.run(safe_search(c, "GitUsers"))
|
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(
|
asyncio.run(
|
||||||
add_new(Group, "naughty", member=[User(cl, "conte_mascetti"), User(cl, "necchi")])
|
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(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(
|
asyncio.run(
|
||||||
add_new(Group, "naughty", member=[User(cl, "conte_mascetti"), User(cl, "necchi")])
|
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 <==")
|
print("==> HERE <==")
|
||||||
naughty = sync_await(Group(cl, "naughty").sync())
|
naughty = sync_await(Group(cl, "naughty").sync())
|
||||||
print("NAUGHTY =>>", [m for m in naughty.get_members()])
|
print("NAUGHTY =>>", [m for m in naughty.get_members()])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user