Skip to content

fix: add device.csr_path to cloud profiles#3441

Merged
Ruadhri17 merged 2 commits intothin-edge:mainfrom
Ruadhri17:fix-tedge-csr
Mar 6, 2025
Merged

fix: add device.csr_path to cloud profiles#3441
Ruadhri17 merged 2 commits intothin-edge:mainfrom
Ruadhri17:fix-tedge-csr

Conversation

@Ruadhri17
Copy link
Copy Markdown
Contributor

Proposed changes

As mentioned in #3413 user could not specified device.csr_path per cloud profile. This PR appends multi profile config with csr_path and replaces old approach of accessing config value in tedge cert create-csr.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request March 3, 2025 09:45 — with GitHub Actions Inactive
@Ruadhri17 Ruadhri17 added theme:c8y Theme: Cumulocity related topics theme:certificates Theme: Device certificate topics theme:aws Theme: AWS cloud related topics theme:az Theme: Azure IoT related topics bug Something isn't working and removed bug Something isn't working labels Mar 3, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 31.03448% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../tedge_config/src/tedge_config_cli/tedge_config.rs 34.61% 10 Missing and 7 partials ⚠️
crates/core/tedge/src/cli/certificate/cli.rs 0.00% 3 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
584 0 3 584 100 1h37m45.292914999s

Copy link
Copy Markdown
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for a system test. Can be added under /tests/RobotFramework/tests/tedge/certificate_signing_request.robot

@Ruadhri17 Ruadhri17 requested a review from a team as a code owner March 5, 2025 09:49
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
File Should Not Exist /etc/tedge/device-certs/tedge-private-key.pem

Execute Command
... tedge config set c8y.device.csr_path /etc/tedge/device-certs/example_dev_test0001-test1.csr
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces that are confusing robotframework ;-)

Suggested change
... tedge config set c8y.device.csr_path /etc/tedge/device-certs/example_dev_test0001-test1.csr
... tedge config set c8y.device.csr_path /etc/tedge/device-certs/example_dev_test0001-test1.csr

Execute Command
... tedge config set c8y.device.csr_path /etc/tedge/device-certs/example_dev_test0001-test1.csr

Execute Command sudo tedge cert create-csr
Copy link
Copy Markdown
Member

@rina23q rina23q Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the failing test, the error message makes sense. Since there is no device certificate nor explicitly device ID is provided by --device-id option, there is no way for the command to know the CN.
So, either provide a device ID as the error message says, or create a certificate beforehand.

sudo tedge cert create-csr returned an unexpected exit code stdout: stderr: Error: missing configuration parameter Caused by: No device ID is provided. Use --device-id <name> option to specify the device ID.

Also adding c8y argument is forgotten. With the following change, the test will pass (confirmed in my local env).

Suggested change
Execute Command sudo tedge cert create-csr
Execute Command sudo tedge cert create-csr c8y --device-id test-user

Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new test though? If not, then the --device-id is not a mandatory flag, as it can pick up the value from the existing certificate or manually set device.id etc.

Copy link
Copy Markdown
Member

@rina23q rina23q Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new test though?

=> It is.

If the test setup was with certificate, as @reubenmiller says, there would be no need to give --device-id. But I'd say it's ok to give --device-id and setup without cert. Not so important for the test purpose I think.

    [Setup]    Setup Without Certificate
    File Should Not Exist    /etc/tedge/device-certs/tedge-certificate.pem
    File Should Not Exist    /etc/tedge/device-certs/tedge-private-key.pem

Copy link
Copy Markdown
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request March 6, 2025 01:20 — with GitHub Actions Inactive
@Ruadhri17 Ruadhri17 enabled auto-merge March 6, 2025 01:20
@Ruadhri17 Ruadhri17 added this pull request to the merge queue Mar 6, 2025
Merged via the queue into thin-edge:main with commit 58f370e Mar 6, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:aws Theme: AWS cloud related topics theme:az Theme: Azure IoT related topics theme:c8y Theme: Cumulocity related topics theme:certificates Theme: Device certificate topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants