-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·109 lines (89 loc) · 6.86 KB
/
test.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
#!/bin/bash
#
# simple tests for the endpoints using CURL
# asuming there is user Bob having some relevant data store in his account
RED="\033[0;31m'"
GREEN="\033[0;32m"
WHITE="\033[0m"
function cecho
{
if [[ $1 == "r" ]]; then
echo -e "${RED}"
echo -n "$2"
elif [[ $1 == "g" ]]; then
echo -e "${GREEN}"
echo -n "$2"
else
echo -e "${WHITE}"
echo -n "$2"
fi
echo -e "${WHITE}"
echo -e "___________________________________________________________"
}
printf "\033c"
#
## Test successful 401 responses from calling endpoints without an API key
#
cecho w "TEST 401 response"
echo "Check 401 on /social-networks"
response=$(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:2222/v1/social-networks")
if [[ $response == 401 ]];then cecho g "test pass"; else cecho r "test failed expected response 401 actual response: $response"; fi
echo "Check 401 on /resolve/social/{network}/{username}"
response=$(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:2222/v1/resolve/social/email/bob@example.com")
if [[ $response == 401 ]];then cecho g "test pass"; else cecho r "test failed expected response 401 actual response: $response"; fi
echo "Check 401 on /resolve/qrcode/{network}/{username}"
response=$(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:2222/v1/resolve/qrcode/email/bob@example.com")
if [[ $response == 401 ]];then cecho g "test pass"; else cecho r "test failed expected response 401 actual response: $response"; fi
echo "Check 401 on /resolve/qrcode/html/{network}/{username}"
response=$(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:2222/v1/resolve/qrcode/html/email/bob@example.com")
if [[ $response == 401 ]];then cecho g "test pass"; else cecho r "test failed expected response 401 actual response: $response"; fi
echo "Check 401 on /resolve/xrplaccount/{xrplaccount}/{tag}"
response=$(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:2222/v1/resolve/xrplaccount/rAsDfasdfADFssadfADFasdfDFsdv/55")
if [[ $response == 401 ]];then cecho g "test pass"; else cecho r "test failed expected response 401 actual response: $response"; fi
echo "Check 401 on /resolve/user/{slug}"
response=$(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:2222/v1/resolve/user/bob")
if [[ $response == 401 ]];then cecho g "test pass"; else cecho r "test failed expected response 401 actual response: $response"; fi
#
## Test successful responses from calling endpoints without an API key
#
cecho w "TEST 200 response"
echo "Check 200 on /social-networks"
response=$(curl --write-out %{http_code} --silent --output /dev/null -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/social-networks")
if [[ $response == 200 ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/social/{network}/{username}"
response=$(curl --write-out %{http_code} --silent --output /dev/null -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/social/email/bob@example.com")
if [[ $response == 200 ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/qrcode/{network}/{username}"
response=$(curl --write-out %{http_code} --silent --output /dev/null -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/qrcode/email/bob@example.com")
if [[ $response == 200 ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/qrcode/html/{network}/{username}"
response=$(curl --write-out %{http_code} --silent --output /dev/null -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/qrcode/html/email/bob@example.com")
if [[ $response == 200 ]];then cecho g "test pass"; else echo "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/xrplaccount/{xrplaccount}/{tag}"
response=$(curl --write-out %{http_code} --silent --output /dev/null -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/xrplaccount/rAsDfasdfADFssadfADFasdfDFsdv/55")
if [[ $response == 200 ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/user/{slug}"
response=$(curl --write-out %{http_code} --silent --output /dev/null -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/user/bob")
if [[ $response == 200 ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
#
## Test successful responses from calling endpoints without an API key
#
cecho w "TEST actual response data"
echo "Check 200 on /social-networks"
response=$(curl --silent -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/social-networks")
if [[ "${response[@]}" =~ "email" ]];then cecho g "test pass"; else cecho r "test failed expected response 'email website' actual response: $response"; fi
echo "Check 200 on /resolve/social/{network}/{username}"
response=$(curl --silent -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/social/email/bob@example.com")
if [[ "${response[@]}" =~ "bob" ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/qrcode/{network}/{username}"
response=$(curl --silent -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/qrcode/email/bob@example.com")
if [[ "${response[@]}" =~ "qrcode" ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/qrcode/html/{network}/{username}"
response=$(curl --silent -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/qrcode/html/email/bob@example.com")
if [[ "${response[@]}" =~ "qrcode" ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/xrplaccount/{xrplaccount}/{tag}"
response=$(curl --silent -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/xrplaccount/rAsDfasdfADFssadfADFasdfDFsdv/55")
if [[ "${response[@]}" =~ "bob" ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi
echo "Check 200 on /resolve/user/{slug}"
response=$(curl --silent -H "XRPLNS-KEY: 8715785b8139ba56eae548e98d24ef65214b09c4" "http://127.0.0.1:2222/v1/resolve/user/bob")
if [[ "${response[@]}" =~ "bob" ]];then cecho g "test pass"; else cecho r "test failed expected response 200 actual response: $response"; fi