-
Notifications
You must be signed in to change notification settings - Fork 24
/
apidebug.sh
executable file
·48 lines (36 loc) · 1.21 KB
/
apidebug.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
45
46
47
48
#!/usr/bin/env bash
cookies=/tmp/bunk-testserver-cookies.txt
api_url="http://136.233.14.3:8282/CampusPortalSOA"
if [ "$1" == "-t" ] || [ "$1" == "--testserver" ] ; then
api_url="https://bunk-testserver.herokuapp.com"
fi
function login {
curl $1/login -s -c $cookies -X POST \
-H "Content-Type:application/json;charset=UTF-8" \
-d "{\"username\":\"$2\", \"password\":\"$3\",\"MemberType\":\"S\"}"
}
function registerationid {
curl $1/studentSemester/lov -s -b $cookies -X POST \
-H "Content-Type:application/json;charset=UTF-8"
}
function attendanceinfo {
curl $1/attendanceinfo -s -b $cookies -X POST \
-H "Content-Type:application/json;charset=UTF-8" \
-d "{\"registerationid\": \"$2\"}"
}
read -p "username: " username
read -sp "password: " password
echo -e "\n\nlogin - invalid credentials\n"
login $api_url invalid credentials
echo -e "\n\nregistration ids\n"
registerationid $api_url
echo -e "\n\nlogin - valid credentials\n"
login $api_url $username $password
echo -e "\n\nregistration ids\n"
registerationid $api_url
echo -e "\n"
read -p "registrationid: " registerationid
echo -e "\nattendance\n"
attendanceinfo $api_url $registerationid
echo -e "\n"
rm -f $cookies