. $PSScriptRoot\..\..\Load-PesterModules.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.' $functionPath = Join-Path -Path $here -ChildPath $sut Write-Host "Overriding SUT: $functionPath" Import-Module $functionPath -Force $moduleForMock = "" <# Invoke pester from the 'Modules' directory of the Alkami.Powershell repository. Example: Invoke-Pester -Script @{Path = 'Alkami.DevOps.Installation\Public\Get-NewRelicAccountDetails.tests.ps1'} #> Describe "Get-NewRelicAccountDetails" { Context "Correct NR Account Information is Returned for Various Environment Keys" { # Generic environment keys. $defaultDrApiKey = "6a9e9820d3aaf12278c80d0bc1433b90aee1ea5769ac25f" $defaultDrLicenseKey = "b55c8c163b1ede6fef75f6f586a1dbb6869ac25f" $defaultProdApiKey = "NRRA-8fbdf2188c09dd34aef478e13e31668e405324a304" $defaultProdLicenseKey = "e0318c558f353e420720d4417ebe4cbd43b7d425" $defaultStagingApiKey = "a156af42c6da91536e67f2414bc1c25f3742e41b0cb93ab" $defaultStagingLicenseKey = "3707290484dceca2dc2ecd71e40fb0ff40cb93ab" # FI environment keys. $dsfcuApiKey = "b84b09aabf2ebe0773009698205220e9d53063bf84d041f" $dsfcuLicenseKey = "417a21abe2bd84ca46940efc9c93cf75584d041f" $ftApiKey = "5362c58099d6a19871a07f66b1ec50e2c00f66b4b69260e" $ftLicenseKey = "4e8134a277da93644407dc53931f81d99b69260e" $macuApiKey = "fcb208ec98958282362c4e7879bfa38e4073c10c073cc2f" $macuLicenseKey = "77b3cae28080be6a5ebcb7d2f3efdde8d073cc2f" $otsApiKey = "3d0346ec856cc9b02b3b0fcc481afc989a4f9941b28a80d" $otsLicenseKey = "d2eb268d151e57550de821438c3d99131b28a80d" $devApiKey = "0cdfe5a47b10db89acf3560e47d4657fbfec081040e50b8" $devLicenseKey = "f88cf2f1ed5fca2600f6a49e63778274c40e50b8" $qaApiKey = "955b8bfccbdde190f855238dc55f17ba5d6382ee2492392" $qaLicenseKey = "e941422aebc76c48d195bcdcf86e4f7602492392" #Internal environment keys. $salesDemoApiKey = 'd34b1647dee7875568ebc4b7c97c37216c4c342b37bcce1' $salesDemoLicenseKey = 'b17e86388ca5c4a2c4777cd1b0e1e12a837bcce1' # Test FirstTech It "Returns Expected POD 5 Values" { $curValues = Get-NewRelicAccountDetails "AWS Production 5" $curValues.APIKey | Should Be $ftApiKey $curValues.LicenseKey | Should Be $ftLicenseKey } It "Returns Expected Lane FTStg Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane FTStg" $curValues.APIKey | Should Be $ftApiKey $curValues.LicenseKey | Should Be $ftLicenseKey } It "Returns Expected Lane FTDev Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane FTDev" $curValues.APIKey | Should Be $ftApiKey $curValues.LicenseKey | Should Be $ftLicenseKey } It "Returns Expected Lane FTTest Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane FTTest" $curValues.APIKey | Should Be $ftApiKey $curValues.LicenseKey | Should Be $ftLicenseKey } # Test DSFCU It "Returns Expected POD 9 Values" { $curValues = Get-NewRelicAccountDetails "AWS Production 9" $curValues.APIKey | Should Be $dsfcuApiKey $curValues.LicenseKey | Should Be $dsfcuLicenseKey } # Test OTS It "Returns Expected POD 10 Values" { $curValues = Get-NewRelicAccountDetails "AWS Production 10" $curValues.APIKey | Should Be $otsApiKey $curValues.LicenseKey | Should Be $otsLicenseKey } It "Returns Expected Lane OTSStg Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane OTSStg" $curValues.APIKey | Should Be $otsApiKey $curValues.LicenseKey | Should Be $otsLicenseKey } # Test One of the DR PODs It "Returns Expected DR Values" { $curValues = Get-NewRelicAccountDetails "AWS DR Production 1" $curValues.APIKey | Should Be $defaultDrApiKey $curValues.LicenseKey | Should Be $defaultDrLicenseKey } # Test One of the DR PODs With Their Own NR Account (should still use base DR key) It "Returns Expected POD 9 DR Values" { $curValues = Get-NewRelicAccountDetails "AWS DR Production 9" $curValues.APIKey | Should Be $defaultDrApiKey $curValues.LicenseKey | Should Be $defaultDrLicenseKey } # Test MACU It "Returns Expected Staging Lane MACUStg Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane MACUStg" $curValues.APIKey | Should Be $macuApiKey $curValues.LicenseKey | Should Be $macuLicenseKey } It "Returns Expected AWS Production 15 Values" { $curValues = Get-NewRelicAccountDetails "AWS Production 15" $curValues.APIKey | Should Be $macuApiKey $curValues.LicenseKey | Should Be $macuLicenseKey } It "Returns Expected AWS Production 15.0.1 Values" { $curValues = Get-NewRelicAccountDetails "AWS Production 15.0.1" $curValues.APIKey | Should Be $macuApiKey $curValues.LicenseKey | Should Be $macuLicenseKey } # Test a Representative Set of "Default" Production Pods $defaultPods = @( "AWS Production 1.1", "AWS Production 1", "AWS Production 2.2", "AWS Production 2.4", "AWS Production 6", "AWS Production 6.1", "AWS Production 7", "AWS Production 7.2", "AWS Production 8", "AWS Production 8.1", "AWS Production 12.2", "AWS Production 12.10", "AWS Production 14.3" ) It "Returns Expected Default Production Values" { foreach ($pod in $defaultPods) { $curValues = Get-NewRelicAccountDetails $pod $curValues.APIKey | Should Be $defaultProdApiKey $curValues.LicenseKey | Should Be $defaultProdLicenseKey } } # Test a representative set of "default" Staging Lanes $defaultLanes = @("AWS Staging Lane LC1", "AWS Staging Lane PS5") It "Returns Expected Default Staging Values" { foreach ($lane in $defaultLanes) { $curValues = Get-NewRelicAccountDetails $lane $curValues.APIKey | Should Be $defaultStagingApiKey $curValues.LicenseKey | Should Be $defaultStagingLicenseKey } } # Test that legacy Armor Staging lane names for First Tech no longer report the First Tech New Relic credentials. It "Returns Expected Lane H (Deprecated) Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane H" $curValues.APIKey | Should Be $defaultStagingApiKey $curValues.LicenseKey | Should Be $defaultStagingLicenseKey } It "Returns Expected FT Dev (Deprecated) Values" { # This should throw because the name never conformed to conventions. { Get-NewRelicAccountDetails "Staging First Tech Dev" } | Should -Throw } It "Returns Expected FT Test (Deprecated) Values" { # This should throw because the name never conformed to conventions. { Get-NewRelicAccountDetails "Staging First Tech Test" } | Should -Throw } # Test that legacy Armor Staging Lane name for MACU no longer reports the MACU New Relic credentials. It "Returns Expected Staging Lane M (Deprecated) Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane M" $curValues.APIKey | Should Be $defaultStagingApiKey $curValues.LicenseKey | Should Be $defaultStagingLicenseKey } # Test QA[x] matches the Dev New Relic key. It "Returns Expected Dev Values for QA3" { $curValues = Get-NewRelicAccountDetails "QA3" $curValues.APIKey | Should Be $devApiKey $curValues.LicenseKey | Should Be $devLicenseKey } It "Returns Expected Dev Values for QA15" { $curValues = Get-NewRelicAccountDetails "QW15" $curValues.APIKey | Should Be $devApiKey $curValues.LicenseKey | Should Be $devLicenseKey } It "Returns Expected Dev Values for AWS DEV" { $curValues = Get-NewRelicAccountDetails "AWS DEV TEAM RANDOM" $curValues.APIKey | Should Be $devApiKey $curValues.LicenseKey | Should Be $devLicenseKey } It "Returns Expected QA Values for AWS QA" { $curValues = Get-NewRelicAccountDetails "AWS QA REGRESSION BUGAPALOOZA" $curValues.APIKey | Should Be $qaApiKey $curValues.LicenseKey | Should Be $qaLicenseKey } # Test QASTg does not match the Dev New Relic key. It "Returns Expected Staging Values for QASTg" { $curValues = Get-NewRelicAccountDetails "AWS Staging Lane QASTG" $curValues.APIKey | Should Be $defaultStagingApiKey $curValues.LicenseKey | Should Be $defaultStagingLicenseKey } It "Returns Expected Values for Pod 0 (Sales Demo)" { $curValues = Get-NewRelicAccountDetails "AWS Production 0" $curValues.APIKey | Should Be $salesDemoApiKey $curValues.LicenseKey | Should Be $salesDemoLicenseKey } It "Returns Expected Values for Pod 0.1 (Pen Test)" { $curValues = Get-NewRelicAccountDetails "AWS Production 0.1" $curValues.APIKey | Should Be $defaultProdApiKey $curValues.LicenseKey | Should Be $defaultProdLicenseKey } # Test Entrust environment keys. It "Returns Expected First Tech Entrust Values" { $curValues = Get-NewRelicAccountDetails "AWS Production Entrust 5-0" $curValues.APIKey | Should Be $ftApiKey $curValues.LicenseKey | Should Be $ftLicenseKey } It "Returns Expected Desert Entrust Values" { $curValues = Get-NewRelicAccountDetails "AWS Production Entrust 9-0" $curValues.APIKey | Should Be $dsfcuApiKey $curValues.LicenseKey | Should Be $dsfcuLicenseKey } It "Returns Expected OTS Entrust Values" { $curValues = Get-NewRelicAccountDetails "AWS Production Entrust 10-0" $curValues.APIKey | Should Be $otsApiKey $curValues.LicenseKey | Should Be $otsLicenseKey } It "Returns Expected MACU Entrust Values" { $curValues = Get-NewRelicAccountDetails "AWS Production Entrust 15-0" $curValues.APIKey | Should Be $macuApiKey $curValues.LicenseKey | Should Be $macuLicenseKey } It "Returns Expected Staging Entrust Values" { $curValues = Get-NewRelicAccountDetails "AWS Staging Entrust" $curValues.APIKey | Should Be $defaultStagingApiKey $curValues.LicenseKey | Should Be $defaultStagingLicenseKey } It "Returns Expected Default Production Entrust Values" { $curValues = Get-NewRelicAccountDetails "AWS Production Entrust 12-0" $curValues.APIKey | Should Be $defaultProdApiKey $curValues.LicenseKey | Should Be $defaultProdLicenseKey } } }