Skip to content

Expand test coverage for Sodium public commands - #73

Open
Marius Storhaug (MariusStorhaug) wants to merge 2 commits into
mainfrom
fantastic-winner
Open

Expand test coverage for Sodium public commands#73
Marius Storhaug (MariusStorhaug) wants to merge 2 commits into
mainfrom
fantastic-winner

Conversation

@MariusStorhaug

Copy link
Copy Markdown
Member

Summary

The existing Pester tests were a solid foundation (29 tests) but not yet production-level. This change expands coverage to 41 tests and adds a BeforeAll setup block so the test file fails fast with a helpful message when the module is not available.

What changed

  • Added BeforeAll block that imports src\Sodium.psd1 when the module is not already loaded, or throws a clear build-first message.
  • Added parameter-validation tests for mandatory/null/empty parameters on ConvertTo-SodiumSealedBox, ConvertFrom-SodiumSealedBox, and Get-SodiumPublicKey.
  • Added edge-case crypto tests:
    • Unicode and special-character round-trip.
    • Sealed-box non-determinism (each encryption must produce a different ciphertext).
    • Decryption fails when the public key does not belong to the private key.
    • Rejection of base64 keys that are the wrong length.
  • Added key-pair output-shape and randomness tests.

Test results

Tests Passed: 41, Failed: 0, Skipped: 0

Notes / follow-up opportunities

  • ConvertTo-SodiumSealedBox rejects empty strings because Message is mandatory. If empty messages should be supported, the function needs [AllowEmptyString()].
  • Get-SodiumPublicKey -AsByteArray claims to preserve the byte array as a single pipeline object via a unary comma, but piping it into ForEach-Object still enumerates the 32 bytes. This may warrant a separate code fix.
  • The example at examples/CreateGitHubSecret.ps1 uses -Secret, but the actual parameter is -Message; the example is currently out of sync with the code.

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

- Add BeforeAll block to fail fast with a helpful message when the Sodium
  module is not loaded and no source manifest exists.
- Cover parameter validation: null/empty Message, PublicKey, and PrivateKey.
- Add Unicode/special-character round-trip and sealed-box non-determinism tests.
- Add wrong-length base64 key rejection and mismatched public/private key tests.
- Extend key-pair tests to verify output shape and randomness.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Pattern Description
^src/ Matches files where path matches this pattern
^README\.md$ Matches files where path matches this pattern
^PSModule/ Matches files where path matches this pattern

Build, test, and publish stages will be skipped for this PR.

If you believe this is incorrect, please verify that your changes are in the correct locations.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Super-linter summary

Language Validation result
CHECKOV Pass ✅
CSHARP Pass ✅
GITHUB_ACTIONS Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
MARKDOWN Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
YAML Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@MariusStorhaug
Marius Storhaug (MariusStorhaug) marked this pull request as ready for review August 3, 2026 01:01
Updates the reusable workflow pin from v6.1.13 to v6.1.16 to pick up the
latest fixes and improvements.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

No Significant Changes Detected

This PR does not contain changes to files that would trigger a new release:

Pattern Description
^src/ Matches files where path matches this pattern
^README\.md$ Matches files where path matches this pattern
^PSModule/ Matches files where path matches this pattern

Build, test, and publish stages will be skipped for this PR.

If you believe this is incorrect, please verify that your changes are in the correct locations.

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