diff options
author | Neil Johnson <neil@matrix.org> | 2018-11-02 15:51:33 +0000 |
---|---|---|
committer | Neil Johnson <neil@matrix.org> | 2018-11-02 15:51:33 +0000 |
commit | 158eccdfb11c029d2f9698bbde85974e520da16a (patch) | |
tree | a150b79fe15549a5052bca2fb6fc8729b20f397f | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into neilj/create_sup... (diff) | |
download | synapse-158eccdfb11c029d2f9698bbde85974e520da16a.tar.xz |
test suppoer user filtering
-rw-r--r-- | synapse/storage/user_directory.py | 4 | ||||
-rw-r--r-- | tests/storage/test_user_directory.py | 50 |
2 files changed, 26 insertions, 28 deletions
diff --git a/synapse/storage/user_directory.py b/synapse/storage/user_directory.py index cd25e07719..c91996b799 100644 --- a/synapse/storage/user_directory.py +++ b/synapse/storage/user_directory.py @@ -164,7 +164,7 @@ class UserDirectoryStore(SQLBaseStore): def update_profile_in_user_dir(self, user_id, display_name, avatar_url, room_id): def _update_profile_in_user_dir_txn(txn): - if user_is is self.hs.config.support_user_id: + if user_id is self.hs.config.support_user_id: return new_entry = self._simple_upsert_txn( txn, @@ -229,7 +229,7 @@ class UserDirectoryStore(SQLBaseStore): @defer.inlineCallbacks def update_user_in_public_user_list(self, user_id, room_id): - if user_is is not self.hs.config.support_user_id: + if user_id is not self.hs.config.support_user_id: yield self._simple_update_one( table="users_in_public_rooms", keyvalues={"user_id": user_id}, diff --git a/tests/storage/test_user_directory.py b/tests/storage/test_user_directory.py index 12f64de691..290a3fa8e5 100644 --- a/tests/storage/test_user_directory.py +++ b/tests/storage/test_user_directory.py @@ -24,6 +24,7 @@ from tests.utils import setup_test_homeserver ALICE = "@alice:a" BOB = "@bob:b" BOBBY = "@bobby:a" +ROOM = "!room:id" class UserDirectoryStoreTestCase(unittest.TestCase): @@ -42,7 +43,7 @@ class UserDirectoryStoreTestCase(unittest.TestCase): BOBBY: ProfileInfo(None, "bobby"), }, ) - yield self.store.add_users_to_public_room("!room:id", [ALICE, BOB]) + yield self.store.add_users_to_public_room(ROOM, [ALICE, BOB]) yield self.store.add_users_who_share_room( "!room:id", False, ((ALICE, BOB), (BOB, ALICE)) ) @@ -81,36 +82,33 @@ class UserDirectoryStoreTestCase(unittest.TestCase): self.hs.config.user_directory_search_all_users = True self.hs.config.support_user_id = "@support:test" SUPPORT_USER = self.hs.config.support_user_id + support_screen_name = "Support" + yield self.store.add_profiles_to_user_dir( - "!room:id", - {SUPPORT_USER: ProfileInfo(None, "support")}, + ROOM, + {SUPPORT_USER: ProfileInfo(None, support_screen_name)}, ) - yield self.store.add_users_to_public_room("!room:id", [SUPPORT_USER]) + yield self.store.add_users_to_public_room(ROOM, [SUPPORT_USER]) yield self.store.add_users_who_share_room( - "!room:id", False, ((ALICE, SUPPORT_USER),) + ROOM, False, ((ALICE, SUPPORT_USER),) + ) + + r = yield self.store.search_user_dir(ALICE, support_screen_name, 10) + self.assertFalse(r["limited"]) + self.assertEqual(0, len(r["results"])) + + yield self.store.update_user_in_user_dir(SUPPORT_USER, ROOM) + yield self.store.update_profile_in_user_dir( + SUPPORT_USER, support_screen_name, None, ROOM ) + yield self.store.update_user_in_public_user_list(SUPPORT_USER, ROOM) - r = yield self.store.search_user_dir(ALICE, "support", 10) + r = yield self.store.search_user_dir(ALICE, support_screen_name, 10) self.assertFalse(r["limited"]) self.assertEqual(0, len(r["results"])) - # add_users_who_share_room - # add_users_to_public_room - # add_profiles_to_user_dir - # update_user_in_user_dir - # update_profile_in_user_dir - # update_user_in_public_user_list - - # yield self.store.add_profiles_to_user_dir( - # "!room:id", - # {SUPPORT_USER: ProfileInfo(None, "support")}, - # ) - # yield self.store.add_profiles_to_user_dir(SUPPORT_USER, - # - # - # - # yield self.store.add_users_to_public_room("!room:id", [SUPPORT_USER]) - # - # yield self.store.add_users_who_share_room( - # "!room:id", False, ((ALICE, SUPPORT_USER), (BOB, SUPPORT_USER)) - # ) + r = yield self.store.get_user_in_directory(SUPPORT_USER) + self.assertEqual(r, None) + + r = yield self.store.get_user_in_public_room(SUPPORT_USER) + self.assertEqual(r, None) |