ps/Modules/Alkami.PowerShell.Configuration/Public/Get-AppServiceAccountName.tests.ps1

111 lines
4.1 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
. $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 = ""
Describe "Get-AppServiceAccountName" {
Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith {}
Mock -ModuleName $moduleForMock -CommandName Get-AppSetting -MockWith { return "sb" }
Context "Testing basic values with domain and is-app-server" {
Mock -ModuleName $moduleForMock -CommandName Test-IsAppServer -MockWith { return $true }
Mock -ModuleName $moduleForMock -CommandName Get-CimInstance -MockWith { return @{ Domain = "Test.Domain"; } }
It "Testing known matrix value" {
Get-AppServiceAccountName "AuditService" | Should Be "test\sb.audit$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "BankService" | Should Be "test\sb.bank$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "ContentService" | Should Be "test\sb.content$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "CoreService" | Should Be "test\sb.core$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "ExceptionService" | Should Be "test\sb.exception$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "MessageCenterService" | Should Be "test\sb.msgctr$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "NagConfigurationService" | Should Be "test\sb.nag$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "NotificationService" | Should Be "test\sb.notify$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "RP-STS" | Should Be "test\sb.rpsts$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "SchedulerService" | Should Be "test\sb.schedule$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "SecurityManagementService" | Should Be "test\sb.secmgr$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "STSConfiguration" | Should Be "test\sb.stsconf$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "SymConnectMultiplexer" | Should Be "test\sb.multiplx$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "Alkami Radium Scheduler Service" | Should Be "test\sb.radium$"
}
It "Testing known matrix value" {
Get-AppServiceAccountName "Alkami Nag Service" | Should Be "test\sb.nag$"
}
It "Testing unknown matrix value" {
Get-AppServiceAccountName "BankService2" | Should Be "sb"
}
}
Context "Testing basic values with domain and is-not-app-server" {
Mock -ModuleName $moduleForMock -CommandName Test-IsAppServer -MockWith { return $false }
Mock -ModuleName $moduleForMock -CommandName Get-CimInstance -MockWith { return @{ Domain = "Test.Domain"; } }
It "Testing known matrix value" {
Get-AppServiceAccountName "BankService" | Should Be "test\sb.bank$"
}
It "Testing unknown matrix value" {
Get-AppServiceAccountName "BankService2" | Should Be ""
}
}
Context "Testing basic values without domain" {
Mock -ModuleName $moduleForMock -CommandName Test-IsAppServer -MockWith { return $false }
Mock -ModuleName $moduleForMock -CommandName Get-CimInstance -MockWith { return @{ Domain = ""; } }
It "Testing known matrix value" {
Get-AppServiceAccountName "BankService" | Should Be ""
}
It "Testing unknown matrix value" {
Get-AppServiceAccountName "BankService2" | Should Be ""
}
}
}
#endregion Get-ConfigurationFiles