added short test script

This commit is contained in:
Godmar Back 2018-04-21 17:34:45 -04:00
parent ba5cf09615
commit 95a7fe24b3

31
src/testloginapi.sh Normal file
View File

@ -0,0 +1,31 @@
# change this as per instruction to avoid conflicts.
PORT=10000
COOKIEJAR=cookies.txt
# clear cookies
/bin/rm ${COOKIEJAR}
# test authentication
curl -v -H "Content-Type: application/json" \
-c ${COOKIEJAR} \
-X POST \
-d '{"username":"user0","password":"password"}' \
http://localhost:${PORT}/api/login
# this should succeed if the password is correct
curl -v \
-b ${COOKIEJAR} \
http://localhost:${PORT}/api/login
# create a 'private' folder first.
# this should fail since credentials were not presented
curl -v \
http://localhost:${PORT}/private/secret.txt
# this should succeed since credentials were presented
curl -v \
-b ${COOKIEJAR} \
http://localhost:${PORT}/private/secret.txt