Skip to content

Commit

Permalink
Always check the errcode in failure responses
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFerr committed Sep 25, 2024
1 parent d28c17b commit 792b065
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions tests/rest/client/test_owned_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_user_can_set_state_with_own_userid_key(self) -> None:
)

def test_room_creator_cannot_set_state_with_own_suffixed_key(self) -> None:
self.helper.send_state(
body = self.helper.send_state(
self.room_id,
_STATE_EVENT_TEST_TYPE,
{},
Expand All @@ -77,8 +77,14 @@ def test_room_creator_cannot_set_state_with_own_suffixed_key(self) -> None:
expect_code=HTTPStatus.FORBIDDEN,
)

self.assertEqual(
body["errcode"],
Codes.FORBIDDEN,
body,
)

def test_room_creator_cannot_set_state_with_other_userid_key(self) -> None:
self.helper.send_state(
body = self.helper.send_state(
self.room_id,
_STATE_EVENT_TEST_TYPE,
{},
Expand All @@ -87,8 +93,14 @@ def test_room_creator_cannot_set_state_with_other_userid_key(self) -> None:
expect_code=HTTPStatus.FORBIDDEN,
)

self.assertEqual(
body["errcode"],
Codes.FORBIDDEN,
body,
)

def test_room_creator_cannot_set_state_with_other_suffixed_key(self) -> None:
self.helper.send_state(
body = self.helper.send_state(
self.room_id,
_STATE_EVENT_TEST_TYPE,
{},
Expand All @@ -97,6 +109,12 @@ def test_room_creator_cannot_set_state_with_other_suffixed_key(self) -> None:
expect_code=HTTPStatus.FORBIDDEN,
)

self.assertEqual(
body["errcode"],
Codes.FORBIDDEN,
body,
)

def test_room_creator_cannot_set_state_with_nonmember_userid_key(self) -> None:
body = self.helper.send_state(
self.room_id,
Expand Down Expand Up @@ -183,7 +201,7 @@ def test_room_creator_can_set_state_with_other_suffixed_key(self) -> None:
)

def test_user_cannot_set_state_with_other_userid_key(self) -> None:
self.helper.send_state(
body = self.helper.send_state(
self.room_id,
_STATE_EVENT_TEST_TYPE,
{},
Expand All @@ -192,8 +210,14 @@ def test_user_cannot_set_state_with_other_userid_key(self) -> None:
expect_code=HTTPStatus.FORBIDDEN,
)

self.assertEqual(
body["errcode"],
Codes.FORBIDDEN,
body,
)

def test_user_cannot_set_state_with_other_suffixed_key(self) -> None:
self.helper.send_state(
body = self.helper.send_state(
self.room_id,
_STATE_EVENT_TEST_TYPE,
{},
Expand All @@ -202,8 +226,14 @@ def test_user_cannot_set_state_with_other_suffixed_key(self) -> None:
expect_code=HTTPStatus.FORBIDDEN,
)

self.assertEqual(
body["errcode"],
Codes.FORBIDDEN,
body,
)

def test_user_cannot_set_state_with_unseparated_suffixed_key(self) -> None:
self.helper.send_state(
body = self.helper.send_state(
self.room_id,
_STATE_EVENT_TEST_TYPE,
{},
Expand All @@ -212,8 +242,14 @@ def test_user_cannot_set_state_with_unseparated_suffixed_key(self) -> None:
expect_code=HTTPStatus.FORBIDDEN,
)

self.assertEqual(
body["errcode"],
Codes.FORBIDDEN,
body,
)

def test_user_cannot_set_state_with_misplaced_userid_in_key(self) -> None:
self.helper.send_state(
body = self.helper.send_state(
self.room_id,
_STATE_EVENT_TEST_TYPE,
{},
Expand All @@ -223,6 +259,12 @@ def test_user_cannot_set_state_with_misplaced_userid_in_key(self) -> None:
expect_code=HTTPStatus.FORBIDDEN,
)

self.assertEqual(
body["errcode"],
Codes.FORBIDDEN,
body,
)

def test_room_creator_can_set_state_with_nonmember_userid_key(self) -> None:
self.helper.send_state(
self.room_id,
Expand Down

0 comments on commit 792b065

Please sign in to comment.