Skip to content

Commit 2a63329

Browse files
Fix non-windows check
1 parent 89e9349 commit 2a63329

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/GroupPolicyEnforcement.Tests.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
# Copyright (c) Microsoft Corporation.
33
# Licensed under the MIT License.
44

5-
# Add Pester test to check the API for GroupPolicyEnforcement
5+
$checkIfWindows = [System.Environment]::OSVersion.Platform -eq 'Win32NT'
66

7+
# Add Pester test to check the API for GroupPolicyEnforcement
78
Describe 'GroupPolicyEnforcement API Tests' -Tags 'CI' {
89

9-
It 'IsGroupPolicyEnabled should return the correct policy enforcement status' -Skip:(-not $IsWindows) {
10+
It 'IsGroupPolicyEnabled should return the correct policy enforcement status' -Skip:(-not $checkIfWindows) {
1011
$actualStatus = [Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement]::IsGroupPolicyEnabled()
1112
$actualStatus | Should -BeFalse
1213
}
1314

14-
It 'IsGroupPolicyEnabled should return false on non-windows platform' -Skip:$IsWindows {
15+
It 'IsGroupPolicyEnabled should return false on non-windows platform' -Skip:$checkIfWindows {
1516
[Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement]::IsGroupPolicyEnabled() | Should -BeFalse
1617
}
1718

18-
It 'GetAllowedRepositoryURIs return null if Group Policy is not enabled' -Skip:(-not $IsWindows) {
19+
It 'GetAllowedRepositoryURIs return null if Group Policy is not enabled' -Skip:(-not $checkIfWindows) {
1920
[Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement]::GetAllowedRepositoryURIs() | Should -BeNullOrEmpty
2021

2122
try {
@@ -47,7 +48,7 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
4748
[Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook('AllowedUri', $null)
4849
}
4950

50-
It 'Get-PSResourceRepository lists the allowed repository' -Skip:(-not $IsWindows) {
51+
It 'Get-PSResourceRepository lists the allowed repository' -Skip:(-not $checkIfWindows) {
5152
try {
5253
Register-PSResourceRepository -Name 'Example' -Uri 'https://www.example.com/'
5354
$psrep = Get-PSResourceRepository -Name 'Example'
@@ -59,7 +60,7 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
5960
}
6061
}
6162

62-
It 'Find-PSResource is blocked by policy' -Skip:(-not $IsWindows) {
63+
It 'Find-PSResource is blocked by policy' -Skip:(-not $checkIfWindows) {
6364
try {
6465
Register-PSResourceRepository -Name 'Example' -Uri 'https://www.example.com/' -ApiVersion 'v3'
6566
{ Find-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Throw "Repository 'PSGallery' is not allowed by Group Policy."
@@ -73,7 +74,7 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
7374
}
7475
}
7576

76-
It 'Install-PSResource is blocked by policy' -Skip:(-not $IsWindows) {
77+
It 'Install-PSResource is blocked by policy' -Skip:(-not $checkIfWindows) {
7778
try {
7879
Register-PSResourceRepository -Name 'Example' -Uri 'https://www.example.com/' -ApiVersion 'v3'
7980
{ Install-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Throw "Repository 'PSGallery' is not allowed by Group Policy."
@@ -87,7 +88,7 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
8788
}
8889
}
8990

90-
It 'Save-PSResource is blocked by policy' -Skip:(-not $IsWindows) {
91+
It 'Save-PSResource is blocked by policy' -Skip:(-not $checkIfWindows) {
9192
try {
9293
Register-PSResourceRepository -Name 'Example' -Uri 'https://www.example.com/' -ApiVersion 'v3'
9394
{ Save-PSResource -Repository PSGallery -Name 'Az.Accounts' -ErrorAction Stop } | Should -Throw "Repository 'PSGallery' is not allowed by Group Policy."

0 commit comments

Comments
 (0)