-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathauth.sh
154 lines (102 loc) · 4.15 KB
/
auth.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
142
143
144
145
146
147
148
149
150
151
152
153
154
set -euo pipefail
source integration_tests/cli/common.sh
random_string user
cmd="(echo $passphrase; echo $passphrase) | dcld keys add $user"
result="$(bash -c "$cmd")"
user_address=$(echo $passphrase | dcld keys show $user -a)
user_pubkey=$(echo $passphrase | dcld keys show $user -p)
random_string user2
cmd="(echo $passphrase; echo $passphrase) | dcld keys add $user2"
result="$(bash -c "$cmd")"
user_address2=$(echo $passphrase | dcld keys show $user2 -a)
# 1. check non-existent values via light client when no entry added
echo "check non-existent values via light client when no entry added"
test_divider
# connect to light client proxy
dcld config node tcp://localhost:26620
sleep 20
echo "Query non existent account"
result=$(execute_with_retry "dcld query auth account --address=$user_address")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent proposed account"
result=$(execute_with_retry "dcld query auth proposed-account --address=$user_address")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent proposed account to revoke"
result=$(execute_with_retry "dcld query auth proposed-account-to-revoke --address=$user_address")
echo "$result"
check_response "$result" "Not Found"
test_divider
# 2. list queries should return a warning via light client
echo "list queries should return a warning via light client"
test_divider
echo "Request all accounts"
result=$(execute_with_retry "dcld query auth all-accounts")
echo "$result"
check_response "$result" "List queries don't work with a Light Client Proxy"
test_divider
echo "Request all proposed accounts"
result=$(execute_with_retry "dcld query auth all-proposed-accounts")
echo "$result"
check_response "$result" "List queries don't work with a Light Client Proxy"
test_divider
echo "Request all proposed accounts to revoke"
result=$(execute_with_retry "dcld query auth all-proposed-accounts-to-revoke")
echo "$result"
check_response "$result" "List queries don't work with a Light Client Proxy"
test_divider
# 3. write entries
echo "write entries"
test_divider
# write requests can be sent via Full Node only
dcld config node tcp://localhost:26657
vid=$RANDOM
echo "Jack proposes account for $user"
result=$(echo $passphrase | dcld tx auth propose-add-account --address="$user_address" --pubkey="$user_pubkey" --roles="NodeAdmin" --from jack --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
test_divider
echo "Alice approves account for \"$user\""
result=$(echo $passphrase | dcld tx auth approve-add-account --address="$user_address" --from alice --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
test_divider
# 4. check existent values via light client
echo "check existent values via light client"
test_divider
# connect to light client proxy
dcld config node tcp://localhost:26620
sleep 5
echo "Get $user account"
result=$(execute_with_retry "dcld query auth account --address=$user_address")
check_response "$result" "\"address\": \"$user_address\""
test_divider
# 5. check non-existent values via light client when entry added
echo "check non-existent values via light client when entry added"
test_divider
echo "Query non existent account"
result=$(execute_with_retry "dcld query auth account --address=$user_address2")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent proposed account"
result=$(execute_with_retry "dcld query auth proposed-account --address=$user_address2")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent proposed account to revoke"
result=$(execute_with_retry "dcld query auth proposed-account-to-revoke --address=$user_address2")
echo "$result"
check_response "$result" "Not Found"
test_divider
# 6. try to write via light client proxy
echo "try to write via light client proxy"
test_divider
echo "Add vendorinfo"
result=$(echo $passphrase | dcld tx auth propose-add-account --address="$user_address" --pubkey="$user_pubkey" --roles="NodeAdmin" --from $user_address --yes)
echo "$result"
check_response "$result" "Write requests don't work with a Light Client Proxy"
test_divider