Skip to content

test: expand Jwt test suite to production-level coverage - #40

Merged
Marius Storhaug (MariusStorhaug) merged 3 commits into
feat/13-implement-jwt-modulefrom
vigilant-guide
Aug 3, 2026
Merged

test: expand Jwt test suite to production-level coverage#40
Marius Storhaug (MariusStorhaug) merged 3 commits into
feat/13-implement-jwt-modulefrom
vigilant-guide

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

Targets feat/13-implement-jwt-module and adds production-level edge-case coverage to the JWT v2 integration suite. While adding tests, it also fixes a regression where New-JwtSigningKey -Algorithm HS* returned [object[]] instead of [byte[]], breaking New-Jwt -GenerateKey for HMAC algorithms.

What changed

Tests (tests/Integration.Jwt.Tests.ps1)

Added a new Production-level edge cases context covering:

  • Test-Jwt -Detailed reports failed signature and failed claim checks.
  • New-Jwt -GenerateKey produces valid tokens for HS256, RS256, and ES256.
  • ConvertFrom-Jwt accepts a SecureString token.
  • Test-Jwt returns $false for an empty signature segment on signed algorithms.
  • New-Jwt parameter validation rejects non-hashtable payloads.
  • Test-Jwt parameter validation rejects $null tokens.
  • Verbose output does not leak payload secrets or key material.

Bug fix (src/functions/public/Keys/New-JwtSigningKey.ps1)

PowerShell unwraps [byte[]] to [object[]] when returned through an untyped variable. The HS* branch now returns ,$bytes so the byte-array type is preserved, allowing New-Jwt -Algorithm HS256 -GenerateKey to sign and verify correctly.

CI

Bumped the reusable workflow pin to Process-PSModule v6.1.15 while preserving the explicit TestData mapping required by the reusable workflow's secrets interface.

Verification

Import-Module Pester -RequiredVersion 6.0.1 -Force
$config = New-PesterConfiguration
$config.Run.Path = 'tests'
Invoke-Pester -Configuration $config

Result: 123 passed, 0 failed (1 skipped: optional Azure Key Vault test).

Related

Contributes to #26 (JWT v2 overhaul).


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

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 ✅
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

@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

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.

@MariusStorhaug
Marius Storhaug (MariusStorhaug) changed the base branch from main to feat/13-implement-jwt-module August 3, 2026 01:16
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Super-linter summary

Language Validation result
CHECKOV 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

Updates the reusable workflow pin from v6.1.13 to v6.1.15 and keeps the
explicit TestData mapping required by the reusable workflow's secrets
interface.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MariusStorhaug
Marius Storhaug (MariusStorhaug) force-pushed the vigilant-guide branch 2 times, most recently from 1e0a2cf to ea6aaf7 Compare August 3, 2026 01:31
PowerShell functions unwrap [byte[]] to [object[]] when returned through
an untyped variable, causing Resolve-JwtKey to reject generated HMAC keys
with 'Algorithm HS256 does not accept a key of type [System.Object[]]'.
Return the byte array with the unary comma operator so the type is
preserved and New-Jwt -Algorithm HS256 -GenerateKey works correctly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Expands Integration.Jwt.Tests.ps1 with a new 'Production-level edge cases'
context covering:

- Test-Jwt -Detailed reports failed signature and claim checks.
- New-Jwt -GenerateKey produces valid tokens for HS256, RS256, and ES256.
- ConvertFrom-Jwt accepts a SecureString token.
- Test-Jwt returns false for an empty signature segment on signed algs.
- New-Jwt parameter validation rejects non-hashtable payloads.
- Test-Jwt parameter validation rejects null tokens.
- Verbose output does not leak payload secrets or key material.

The new HS256 -GenerateKey test exposed the byte[]-to-object[] regression
fixed in the preceding commit.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MariusStorhaug
Marius Storhaug (MariusStorhaug) marked this pull request as ready for review August 3, 2026 01:47
@MariusStorhaug
Marius Storhaug (MariusStorhaug) merged commit 3e3d5ca into feat/13-implement-jwt-module Aug 3, 2026
35 checks passed
@MariusStorhaug
Marius Storhaug (MariusStorhaug) deleted the vigilant-guide branch August 3, 2026 01:48
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