From 95a7fe24b360ceb831a6acaf14a4ebbf76e7a3d8 Mon Sep 17 00:00:00 2001 From: Godmar Back Date: Sat, 21 Apr 2018 17:34:45 -0400 Subject: [PATCH] added short test script --- src/testloginapi.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/testloginapi.sh diff --git a/src/testloginapi.sh b/src/testloginapi.sh new file mode 100644 index 0000000..a81d5ce --- /dev/null +++ b/src/testloginapi.sh @@ -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 +