Happypath.localhost.tests.ps1

Describe "Fortytwo.Universe - Production" {
    It "Can load the module" {
        Import-Module ([string]::IsNullOrEmpty($PSScriptRoot) ? "./" : $PSScriptRoot) -Force
        $module = Get-Module Fortytwo.Universe
        $module | Should -Not -BeNullOrEmpty
    }

    It "Can connect with fake token" {
        $Script:JWT = New-DummyJWT
        Confirm-Universe | Should -BeFalse
        {
            Add-EntraIDExternalAccessTokenProfile -Name "Fortytwo.Universe" -AccessToken $Script:JWT -WarningAction SilentlyContinue
            Connect-Universe -AccessTokenProfile "Fortytwo.Universe" -Environment "Development" -FQDN "localhost:333"
        } | Should -Not -Throw
        Confirm-Universe | Should -BeTrue
    }

    It "Can get token" {
        Get-UniverseToken | Should -BeExactly $Script:JWT
    }

    It "Can get header" {
        $header = Get-UniverseHeader
        $header.Authorization | Should -BeExactly "Bearer $Script:JWT"
    }

    It "Can get urls" {
        Get-UniverseUrl | Should -BeExactly "https://localhost:333/"
        Get-UniverseUrl "test" | Should -BeExactly "https://localhost:333/test"
        Get-UniverseUrl "/test" | Should -BeExactly "https://localhost:333/test"
    }
}