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

Commit

Permalink
Modify tests to cover direct as well as unrestricted
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Sep 11, 2020
1 parent 4eda10f commit aab785a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/rest/client/test_room_access_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@ def test_restricted(self):
expected_code=200,
)

# We are allowed to publish the room to the public rooms directory
url = "/_matrix/client/r0/directory/list/room/%s" % self.restricted_room
data = {"visibility": "public"}

request, channel = self.make_request("PUT", url, data, access_token=self.tok)
self.render(request)
self.assertEqual(channel.code, 200, channel.result)

def test_direct(self):
"""Tests that, in direct mode, other users than the initial two can't be invited,
but the following scenario works:
Expand Down Expand Up @@ -390,6 +398,14 @@ def test_direct(self):
self.hs.config.rc_third_party_invite.burst_count = burst
self.hs.config.rc_third_party_invite.per_second = per_second

# We can't publish the room to the public rooms directory
url = "/_matrix/client/r0/directory/list/room/%s" % self.direct_rooms[0]
data = {"visibility": "public"}

request, channel = self.make_request("PUT", url, data, access_token=self.tok)
self.render(request)
self.assertEqual(channel.code, 403, channel.result)

def test_unrestricted(self):
"""Tests that, in unrestricted mode, we can invite whoever we want, but we can
only change the power level of users that wouldn't be forbidden in restricted
Expand Down Expand Up @@ -533,6 +549,11 @@ def test_change_rules(self):
room_id=test_room_id, new_rule=AccessRules.UNRESTRICTED, expected_code=403
)

# Attempt to switch the room to "direct"
self.change_rule_in_room(
room_id=test_room_id, new_rule=AccessRules.DIRECT, expected_code=403
)

def test_change_room_avatar(self):
"""Tests that changing the room avatar is always allowed unless the room is a
direct chat, in which case it's forbidden.
Expand Down

0 comments on commit aab785a

Please sign in to comment.