-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurls.sh
executable file
·145 lines (119 loc) · 5.2 KB
/
curls.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
domain=$1
function call() {
res=`curl -s --data "$1" $domain/engine/api/$2 | jq -r '.success'`
echo $res
if [ "$res" == "$3" ]
then
echo 'passed!'
else
echo 'failed!'
fi
}
function get_token() {
# Get token from checkin API
token=`curl -s --data "$1" $domain/engine/api/checkin_data | jq -r '.user_info.user_token'`
echo $token
if [ ${#token} -gt 0 ]
then
echo "passed!"
else
echo "failed!"
fi
}
function checkout() {
# Get token from checkin API
token=`curl -s --data "token=$token" $domain/engine/api/checkout_data | jq -r '.user_info.user_token'`
echo $token
if [ ${#token} -gt 0 ]
then
echo "passed!"
else
echo "failed!"
fi
}
function send_email_token() {
#test send_email token
email_token=`curl -s --data "$1" $domain/engine/api/send_email_token | jq -r '.success'`
echo $email_token
if [ "$email_token" == "Email sent with success." ]
then
echo 'passed!'
else
echo 'failed!'
fi
}
function test_manage_user() {
get_token "user=teste&pwd=@bC12345"
call "user=teste&fname=teste_new&lname=teste_new&[email protected]&stayin=true&token=$token" "update_user" "User information updated successfully."
call "user=teste&token=$token" "delete_user" "User deleted with success."
}
function test_signup() {
call "user=teste&pwd=@bC12345&fname=teste&lname=teste&[email protected]" "signup_data" "User signed up with success."
get_token "user=teste&pwd=@bC12345"
if [ "$token" == "null" ]
then
echo 'null token!'
else
call "token=$token" "read_user_info" "User info read successfully."
checkout "token=$token"
fi
}
function test_favorite() {
get_token "user=teste&pwd=@bC12345"
call "username=teste&resource_category=Software&resource_name=Favorites&max=10&token=$token" "create_authorisation" "Rule successfully created."
call "username=teste&item_id=l&item_type=a&city_id=1&country_id=2&favorite_id=b&data=aaa&token=$token" "create_favorite" "Favorite association successfully created."
call "username=teste&city_id=1&country_id=2&token=$token" "read_favorite" "Favorite association successfully read."
call "username=teste&token=$token" "read_favorites" "Favorite association successfully read."
call "username=teste&token=errado" "read_favorites" "Invalid token."
call "username=errado&token=$token" "read_favorites" "Invalid username."
call "username=teste&item_id=b&token=$token" "delete_favorite" "Favorite association successfully deleted."
#call "username=teste&item_id=b&token=$token" "delete_favorite" "Favorite association successfully deleted."
}
function test_email() {
send_email_token "username=teste2&[email protected]"
call "username=teste2&[email protected]&token=$email_token" "email_confirmation" "User email confirmed with success."
}
function test_email_association() {
get_token "user=teste2&pwd=@bC12345"
call "username=teste2&[email protected]&token=$token" "create_email" "Email association successfully created."
# test now if system detects repetition
call "username=teste2&[email protected]&token=$token" "create_email" "Invalid email."
call "username=teste2&token=$token" "read_emails" "Email association successfully read."
call "username=teste2&[email protected]&token=$token" "delete_email" "Email association successfully deleted."
}
function test_email_checkin() {
get_token "user=teste2&pwd=@bC12345"
call "username=teste2&[email protected]&token=$token" "create_email" "Email association successfully created."
# next call returns user info and corresponding token
call "[email protected]" "email_checkin" "Email checkin with success."
}
function test_authorisation() {
get_token "user=teste2&pwd=@bC12345"
call "username=teste2&resource_category=teste&resource_name=teste&max=10&token=$token" "create_authorisation" "Rule successfully created."
call "username=teste2&token=$token" "read_authorisations" "Rules read successfully."
call "username=teste2&resource_category=teste&resource_name=teste&token=$token" "read_authorisation" "Rule information read successfully."
call "username=teste2&resource_category=teste&resource_name=teste&max=20&token=$token" "update_authorisation" "Rule successfully updated."
call "username=teste2&resource_category=teste&resource_name=teste&token=$token" "delete_authorisation" "Rule successfully deleted."
}
function test_use_resource() {
get_token "user=teste2&pwd=@bC12345"
call "username=teste2&resource_name=teste&resource_category=teste&max=10&token=$token" "create_authorisation" "Rule successfully created."
call "username=teste2&resource_name=teste&resource_category=teste&token=$token" "use_resource" "User is authorised."
call "username=teste2&token=$token" "read_accounting" "User accounting information read successfully."
}
function test_forgot_password() {
call "username=teste2&[email protected]" "forgot_password" "Email sent with success."
}
function test_infra() {
call "username=teste2&principal=teste&secret=teste" "insert_data_infra" "Infra data successfully created."
call "username=teste2&pwd=@bC12345" "checkin_data_infra" "Infra data successfully read."
}
#test_signup
test_favorite
#test_email_association
#test_email
#test_use_resource
#test_manage_user
#test_forgot_password
#test_infra