test_scim: Add test for missing or wrong authentication.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-11-04 16:24:17 -07:00
committed by Tim Abbott
parent cba8738eea
commit 7e8ebd18b6

View File

@@ -114,6 +114,19 @@ class TestExceptionDetailsNotRevealedToClient(SCIMTestCase):
class TestSCIMUser(SCIMTestCase):
def test_bad_authentication(self) -> None:
hamlet = self.example_user("hamlet")
result = self.client_get(f"/scim/v2/Users/{hamlet.id}", {})
self.assertEqual(result.status_code, 401)
self.assertEqual(result.headers["WWW-Authenticate"], 'Basic realm="django-scim2"')
result = self.client_get(
f"/scim/v2/Users/{hamlet.id}", {"HTTP_AUTHORIZATION": "Bearer wrong"}
)
self.assertEqual(result.status_code, 401)
self.assertEqual(result.headers["WWW-Authenticate"], 'Basic realm="django-scim2"')
def test_get_by_id(self) -> None:
hamlet = self.example_user("hamlet")
expected_response_schema = self.generate_user_schema(hamlet)