Delete a member's local user when the portal removes them
On a member_removed frame the connector deletes the local user mapped to that portal account, never the owner and never a superuser, since the portal only ever creates ordinary accounts here. An instance offline at the time keeps the inert row, as before.
This commit is contained in:
@@ -691,3 +691,29 @@ async def test_a_revoked_link_stands_down(enrolled: User) -> None: # noqa: ARG0
|
||||
await asyncio.sleep(0.05)
|
||||
watcher.cancel()
|
||||
assert not started
|
||||
|
||||
|
||||
def test_a_member_removed_at_the_portal_loses_their_user(db: Session) -> None:
|
||||
"""The portal takes away only the ordinary accounts it gave."""
|
||||
from fluksio.cloud.connector import CloudConnector
|
||||
|
||||
member = User(email="gone@example.com", hashed_password="x", portal_sub="p-9")
|
||||
boss = User(
|
||||
email="boss@example.com",
|
||||
hashed_password="x",
|
||||
portal_sub="p-8",
|
||||
is_superuser=True,
|
||||
)
|
||||
db.add(member)
|
||||
db.add(boss)
|
||||
db.commit()
|
||||
member_id, boss_id = member.id, boss.id
|
||||
|
||||
CloudConnector._forget_member("p-9", "p-8")
|
||||
CloudConnector._forget_member("p-8", "p-8")
|
||||
CloudConnector._forget_member("p-8", None)
|
||||
db.expire_all()
|
||||
assert db.get(User, member_id) is None
|
||||
assert db.get(User, boss_id) is not None
|
||||
db.delete(boss)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user