Skip to content

Commit 1d4ed59

Browse files
Add test for PreserveCredentials false functionality
Co-authored-by: MariusStorhaug <[email protected]>
1 parent 968f8f0 commit 1d4ed59

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/TestWorkflow.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,52 @@ jobs:
498498
Get-GitHubGitConfig | Format-Table -AutoSize | Out-String
499499
}
500500
}
501+
502+
ActionTestPreserveCredentialsFalse:
503+
name: PreserveCredentials False
504+
runs-on: ${{ inputs.runs-on }}
505+
steps:
506+
# Need to check out as part of the test, as its a local action
507+
- name: Checkout repo
508+
uses: actions/checkout@v4
509+
510+
- name: Action-Test with PreserveCredentials false
511+
uses: ./
512+
with:
513+
Token: ${{ secrets.TEST_USER_PAT }}
514+
PreserveCredentials: false
515+
Prerelease: ${{ inputs.Prerelease }}
516+
Script: |
517+
LogGroup 'Get-GitHubUser with credentials that will be cleaned up' {
518+
Get-GitHubUser | Format-Table -AutoSize | Out-String
519+
}
520+
521+
- name: Verify credentials are cleaned up
522+
shell: pwsh
523+
run: |
524+
try {
525+
# Import GitHub module to check contexts
526+
Import-Module -Name GitHub -ErrorAction SilentlyContinue
527+
528+
# Check if Get-GitHubContext command is available
529+
if (Get-Command Get-GitHubContext -ErrorAction SilentlyContinue) {
530+
# Get available contexts
531+
$contexts = Get-GitHubContext -ListAvailable
532+
533+
Write-Host "Available GitHub contexts: $($contexts | ConvertTo-Json -Depth 3)"
534+
535+
# Verify that no contexts are available (should be null or empty)
536+
if ($null -eq $contexts -or $contexts.Count -eq 0) {
537+
Write-Host "✅ SUCCESS: No GitHub contexts found after cleanup"
538+
} else {
539+
Write-Host "❌ FAILURE: Found $($contexts.Count) GitHub context(s) after cleanup"
540+
$contexts | Format-Table -AutoSize | Out-String | Write-Host
541+
exit 1
542+
}
543+
} else {
544+
Write-Host "⚠️ WARNING: Get-GitHubContext command not available"
545+
}
546+
} catch {
547+
Write-Host "❌ FAILURE: Error checking GitHub contexts: $($_.Exception.Message)"
548+
exit 1
549+
}

0 commit comments

Comments
 (0)