-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathcompliance.sh
225 lines (155 loc) · 6.69 KB
/
compliance.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
set -euo pipefail
source integration_tests/cli/common.sh
# 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 10
vid=$RANDOM
pid=$RANDOM
sv=$RANDOM
svs=$RANDOM
cd_certificate_id="123"
echo "Query non existent complianceinfo"
result=$(execute_with_retry "dcld query compliance compliance-info --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
#check_response "$result" "Not Found"
test_divider
echo "Query non existent certified"
result=$(execute_with_retry "dcld query compliance certified-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
#check_response "$result" "Not Found"
test_divider
echo "Query non existent revoked"
result=$(execute_with_retry "dcld query compliance revoked-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
#check_response "$result" "Not Found"
test_divider
echo "Query non existent provision"
result=$(execute_with_retry "dcld query compliance provisional-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
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 compliance infos"
result=$(execute_with_retry "dcld query compliance all-compliance-info")
echo "$result"
check_response "$result" "List queries don't work with a Light Client Proxy"
test_divider
echo "Request all certified"
result=$(execute_with_retry "dcld query compliance all-certified-models")
echo "$result"
check_response "$result" "List queries don't work with a Light Client Proxy"
test_divider
echo "Request all revoked"
result=$(execute_with_retry "dcld query compliance all-revoked-models")
echo "$result"
check_response "$result" "List queries don't work with a Light Client Proxy"
test_divider
echo "Request all provisional"
result=$(execute_with_retry "dcld query compliance all-provisional-models")
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
pid=$RANDOM
sv=$RANDOM
svs=$RANDOM
testing_result="http://first.place.com"
test_date="2020-11-24T10:00:00Z"
certification_date="2020-01-01T00:00:01Z"
vendor_account=vendor_account_$vid
echo "Create Vendor account - $vendor_account"
create_new_vendor_account $vendor_account $vid
test_divider
echo "Create CertificationCenter account"
create_new_account zb_account "CertificationCenter"
test_divider
echo "Add Model and a New Model Version with VID: $vid PID: $pid SV: $sv"
create_model_and_version $vid $pid $sv $svs $vendor_account
test_divider
echo "Certify Model with VID: $vid PID: $pid SV: ${sv} with zigbee certification"
result=$(echo "$passphrase" | dcld tx compliance certify-model --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=$svs --certificationType="zigbee" --certificationDate="$certification_date" --cdCertificateId="$cd_certificate_id" --cdVersionNumber=1 --from $zb_account --yes)
result=$(get_txn_result "$result")
echo "$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 "Query complianceinfo"
result=$(execute_with_retry "dcld query compliance compliance-info --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"softwareVersionCertificationStatus\": 2"
check_response "$result" "\"date\": \"$certification_date\""
check_response "$result" "\"certificationType\": \"zigbee\""
test_divider
echo "Query certified"
result=$(execute_with_retry "dcld query compliance certified-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
check_response "$result" "\"value\": true"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"vid\": $vid"
test_divider
echo "Query revoked"
result=$(execute_with_retry "dcld query compliance revoked-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
check_response "$result" "\"value\": false"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"vid\": $vid"
test_divider
echo "Query provision"
result=$(execute_with_retry "dcld query compliance provisional-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
check_response "$result" "\"value\": false"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"vid\": $vid"
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
vid=$RANDOM
pid=$RANDOM
sv=$RANDOM
svs=$RANDOM
echo "Query non existent complianceinfo"
result=$(execute_with_retry "dcld query compliance compliance-info --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent certified"
result=$(execute_with_retry "dcld query compliance certified-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent revoked"
result=$(execute_with_retry "dcld query compliance revoked-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent provision"
result=$(execute_with_retry "dcld query compliance provisional-model --vid=$vid --pid=$pid --softwareVersion=$sv --certificationType="zigbee"")
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 compliance info"
result=$(echo "$passphrase" | dcld tx compliance certify-model --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=$svs --certificationType="zigbee" --certificationDate="$certification_date" --cdCertificateId="$cd_certificate_id" --cdVersionNumber=1 --from $zb_account --yes)
echo "$result"
check_response "$result" "Write requests don't work with a Light Client Proxy"
test_divider