forked from MLH-Fellowship/sre-portfolio-site
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_endpoints.sh
executable file
·44 lines (34 loc) · 916 Bytes
/
test_endpoints.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
if [[ "$1" -eq "" ]]
then
URL="https://autumnchiu.duckdns.org"
else
URL=$1
fi
ROUTES=("/" "/blog/" "/health/" "/mlh/" "/mlh/Experience/" "/mlh/Projects/" "/mlh/Accomplishments/" "/mlh/register/" "/mlh/login/")
EXIT=0
CURL_CMD='curl -s -o /dev/null -w "%{http_code}"'
HEAD="-I"
POST='-X POST -d "username=JonSmith&password=pw123"'
check_route () {
if [[ $RESPONSE -eq 200 || $RESPONSE -eq 418 ]]
then
echo "response $RESPONSE ok"
else
echo "response $RESPONSE not good"
EXIT=1
fi
}
for ROUTE in ${ROUTES[@]}; do
REQUEST=$URL$ROUTE
echo "curling $REQUEST"
RESPONSE=$(eval $CURL_CMD $HEAD $REQUEST)
check_route
done
echo "curling register POST ${URL}/mlh/register/"
RESPONSE=$(eval $CURL_CMD $POST "${URL}/mlh/register/")
check_route
echo "curling login POST ${URL}/mlh/login/"
RESPONSE=$(eval $CURL_CMD $POST "${URL}/mlh/login/")
check_route
exit $EXIT