|
@@ 226-231 (lines=6) @@
|
| 223 |
|
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) |
| 224 |
|
self.assertEqual(reload(self.chatmembers[0]), self.chatmembers[0]) |
| 225 |
|
|
| 226 |
|
def test_update_forbidden3(self): |
| 227 |
|
# Client cannot update a chatmember if it is not a member of the right chat |
| 228 |
|
self.client.force_authenticate(user=self.users[1]) |
| 229 |
|
response = self.client.put(self.change_role_chatmember_url.format(self.chats[0].id), {'role': "admin", "chatmember_id": 3}) |
| 230 |
|
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) |
| 231 |
|
self.assertEqual(reload(self.chatmembers[2]), self.chatmembers[2]) |
| 232 |
|
|
| 233 |
|
def test_update_non_existent_chat(self): |
| 234 |
|
self.client.force_authenticate(user=self.users[0]) |
|
@@ 219-224 (lines=6) @@
|
| 216 |
|
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) |
| 217 |
|
self.assertEqual(reload(self.chatmembers[2]), self.chatmembers[2]) |
| 218 |
|
|
| 219 |
|
def test_update_forbidden2(self): |
| 220 |
|
# Client cannot update a chatmember if it is the creator of the associated chat |
| 221 |
|
self.client.force_authenticate(user=self.users[0]) |
| 222 |
|
response = self.client.put(self.change_role_chatmember_url.format(self.chats[0].id), {'role': "admin", "chatmember_id": 1}) |
| 223 |
|
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) |
| 224 |
|
self.assertEqual(reload(self.chatmembers[0]), self.chatmembers[0]) |
| 225 |
|
|
| 226 |
|
def test_update_forbidden3(self): |
| 227 |
|
# Client cannot update a chatmember if it is not a member of the right chat |
|
@@ 212-217 (lines=6) @@
|
| 209 |
|
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) |
| 210 |
|
self.assertEqual(reload(self.chatmembers[2]), self.chatmembers[2]) |
| 211 |
|
|
| 212 |
|
def test_update_forbidden(self): |
| 213 |
|
# Client cannot update a chatmember if he isn't admin of the associated chat |
| 214 |
|
self.client.force_authenticate(user=self.users[2]) |
| 215 |
|
response = self.client.put(self.change_role_chatmember_url.format(self.chats[0].id), {'role': "admin", "chatmember_id": 3}) |
| 216 |
|
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) |
| 217 |
|
self.assertEqual(reload(self.chatmembers[2]), self.chatmembers[2]) |
| 218 |
|
|
| 219 |
|
def test_update_forbidden2(self): |
| 220 |
|
# Client cannot update a chatmember if it is the creator of the associated chat |
|
@@ 199-204 (lines=6) @@
|
| 196 |
|
self.assertEqual(ChatMember.objects.all().count(), len(self.chatmembers) + 1) |
| 197 |
|
|
| 198 |
|
#### Modification requests |
| 199 |
|
def test_update_wrong_way(self): |
| 200 |
|
# Has to use the change_role function to change a ChatMember |
| 201 |
|
self.client.force_authenticate(user=self.users[0]) |
| 202 |
|
response = self.client.put(self.chatmember_url % self.chatmembers[2].id, {'role': "admin", "chatmember_id": 3}) |
| 203 |
|
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) |
| 204 |
|
self.assertEqual(reload(self.chatmembers[2]), self.chatmembers[2]) |
| 205 |
|
|
| 206 |
|
def test_update_unauthed(self): |
| 207 |
|
# Unauthed client cannot update a chatmember |