event_schema: Add schema check for realm/deactivated event.

This add the schema checker, openapi schema, and also a test for
realm/deactivated event.

With several block comments by tabbott explaining the logic behind our
behavior here.

Part of #17568.
This commit is contained in:
shanukun
2021-03-14 00:30:05 +05:30
committed by Tim Abbott
parent daa9bbba61
commit cfe0fa3788
7 changed files with 87 additions and 0 deletions

View File

@@ -742,6 +742,15 @@ def apply_event(
if key == "authentication_methods":
state["realm_password_auth_enabled"] = value["Email"] or value["LDAP"]
state["realm_email_auth_enabled"] = value["Email"]
elif event["op"] == "deactivated":
# The realm has just been deactivated. If our request had
# arrived a moment later, we'd have rendered the
# deactivation UI; if it'd been a moment sooner, we've
# have rendered the app and then immediately got this
# event (or actually, more likely, an auth error on GET
# /events) and immediately reloaded into the same
# deactivation UI. Passing achieves the same result.
pass
else:
raise AssertionError("Unexpected event type {type}/{op}".format(**event))
elif event["type"] == "subscription":