Skip to content

test: test luks encryption key#547

Merged
richm merged 1 commit intolinux-system-roles:mainfrom
richm:test-fix-ekey
Jul 23, 2025
Merged

test: test luks encryption key#547
richm merged 1 commit intolinux-system-roles:mainfrom
richm:test-fix-ekey

Conversation

@richm
Copy link
Copy Markdown
Contributor

@richm richm commented Jul 23, 2025

The storage_test_volume.encryption_key comes from the same variable that
is used to write the key to the crypttab - so change the test to test
against the original value passed in to the role.

Signed-off-by: Rich Megginson [email protected]

Summary by Sourcery

Improve LUKS encryption tests to verify against the original key and expand coverage across disk interfaces

Tests:

  • Update encryption assertion to use __test_encryption_key variable for crypttab verification
  • Add auto-generated playbooks for NVMe and SCSI variants of mixed and mixed_2 LUKS tests

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 23, 2025

Reviewer's Guide

This PR refactors the LUKS encryption verification tests to assert against the original key passed to the role and expands test coverage by auto-generating interface-specific playbooks for nvme and scsi scenarios.

File-Level Changes

Change Details Files
Assert crypttab entry against the original encryption key
  • Switched expected crypttab key file variable to use __test_encryption_key with a fallback
  • Added __test_encryption_key var injection in LUKS test include tasks
tests/test-verify-volume-encryption.yml
tests/tests_luks.yml
Generate interface-specific LUKS mixed test playbooks
  • Auto-generated playbooks for nvme and scsi for mixed and mixed_2 tests
  • Set storage_test_use_interface fact before importing the generic playbook
tests/tests_luks_mixed_nvme_generated.yml
tests/tests_luks_mixed_scsi_generated.yml
tests/tests_luks_mixed_2_nvme_generated.yml
tests/tests_luks_mixed_2_scsi_generated.yml

Possibly linked issues

  • #0: The PR adjusts a test's expected value for the encryption key in the crypttab entry, directly resolving the 'Incorrect key file' assertion failure reported in the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @richm - I've reviewed your changes - here's some feedback:

  • Consider consolidating the autogenerated per-interface test playbooks into a single parametric playbook (or loop over interfaces) to reduce duplication and maintenance overhead.
  • Ensure that __test_encryption_key is explicitly defined (or defaults are handled) in every test that references it, so you don’t run into undefined-variable errors in other scenarios.
  • Double-check that using '-' as the default for storage_test_volume.encryption_key matches the real crypttab behavior when no key is provided, and add a test case for the empty‐key path if needed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider consolidating the autogenerated per-interface test playbooks into a single parametric playbook (or loop over interfaces) to reduce duplication and maintenance overhead.
- Ensure that __test_encryption_key is explicitly defined (or defaults are handled) in every test that references it, so you don’t run into undefined-variable errors in other scenarios.
- Double-check that using '-' as the default for storage_test_volume.encryption_key matches the real crypttab behavior when no key is provided, and add a test case for the empty‐key path if needed.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.66%. Comparing base (59fd1c6) to head (e1b76ad).
Report is 73 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (59fd1c6) and HEAD (e1b76ad). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (59fd1c6) HEAD (e1b76ad)
sanity 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #547      +/-   ##
==========================================
- Coverage   16.54%   10.66%   -5.89%     
==========================================
  Files           2        8       +6     
  Lines         284     1960    +1676     
  Branches       79        0      -79     
==========================================
+ Hits           47      209     +162     
- Misses        237     1751    +1514     
Flag Coverage Δ
sanity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The storage_test_volume.encryption_key comes from the same variable that
is used to write the key to the crypttab - so change the test to test
against the original value passed in to the role.

Signed-off-by: Rich Megginson <[email protected]>
@richm richm merged commit 4436969 into linux-system-roles:main Jul 23, 2025
26 of 29 checks passed
@richm richm deleted the test-fix-ekey branch July 23, 2025 22:19
@richm
Copy link
Copy Markdown
Contributor Author

richm commented Jul 23, 2025

This is the test for #546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant