Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add test covering appservice sender joining a room
Browse files Browse the repository at this point in the history
I don't think this actually improves coverage as such, but I'll sleep
better at night having this case checked!
  • Loading branch information
David Robertson committed Oct 11, 2021
1 parent 8d2025c commit ff6212a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/handlers/test_user_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer:
hostname="test",
id="1234",
namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]},
sender="@as:test",
# Note: this user does not match the regex above, so that tests
# can distinguish the sender from the AS user.
sender="@as_main:test",
)

mock_load_appservices = Mock(return_value=[self.appservice])
Expand Down Expand Up @@ -179,6 +181,15 @@ def test_excludes_appservices_user(self) -> None:
)
self._check_only_one_user_in_directory(user, public)

def test_excludes_appservice_sender(self) -> None:
user = self.register_user("user", "pass")
token = self.login(user, "pass")
room = self.helper.create_room_as(
self.appservice.sender, is_public=True, tok=self.appservice.token
)
self.helper.join(room, user, tok=token)
self._check_only_one_user_in_directory(user, room)

def _create_rooms_and_inject_memberships(
self, creator: str, token: str, joiner: str
) -> Tuple[str, str]:
Expand Down

0 comments on commit ff6212a

Please sign in to comment.