1
+ set -euo pipefail
2
+ source integration_tests/cli/common.sh
3
+
4
+ noc_root_cert_1_path=" integration_tests/constants/noc_root_cert_1"
5
+ noc_root_cert_1_subject=" MFUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDjAMBgNVBAMMBU5PQy0x"
6
+ noc_root_cert_1_subject_key_id=" 44:EB:4C:62:6B:25:48:CD:A2:B3:1C:87:41:5A:08:E7:2B:B9:83:26"
7
+ noc_root_cert_1_serial_number=" 217369606639495620450806539821422258966012867792"
8
+ noc_root_cert_1_subject_as_text=" CN=NOC-1,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU"
9
+
10
+ noc_root_cert_2_path=" integration_tests/constants/noc_root_cert_2"
11
+ noc_root_cert_2_subject=" MFUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDjAMBgNVBAMMBU5PQy0y"
12
+ noc_root_cert_2_subject_key_id=" CF:E6:DD:37:2B:4C:B2:B9:A9:F2:75:30:1C:AA:B1:37:1B:11:7F:1B"
13
+ noc_root_cert_2_serial_number=" 720401643293243343104681760462974770802745092176"
14
+ noc_root_cert_2_subject_as_text=" CN=NOC-2,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU"
15
+
16
+ noc_root_cert_3_path=" integration_tests/constants/noc_root_cert_3"
17
+ noc_root_cert_3_subject=" MFUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDjAMBgNVBAMMBU5PQy0z"
18
+ noc_root_cert_3_subject_key_id=" 88:0D:06:D9:64:22:29:34:78:7F:8C:3B:AE:F5:08:93:86:8F:0D:20"
19
+ noc_root_cert_3_serial_number=" 38457288443253426021793906708335409501754677187"
20
+ noc_root_cert_3_subject_as_text=" CN=NOC-3,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU"
21
+
22
+ trustee_account=" jack"
23
+ second_trustee_account=" alice"
24
+
25
+ vid_in_hex_format=0x6006
26
+ vid=24582
27
+
28
+ vendor_account=vendor_account_$vid_in_hex_format
29
+ echo " Create Vendor account - $vendor_account "
30
+ create_new_vendor_account $vendor_account $vid_in_hex_format
31
+
32
+ vid_2_in_hex_format=0x125D
33
+ vid_2=4701
34
+
35
+ vendor_account_2=vendor_account_$vid_2_in_hex_format
36
+ echo " Create Vendor account - $vendor_account_2 "
37
+ create_new_vendor_account $vendor_account_2 $vid_2_in_hex_format
38
+
39
+
40
+ test_divider
41
+
42
+ echo " Request NOC certificate by VID must be empty"
43
+ result=$( dcld query pki noc-x509-root-certs --vid=" $vid " )
44
+ check_response " $result " " Not Found"
45
+ response_does_not_contain " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
46
+ response_does_not_contain " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
47
+ response_does_not_contain " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
48
+ response_does_not_contain " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
49
+ echo $result | jq
50
+
51
+ test_divider
52
+
53
+ echo " Request all NOC root certificates must be empty"
54
+ result=$( dcld query pki all-noc-x509-root-certs)
55
+ check_response " $result " " \[\]"
56
+ response_does_not_contain " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
57
+ response_does_not_contain " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
58
+ response_does_not_contain " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
59
+ response_does_not_contain " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
60
+ echo $result | jq
61
+
62
+ test_divider
63
+
64
+ echo " Request approved certificate must be empty"
65
+ result=$( dcld query pki x509-cert --subject=" $noc_root_cert_1_subject " --subject-key-id=" $noc_root_cert_1_subject_key_id " )
66
+ check_response " $result " " Not Found"
67
+ response_does_not_contain " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
68
+ response_does_not_contain " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
69
+ response_does_not_contain " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
70
+ response_does_not_contain " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
71
+ echo $result | jq
72
+
73
+ test_divider
74
+
75
+ echo " Request all certificates by subject must be empty"
76
+ result=$( dcld query pki all-subject-x509-certs --subject=" $noc_root_cert_1_subject " )
77
+ check_response " $result " " Not Found"
78
+ response_does_not_contain " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
79
+ response_does_not_contain " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
80
+ echo $result | jq
81
+
82
+ test_divider
83
+
84
+ echo " Request all certificates by subjectKeyId must be empty"
85
+ result=$( dcld query pki x509-cert --subject-key-id=" $noc_root_cert_1_subject_key_id " )
86
+ check_response " $result " " Not Found"
87
+ response_does_not_contain " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
88
+ response_does_not_contain " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
89
+ response_does_not_contain " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
90
+ response_does_not_contain " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
91
+ echo $result | jq
92
+
93
+ test_divider
94
+
95
+ echo " Try to add inermidiate cert using add-noc-x509-root-cert command"
96
+ intermediate_path=" integration_tests/constants/intermediate_cert"
97
+ result=$( echo " $passphrase " | dcld tx pki add-noc-x509-root-cert --certificate=" $intermediate_path " --from $vendor_account --yes)
98
+ check_response " $result " " \" code\" : 414"
99
+
100
+ echo " Add first NOC root certificate by vendor with VID = $vid "
101
+ result=$( echo " $passphrase " | dcld tx pki add-noc-x509-root-cert --certificate=" $noc_root_cert_1_path " --from $vendor_account --yes)
102
+ check_response " $result " " \" code\" : 0"
103
+
104
+ echo " Add second NOC root certificate by vendor with VID = $vid "
105
+ result=$( echo " $passphrase " | dcld tx pki add-noc-x509-root-cert --certificate=" $noc_root_cert_2_path " --from $vendor_account --yes)
106
+ check_response " $result " " \" code\" : 0"
107
+
108
+ echo " Add third NOC root certificate by vendor with VID = $vid_2 "
109
+ result=$( echo " $passphrase " | dcld tx pki add-noc-x509-root-cert --certificate=" $noc_root_cert_3_path " --from $vendor_account_2 --yes)
110
+ check_response " $result " " \" code\" : 0"
111
+
112
+ test_divider
113
+
114
+ echo " Request NOC root certificate by VID"
115
+ result=$( dcld query pki noc-x509-root-certs --vid=" $vid " )
116
+ echo $result | jq
117
+ check_response " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
118
+ check_response " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
119
+ check_response " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
120
+ check_response " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
121
+ check_response " $result " " \" subject\" : \" $noc_root_cert_2_subject \" "
122
+ check_response " $result " " \" subjectKeyId\" : \" $noc_root_cert_2_subject_key_id \" "
123
+ check_response " $result " " \" serialNumber\" : \" $noc_root_cert_2_serial_number \" "
124
+ check_response " $result " " \" subjectAsText\" : \" $noc_root_cert_2_subject_as_text \" "
125
+ check_response " $result " " \" vid\" : $vid "
126
+
127
+ test_divider
128
+
129
+ echo " Request All NOC root certificate"
130
+ result=$( dcld query pki all-noc-x509-root-certs)
131
+ echo $result | jq
132
+ check_response " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
133
+ check_response " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
134
+ check_response " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
135
+ check_response " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
136
+ check_response " $result " " \" subject\" : \" $noc_root_cert_2_subject \" "
137
+ check_response " $result " " \" subjectKeyId\" : \" $noc_root_cert_2_subject_key_id \" "
138
+ check_response " $result " " \" serialNumber\" : \" $noc_root_cert_2_serial_number \" "
139
+ check_response " $result " " \" subjectAsText\" : \" $noc_root_cert_2_subject_as_text \" "
140
+ check_response " $result " " \" subject\" : \" $noc_root_cert_3_subject \" "
141
+ check_response " $result " " \" subjectKeyId\" : \" $noc_root_cert_3_subject_key_id \" "
142
+ check_response " $result " " \" serialNumber\" : \" $noc_root_cert_3_serial_number \" "
143
+ check_response " $result " " \" subjectAsText\" : \" $noc_root_cert_3_subject_as_text \" "
144
+ check_response " $result " " \" vid\" : $vid "
145
+ check_response " $result " " \" vid\" : $vid_2 "
146
+
147
+ test_divider
148
+
149
+ echo " Request NOC root certificate by Subject and SubjectKeyID"
150
+ result=$( dcld query pki x509-cert --subject=" $noc_root_cert_1_subject " --subject-key-id=" $noc_root_cert_1_subject_key_id " )
151
+ echo $result | jq
152
+ check_response " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
153
+ check_response " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
154
+ check_response " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
155
+ check_response " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
156
+ check_response " $result " " \" approvals\" : \\ [\\ ]"
157
+
158
+ test_divider
159
+
160
+ echo " Request NOC root certificate by Subject"
161
+ result=$( dcld query pki all-subject-x509-certs --subject=" $noc_root_cert_1_subject " )
162
+ echo $result | jq
163
+ check_response " $result " " \" $noc_root_cert_1_subject \" "
164
+ check_response " $result " " \" $noc_root_cert_1_subject_key_id \" "
165
+
166
+ test_divider
167
+
168
+ echo " Request NOC root certificate by SubjectKeyID"
169
+ result=$( dcld query pki x509-cert --subject-key-id=" $noc_root_cert_1_subject_key_id " )
170
+ echo $result | jq
171
+ check_response " $result " " \" subject\" : \" $noc_root_cert_1_subject \" "
172
+ check_response " $result " " \" subjectKeyId\" : \" $noc_root_cert_1_subject_key_id \" "
173
+ check_response " $result " " \" serialNumber\" : \" $noc_root_cert_1_serial_number \" "
174
+ check_response " $result " " \" subjectAsText\" : \" $noc_root_cert_1_subject_as_text \" "
175
+
176
+ test_divider
0 commit comments