added comments to testloginapi.sh
This commit is contained in:
parent
966e23dd13
commit
8584da6a7f
@ -1,11 +1,13 @@
|
|||||||
|
|
||||||
# change this as per instruction to avoid conflicts.
|
# change this number as per instruction to avoid conflicts.
|
||||||
PORT=10000
|
PORT=10000
|
||||||
|
|
||||||
# to test against a working implementation (and see the intended responses)
|
# to test against a working implementation (and see the intended responses)
|
||||||
# change this URL=http://theta.cs.vt.edu:3000/
|
# change this variable, e.g.
|
||||||
|
# use URL=http://theta.cs.vt.edu:3000/
|
||||||
URL=http://localhost:${PORT}
|
URL=http://localhost:${PORT}
|
||||||
|
|
||||||
|
# the file in which curl stores cookies across runs
|
||||||
COOKIEJAR=cookies.txt
|
COOKIEJAR=cookies.txt
|
||||||
|
|
||||||
|
|
||||||
@ -13,23 +15,26 @@ COOKIEJAR=cookies.txt
|
|||||||
/bin/rm ${COOKIEJAR}
|
/bin/rm ${COOKIEJAR}
|
||||||
|
|
||||||
# test authentication
|
# test authentication
|
||||||
|
# this should result in a cookie being issued that embeds the JWT token
|
||||||
curl -v -H "Content-Type: application/json" \
|
curl -v -H "Content-Type: application/json" \
|
||||||
-c ${COOKIEJAR} \
|
-c ${COOKIEJAR} \
|
||||||
-X POST \
|
-X POST \
|
||||||
-d '{"username":"user0","password":"thepassword"}' \
|
-d '{"username":"user0","password":"thepassword"}' \
|
||||||
${URL}/api/login
|
${URL}/api/login
|
||||||
|
|
||||||
# this should succeed if the password is correct
|
# this should succeed if the password was correct
|
||||||
|
# curl presents the cookie from the previous request
|
||||||
curl -v \
|
curl -v \
|
||||||
-b ${COOKIEJAR} \
|
-b ${COOKIEJAR} \
|
||||||
${URL}/api/login
|
${URL}/api/login
|
||||||
|
|
||||||
# create a 'private' folder first.
|
# create a 'private' folder first for your server, and
|
||||||
# this should fail since credentials were not presented
|
# put a file `secret.txt` in it.
|
||||||
|
# this should fail since credentials were not presented in the request
|
||||||
curl -v \
|
curl -v \
|
||||||
${URL}/private/secret.txt
|
${URL}/private/secret.txt
|
||||||
|
|
||||||
# this should succeed since credentials were presented
|
# this should succeed since credentials are included
|
||||||
curl -v \
|
curl -v \
|
||||||
-b ${COOKIEJAR} \
|
-b ${COOKIEJAR} \
|
||||||
${URL}/private/secret.txt
|
${URL}/private/secret.txt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user