Tests/Unit/Private/Resolve-SIAUri.Tests.ps1
|
BeforeAll { $moduleRoot = (Resolve-Path (Join-Path $PSScriptRoot '../../..')).Path Import-Module (Join-Path $moduleRoot 'psSIA.psd1') -Force } Describe 'Resolve-SIAUri' { It 'builds the Dpa host by default' { InModuleScope psSIA { $uri = Resolve-SIAUri -Path '/api/connectors' -Subdomain 'contoso' $uri.Host | Should -Be 'contoso.dpa.cyberark.cloud' $uri.AbsolutePath | Should -Be '/api/connectors' } } It 'builds the Uap host' { InModuleScope psSIA { $uri = Resolve-SIAUri -Path '/policies' -Service Uap -Subdomain 'contoso' $uri.Host | Should -Be 'contoso.uap.cyberark.cloud' } } It 'builds the Uar host' { InModuleScope psSIA { $uri = Resolve-SIAUri -Path '/workflows/requests' -Service Uar -Subdomain 'contoso' $uri.Host | Should -Be 'contoso.uar.cyberark.cloud' } } It 'builds the UserPortal host with a hyphen, not a subdomain dot' { InModuleScope psSIA { $uri = Resolve-SIAUri -Path '/api/assets' -Service UserPortal -Subdomain 'contoso' $uri.Host | Should -Be 'contoso-userportal.cyberark.cloud' } } It 'appends and escapes query parameters' { InModuleScope psSIA { $uri = Resolve-SIAUri -Path '/api/secrets/public/v1' -Subdomain 'contoso' -QueryParameter @{ secret_name = 'svc admin' } $uri.Query | Should -Be '?secret_name=svc%20admin' } } It 'omits null query parameter values' { InModuleScope psSIA { $uri = Resolve-SIAUri -Path '/api/connectors' -Subdomain 'contoso' -QueryParameter @{ continuationToken = $null } $uri.Query | Should -BeNullOrEmpty } } It 'always uses https' { InModuleScope psSIA { (Resolve-SIAUri -Path '/api/connectors' -Subdomain 'contoso').Scheme | Should -Be 'https' } } } |