summary refs log tree commit diff
path: root/scripts/check_auth.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-06 11:41:19 +0100
committerErik Johnston <erik@matrix.org>2015-05-06 11:41:19 +0100
commit119e5d7702a1de0b196a374b53b646c06ee753e5 (patch)
treea617bb7f11b100e1b6fdbb92c462109950d64908 /scripts/check_auth.py
parentMerge pull request #138 from matrix-org/erikj/SYN-371 (diff)
downloadsynapse-119e5d7702a1de0b196a374b53b646c06ee753e5.tar.xz
Seperate scripts/ into scripts/ and scripts-dev/, where scripts/* are automatically added to the package
Diffstat (limited to 'scripts/check_auth.py')
-rw-r--r--scripts/check_auth.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/scripts/check_auth.py b/scripts/check_auth.py
deleted file mode 100644
index b889ac7fa7..0000000000
--- a/scripts/check_auth.py
+++ /dev/null
@@ -1,65 +0,0 @@
-from synapse.events import FrozenEvent
-from synapse.api.auth import Auth
-
-from mock import Mock
-
-import argparse
-import itertools
-import json
-import sys
-
-
-def check_auth(auth, auth_chain, events):
-    auth_chain.sort(key=lambda e: e.depth)
-
-    auth_map = {
-        e.event_id: e
-        for e in auth_chain
-    }
-
-    create_events = {}
-    for e in auth_chain:
-        if e.type == "m.room.create":
-            create_events[e.room_id] = e
-
-    for e in itertools.chain(auth_chain, events):
-        auth_events_list = [auth_map[i] for i, _ in e.auth_events]
-
-        auth_events = {
-            (e.type, e.state_key): e
-            for e in auth_events_list
-        }
-
-        auth_events[("m.room.create", "")] = create_events[e.room_id]
-
-        try:
-            auth.check(e, auth_events=auth_events)
-        except Exception as ex:
-            print "Failed:", e.event_id, e.type, e.state_key
-            print "Auth_events:", auth_events
-            print ex
-            print json.dumps(e.get_dict(), sort_keys=True, indent=4)
-            # raise
-        print "Success:", e.event_id, e.type, e.state_key
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser()
-
-    parser.add_argument(
-        'json',
-        nargs='?',
-        type=argparse.FileType('r'),
-        default=sys.stdin,
-    )
-
-    args = parser.parse_args()
-
-    js = json.load(args.json)
-
-
-    auth = Auth(Mock())
-    check_auth(
-        auth,
-        [FrozenEvent(d) for d in js["auth_chain"]],
-        [FrozenEvent(d) for d in js["pdus"]],
-    )