improv: #5 add e2e tests
This commit is contained in:
parent
65e188bcf8
commit
5321c06d24
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
/target
|
||||
simple-auth
|
||||
*.swp
|
||||
|
||||
tests/python/__pycache__
|
||||
tests/bash/response.txt
|
||||
|
||||
36
tests/bash/curling.bash
Executable file
36
tests/bash/curling.bash
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
#######################################
|
||||
#
|
||||
# A simple curl test on a deployed app
|
||||
#
|
||||
#######################################
|
||||
|
||||
URL="https://dev.thegux.fr"
|
||||
|
||||
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 != "200" ]
|
||||
then
|
||||
echo "bad http status code : ${http_response}, expect 200"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $(cat response.txt | jq -r '.[]') != "ok" ]
|
||||
then
|
||||
echo "bad data returned, expect : ok"
|
||||
exit 1
|
||||
fi
|
||||
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" ]
|
||||
then
|
||||
echo "bad http status code : ${http_response}, expect 400"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
34
tests/python/test_requests.py
Normal file
34
tests/python/test_requests.py
Normal file
@ -0,0 +1,34 @@
|
||||
import requests
|
||||
|
||||
URL = "https://dev.thegux.fr"
|
||||
|
||||
|
||||
def test_get_target():
|
||||
resp = requests.post(URL + "/get/", json={"username": "toto", "password": "tata"})
|
||||
assert resp.status_code == 200, "bad status code returned"
|
||||
assert resp.json() is not None, "response data can't be empty"
|
||||
assert resp.json()["status"] == "ok", "bad status returned"
|
||||
|
||||
|
||||
def test_validate_target():
|
||||
resp = requests.post(
|
||||
URL + "/validate/", json={"username": "toto", "password": "tata"}
|
||||
)
|
||||
assert resp.status_code == 200, "bad status code returned"
|
||||
assert resp.json() is not None, "response data can't be empty"
|
||||
assert resp.json()["status"] == "ok", "bad status returned"
|
||||
|
||||
|
||||
def test_refresh_target():
|
||||
resp = requests.post(
|
||||
URL + "/refresh/", json={"username": "toto", "password": "tata"}
|
||||
)
|
||||
assert resp.status_code == 200, "bad status code returned"
|
||||
assert resp.json() is not None, "response data can't be empty"
|
||||
assert resp.json()["status"] == "ok", "bad status returned"
|
||||
|
||||
|
||||
def test_bad_target():
|
||||
resp = requests.post(URL + "/token/", json={"username": "toto", "password": "tata"})
|
||||
assert resp.status_code == 400, "bad status code returned"
|
||||
assert resp.text == "", "response data must be empty"
|
||||
Loading…
x
Reference in New Issue
Block a user