feat: #12 add async block in handlers (more readable) + fix tests
This commit is contained in:
@@ -28,7 +28,7 @@ done
|
||||
for i in {0..10}
|
||||
do
|
||||
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/ge/ -d '{"username":"toto", "password":"tutu"}')
|
||||
if [ $http_response != "400" ]
|
||||
if [ $http_response != "404" ]
|
||||
then
|
||||
echo "bad http status code : ${http_response}, expect 400"
|
||||
exit 1
|
||||
|
||||
@@ -26,23 +26,26 @@ class TestResponse(TestCase):
|
||||
resp.json()["token"], "header.payload.signature", "bad status returned"
|
||||
)
|
||||
|
||||
# TODO: must be updated after implmenting `/refresh/` url handler
|
||||
def test_refresh_target(self):
|
||||
resp = requests.post(
|
||||
URL + "/refresh/", json={"username": "toto", "password": "tata"}
|
||||
)
|
||||
self.assertEqual(resp.status_code, 200, "bad status code returned")
|
||||
self.assertEqual(resp.status_code, 404, "bad status code returned")
|
||||
self.assertIsNotNone(resp.json(), "response data can't be empty")
|
||||
self.assertEqual(
|
||||
resp.json()["token"], "header.payload.signature", "bad status returned"
|
||||
resp.json()["error"],
|
||||
"the url requested does not exist",
|
||||
"bad status returned",
|
||||
)
|
||||
|
||||
def test_no_credentials(self):
|
||||
resp = requests.post(URL + "/get/")
|
||||
self.assertEqual(resp.status_code, 403, "bad status code returned")
|
||||
self.assertEqual(resp.status_code, 400, "bad status code returned")
|
||||
self.assertIsNotNone(resp.json(), "response data must not be empty")
|
||||
self.assertEqual(
|
||||
resp.json()["error"],
|
||||
"invalid credentials",
|
||||
"the incoming request is not valid",
|
||||
"invalid error message returned",
|
||||
)
|
||||
|
||||
@@ -62,10 +65,10 @@ class TestResponse(TestCase):
|
||||
resp = requests.post(
|
||||
URL + "/token/", json={"username": "toto", "password": "tata"}
|
||||
)
|
||||
self.assertEqual(resp.status_code, 400, "bad status code returned")
|
||||
self.assertEqual(resp.status_code, 404, "bad status code returned")
|
||||
self.assertIsNotNone(resp.json(), "response data must not be empty")
|
||||
self.assertEqual(
|
||||
resp.json()["error"],
|
||||
"the incoming request is not valid",
|
||||
"the url requested does not exist",
|
||||
"invalid error message returned",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user