#8 return a 403 if credentials are invalid + adjust corresponding test

This commit is contained in:
2022-10-03 15:09:44 +00:00
parent 73059c724f
commit 384e868501
6 changed files with 94 additions and 29 deletions
+22
View File
@@ -36,6 +36,28 @@ class TestResponse(TestCase):
resp.json()["token"], "header.payload.signature", "bad status returned"
)
def test_no_credentials(self):
resp = requests.post(URL + "/get/")
self.assertEqual(resp.status_code, 403, "bad status code returned")
self.assertIsNotNone(resp.json(), "response data must not be empty")
self.assertEqual(
resp.json()["error"],
"invalid credentials",
"invalid error message returned",
)
def test_bad_credentials(self):
resp = requests.post(
URL + "/get/", json={"username": "tutu", "password": "titi"}
)
self.assertEqual(resp.status_code, 403, "bas status code returned")
self.assertIsNotNone(resp.json(), "response data must not be empty")
self.assertEqual(
resp.json()["error"],
"invalid credentials",
"invalid error message returned",
)
def test_bad_target(self):
resp = requests.post(
URL + "/token/", json={"username": "toto", "password": "tata"}