Release 2.7.1: Token refresh and secret management fixes#85
Conversation
- Fix token refresh to gracefully handle missing secret vault configuration - Preserve secret prefix during token refresh for correct vault lookups - Add regression tests for secret management token refresh scenarios - Fix workflow issue matching to use exact title filtering instead of fuzzy first-match
There was a problem hiding this comment.
Pull request overview
This PR prepares the NinjaOne PowerShell module Release 2.7.1, focusing on improving token refresh behavior when SecretManagement is in use (or misconfigured), preserving secret-prefix behavior across re-authentication, and tightening the monthly endpoint drift workflow’s issue update logic.
Changes:
- Adjust secret-vault read/write flows to preserve
SecretPrefixand avoid passing secret management params during refresh when vault config is missing. - Add regression tests for token refresh + secret management scenarios, including secret prefix preservation.
- Bump module version to 2.7.1, update changelog, and refine the monthly capability check workflow’s issue matching/update behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/NinjaOne.Private.Tests.ps1 | Adds regression tests for token refresh behavior and secret-prefix preservation. |
| Source/Public/PSModule/Connect/Connect-NinjaOne.ps1 | Passes -secretPrefix when reading connection/auth data from the secret vault. |
| Source/Private/Update-NinjaOneToken.ps1 | Refactors refresh reauth splat params; adds conditional secret-management handling and secret prefix propagation. |
| Source/Private/Set-NinjaOneSecrets.ps1 | Adds explicit validation for missing/blank vault name. |
| Source/Private/Get-NinjaOneSecrets.ps1 | Persists SecretPrefix into connection info after retrieving secrets. |
| Source/NinjaOne.psd1 | Updates module version to 2.7.1. |
| CHANGELOG.md | Adds 2.7.1 release entry (dated 2026-06-22). |
| .github/workflows/monthly-instance-capability-check.yml | Uses exact-title filtering and edits issue body (instead of commenting) when updating an existing issue. |
| if ($Script:NRAPIConnectionInformation.UseSecretManagement) { | ||
| if ([String]::IsNullOrWhiteSpace($Script:NRAPIConnectionInformation.VaultName)) { | ||
| Write-Verbose 'Secret management is enabled, but no secret vault name is configured. Refreshing without secret vault updates.' | ||
| } else { | ||
| $ReauthParams.UseSecretManagement = $True | ||
| $ReauthParams.VaultName = $Script:NRAPIConnectionInformation.VaultName | ||
| $ReauthParams.WriteToSecretVault = $Script:NRAPIConnectionInformation.WriteToSecretVault | ||
| $ReauthParams.ReadFromSecretVault = $Script:NRAPIConnectionInformation.ReadFromSecretVault | ||
| if (-not [String]::IsNullOrWhiteSpace($Script:NRAPIConnectionInformation.SecretPrefix)) { | ||
| $ReauthParams.SecretPrefix = $Script:NRAPIConnectionInformation.SecretPrefix | ||
| } | ||
| } | ||
| } |
| { Update-NinjaOneToken -ErrorAction SilentlyContinue } | Should -Not -Throw | ||
| $script:CapturedReauthParams.SecretPrefix | Should -Be 'Custom' | ||
| $script:CapturedReauthParams.ReadFromSecretVault | Should -BeTrue | ||
| } |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #85 +/- ##
==========================================
- Coverage 18.16% 18.04% -0.13%
==========================================
Files 313 313
Lines 4260 4256 -4
==========================================
- Hits 774 768 -6
- Misses 3486 3488 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
- Remove secret management parameters from token refresh call to Connect-NinjaOne - Token refresh should only use auth method (OAuth/ClientCreds) parameters - Secret management operations (read/write) don't apply during token refresh - Fixes parameter set resolution error in Update-NinjaOneToken - Update test to verify refresh succeeds without secret management params
Release 2.7.1
This release includes critical fixes for token refresh and secret management, as well as workflow improvements.
Fixes
Changes
After this PR is merged into main, release tag v2.7.1 will be created.