Skip to content

Commit a4d99a4

Browse files
committed
test: Add a system test to check tedge cert create-cert with device profile
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
1 parent 0c812d1 commit a4d99a4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/RobotFramework/tests/tedge/certificate_signing_request.robot

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,39 @@ Generate CSR without an existing certificate and private key
5252
... openssl req -in /etc/tedge/device-certs/tedge.csr -pubkey -noout | openssl md5
5353
Should Be Equal ${output_private_key_md5} ${output_csr_md5}
5454

55+
Generate CSR using the device-id from an existing certificate and private key of cloud profile
56+
[Tags] \#3315
57+
[Setup] Setup With Self-Signed Certificate
58+
59+
${second_device_sn}= Catenate SEPARATOR=_ ${DEVICE_SN} second
60+
Execute Command
61+
... tedge config set c8y.device.cert_path --profile second /etc/tedge/device-certs/tedge@second-certificate.pem
62+
Execute Command
63+
... tedge config set c8y.device.key_path --profile second /etc/tedge/device-certs/tedge@second-key.pem
64+
Execute Command tedge cert create --device-id ${second_device_sn} c8y --profile second
65+
66+
${hash_before_cert}= Execute Command md5sum /etc/tedge/device-certs/tedge@second-certificate.pem
67+
${hash_before_private_key}= Execute Command md5sum /etc/tedge/device-certs/tedge@second-key.pem
68+
69+
Execute Command sudo tedge cert create-csr c8y --profile second
70+
71+
${output_cert_subject}= Execute Command
72+
... openssl x509 -noout -subject -in /etc/tedge/device-certs/tedge@second-certificate.pem
73+
${output_csr_subject}= Execute Command
74+
... openssl req -noout -subject -in /etc/tedge/device-certs/tedge.csr
75+
Should Be Equal ${output_cert_subject} ${output_csr_subject}
76+
77+
${output_private_key_md5}= Execute Command
78+
... openssl pkey -in /etc/tedge/device-certs/tedge@second-key.pem -pubout | openssl md5
79+
${output_csr_md5}= Execute Command
80+
... openssl req -in /etc/tedge/device-certs/tedge.csr -pubkey -noout | openssl md5
81+
Should Be Equal ${output_private_key_md5} ${output_csr_md5}
82+
83+
${hash_after_cert}= Execute Command md5sum /etc/tedge/device-certs/tedge@second-certificate.pem
84+
${hash_after_private_key}= Execute Command md5sum /etc/tedge/device-certs/tedge@second-key.pem
85+
Should Be Equal ${hash_before_cert} ${hash_after_cert}
86+
Should Be Equal ${hash_before_private_key} ${hash_after_private_key}
87+
5588

5689
*** Keywords ***
5790
Setup With Self-Signed Certificate

0 commit comments

Comments
 (0)