Skip to content

Commit

Permalink
test: add and update regarding device.id and tedge connect
Browse files Browse the repository at this point in the history
* tedge connect c8y uses device.id directly.
The CN from certificate is no longer used to determine device.id
* tedge connect c8y returns an error if device.id mismatches
the certificate's CN when auth method is certificate

Signed-off-by: Rina Fujino <[email protected]>
  • Loading branch information
rina23q committed Jan 10, 2025
1 parent 22cb0da commit 8fd8ad8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Register and Use SmartREST 1.0. Templates
[Arguments] ${use_builtin_bridge}
Custom Setup use_builtin_bridge=${use_builtin_bridge}

# device.id should be set by tedge config and confirm the test doesn't use certificate
Execute Command tedge config set device.id ${DEVICE_SN}
Execute Command tedge cert remove
File Should Not Exist /etc/tedge/device-certs/tedge-certificate.pem
File Should Not Exist /etc/tedge/device-certs/tedge-private-key.pem

${TEMPLATE_XID}= Get Random Name prefix=TST_Template
Set Test Variable $TEMPLATE_XID
Execute Command tedge config set c8y.smartrest1.templates "${TEMPLATE_XID}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
*** Settings ***
Resource ../../resources/common.resource
Library Cumulocity
Library ThinEdgeIO
Library ../../.venv/lib/python3.11/site-packages/robot/libraries/String.py

Suite Teardown Get Logs
Test Setup Custom Setup

Test Tags theme:c8y theme:cli


*** Test Cases ***
Certificate's CN must match device.id
${cert_output}= Execute Command tedge cert show
Should Contain ${cert_output} ${DEVICE_SN}

Execute Command tedge config set device.id foo
${output}= Execute Command tedge connect c8y
... exp_exit_code=1
... stdout=False
... stderr=True
... timeout=0
... strip=True
Should Be Equal
... ${output}
... error: device.id 'foo' mismatches to the device certificate's CN '${DEVICE_SN}'


*** Keywords ***
Custom Setup
${device_sn}= Setup skip_bootstrap=${True}
Execute Command ./bootstrap.sh --no-connect
Set Test Variable $DEVICE_SN ${device_sn}

0 comments on commit 8fd8ad8

Please sign in to comment.