|
1 | | -Describe 'PowerShellGallery' { |
| 1 | +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( |
| 2 | + 'PSAvoidUsingConvertToSecureStringWithPlainText', '', |
| 3 | + Justification = 'Test file - converting test data to SecureString for testing purposes only.' |
| 4 | +)] |
| 5 | +param() |
| 6 | + |
| 7 | +Describe 'PowerShellGallery' { |
2 | 8 | Context 'Function: Get-PSGalleryAPI' { |
3 | 9 | It 'Should not throw' { |
4 | 10 | { Get-PSGalleryAPI } | Should -Not -Throw |
|
27 | 33 | try { |
28 | 34 | $null = Disconnect-PowerShellGallery -Name $script:TestContextName -Confirm:$false -ErrorAction SilentlyContinue |
29 | 35 | } catch { |
30 | | - # Ignore cleanup errors |
| 36 | + Write-Verbose "Cleanup error ignored: $_" |
31 | 37 | } |
32 | 38 | } |
33 | 39 |
|
|
66 | 72 | try { |
67 | 73 | $null = Disconnect-PowerShellGallery -Name $script:GetTestContextName -Confirm:$false -ErrorAction SilentlyContinue |
68 | 74 | } catch { |
69 | | - # Ignore cleanup errors |
| 75 | + Write-Verbose "Cleanup error ignored: $_" |
70 | 76 | } |
71 | 77 | } |
72 | 78 |
|
|
95 | 101 | $testContextName2 = 'SwitchTestContext2_' + (Get-Random) |
96 | 102 | $script:SwitchTestContextName1 = $testContextName1 |
97 | 103 | $script:SwitchTestContextName2 = $testContextName2 |
98 | | - |
| 104 | + |
99 | 105 | $secureApiKey1 = ConvertTo-SecureString -String 'test-switch-api-key-1' -AsPlainText -Force |
100 | 106 | $secureApiKey2 = ConvertTo-SecureString -String 'test-switch-api-key-2' -AsPlainText -Force |
101 | | - |
| 107 | + |
102 | 108 | Connect-PowerShellGallery -Name $testContextName1 -ApiKey $secureApiKey1 -Silent |
103 | 109 | Connect-PowerShellGallery -Name $testContextName2 -ApiKey $secureApiKey2 -Silent |
104 | 110 | } |
|
109 | 115 | $null = Disconnect-PowerShellGallery -Name $script:SwitchTestContextName1 -Confirm:$false -ErrorAction SilentlyContinue |
110 | 116 | $null = Disconnect-PowerShellGallery -Name $script:SwitchTestContextName2 -Confirm:$false -ErrorAction SilentlyContinue |
111 | 117 | } catch { |
112 | | - # Ignore cleanup errors |
| 118 | + Write-Verbose "Cleanup error ignored: $_" |
113 | 119 | } |
114 | 120 | } |
115 | 121 |
|
|
159 | 165 | try { |
160 | 166 | $null = Disconnect-PowerShellGallery -Name $script:TokenTestContextName -Confirm:$false -ErrorAction SilentlyContinue |
161 | 167 | } catch { |
162 | | - # Ignore cleanup errors |
| 168 | + Write-Verbose "Cleanup error ignored: $_" |
163 | 169 | } |
164 | 170 | } |
165 | 171 |
|
|
191 | 197 | try { |
192 | 198 | $null = Disconnect-PowerShellGallery -Name $script:AccessTestContextName -Confirm:$false -ErrorAction SilentlyContinue |
193 | 199 | } catch { |
194 | | - # Ignore cleanup errors |
| 200 | + Write-Verbose "Cleanup error ignored: $_" |
195 | 201 | } |
196 | 202 | } |
197 | 203 |
|
|
0 commit comments