Skip to content

Commit

Permalink
Fix operations
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapatwardhan committed Oct 20, 2024
1 parent 3876f53 commit 096a512
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/GroupPolicyEnforcement.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
It 'Install-PSResource is blocked by policy' -Skip:(-not $IsWindows) {
try {
Register-PSResourceRepository -Name 'Example' -Uri 'https://www.example.com/' -ApiVersion 'v3'
{ Find-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Throw "Repository 'PSGallery' is not allowed by Group Policy."
{ Install-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Throw "Repository 'PSGallery' is not allowed by Group Policy."

# Allow PSGallery and it should not fail
[Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook('AllowedUri', " https://www.powershellgallery.com/api/v2")
{ Find-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Not -Throw
{ Install-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop -TrustRepository} | Should -Not -Throw
}
finally {
Unregister-PSResourceRepository -Name 'Example'
Expand All @@ -92,11 +92,11 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
It 'Save-PSResource is blocked by policy' -Skip:(-not $IsWindows) {
try {
Register-PSResourceRepository -Name 'Example' -Uri 'https://www.example.com/' -ApiVersion 'v3'
{ Find-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Throw "Repository 'PSGallery' is not allowed by Group Policy."
{ Save-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Throw "Repository 'PSGallery' is not allowed by Group Policy."

# Allow PSGallery and it should not fail
[Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook('AllowedUri', " https://www.powershellgallery.com/api/v2")
{ Find-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Not -Throw
{ Save-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop -TrustRepository} | Should -Not -Throw
}
finally {
Unregister-PSResourceRepository -Name 'Example'
Expand Down

0 comments on commit 096a512

Please sign in to comment.