use serde_json to build http response with JWT json body
This commit is contained in:
+20
-4
@@ -16,15 +16,31 @@ fi
|
||||
for i in {0..10}
|
||||
do
|
||||
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/get/ -d '{"username":"toto", "password":"tutu"}')
|
||||
if [ $http_response != "400" ]
|
||||
then
|
||||
echo "bad http status code : ${http_response}, expect 400"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(cat response.txt | jq -r '.error')" != "bad request" ]
|
||||
then
|
||||
echo "bad data returned, expect : bad request"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
for i in {0..10}
|
||||
do
|
||||
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/get/ -d '{"email":"toto", "password":"tutu"}')
|
||||
if [ $http_response != "403" ]
|
||||
then
|
||||
echo "bad http status code : ${http_response}, expect 200"
|
||||
echo "bad http status code : ${http_response}, expect 403"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(cat response.txt | jq -r '.error')" != "url forbidden" ]
|
||||
then
|
||||
echo "bad data returned, expect : invalid credentials"
|
||||
echo "bad data returned, expect : url forbidden"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
@@ -35,7 +51,7 @@ do
|
||||
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/ge/ -d '{"username":"toto", "password":"tutu"}')
|
||||
if [ $http_response != "404" ]
|
||||
then
|
||||
echo "bad http status code : ${http_response}, expect 400"
|
||||
echo "bad http status code : ${http_response}, expect 404"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
@@ -46,7 +62,7 @@ do
|
||||
http_response=$(curl -s -o response.txt -w "%{http_code}" ${URL}/pubkey/)
|
||||
if [ $http_response != "200" ]
|
||||
then
|
||||
echo "bad http status code : ${http_response}, expect 400"
|
||||
echo "bad http status code : ${http_response}, expect 200"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestResponse(TestCase):
|
||||
self.assertEqual(resp.status_code, 200, "bad status code returned")
|
||||
self.assertIsNotNone(resp.json(), "response data can't be empty")
|
||||
|
||||
token = resp.json()["token"]
|
||||
token = resp.json()["access_token"]
|
||||
jwt_decoded = jwt.decode(
|
||||
token,
|
||||
pubkey or self.pub_key,
|
||||
|
||||
Reference in New Issue
Block a user