Commit 3e3d5ca
test: expand Jwt test suite to production-level coverage (#40)
## 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
```powershell
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>
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>1 parent 932350e commit 3e3d5ca
3 files changed
Lines changed: 78 additions & 2 deletions
File tree
- .github/workflows
- src/functions/public/Keys
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
674 | 750 | | |
675 | 751 | | |
0 commit comments