@@ -15,12 +15,21 @@ Describe 'GroupPolicyEnforcement API Tests' -Tags 'CI' {
1515 [Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement ]::IsGroupPolicyEnabled() | Should - BeTrue
1616 }
1717
18- It ' Group Policy must be enabled before getting allowed repositories' - Skip:(-not $IsWindows ) {
18+ It ' GetAllowedRepositoryURIs return null if Group Policy is not enabled' - Skip:(-not $IsWindows ) {
19+ [Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement ]::GetAllowedRepositoryURIs() | Should - BeNullOrEmpty
20+
1921 try {
20- [Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement ]::GetAllowedRepositoryURIs()
22+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks ]::SetTestHook(' EnableGPRegistryHook' , $true )
23+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks ]::SetTestHook(' GPEnabledStatus' , $true )
24+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks ]::SetTestHook(' AllowedUri' , " https://www.example.com/" )
25+
26+ $allowedReps = [Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement ]::GetAllowedRepositoryURIs()
27+ $allowedReps.AbsoluteUri | Should - Be @ (" https://www.example.com/" )
2128 }
22- catch {
23- $_.Exception.InnerException.Message | Should - Be ' Group policy is not enabled.'
29+ finally {
30+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks ]::SetTestHook(' EnableGPRegistryHook' , $false )
31+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks ]::SetTestHook(' GPEnabledStatus' , $false )
32+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks ]::SetTestHook(' AllowedUri' , $null )
2433 }
2534 }
2635}
@@ -38,11 +47,6 @@ Describe 'GroupPolicyEnforcement Cmdlet Tests' -Tags 'CI' {
3847 [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks ]::SetTestHook(' AllowedUri' , $null )
3948 }
4049
41- It ' Getting allowed repositories works as expected' - Skip:(-not $IsWindows ) {
42- $allowedReps = [Microsoft.PowerShell.PSResourceGet.Cmdlets.GroupPolicyRepositoryEnforcement ]::GetAllowedRepositoryURIs()
43- $allowedReps.AbsoluteUri | Should - Be @ (" https://www.example.com/" )
44- }
45-
4650 It ' Get-PSResourceRepository lists the allowed repository' - Skip:(-not $IsWindows ) {
4751 try {
4852 Register-PSResourceRepository - Name ' Example' - Uri ' https://www.example.com/'
0 commit comments