264 lines
9.2 KiB
PowerShell
264 lines
9.2 KiB
PowerShell
. $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 "Test-AlkamiServiceManifest10" {
|
|
function New-FakeServiceManifest {
|
|
$sampleManifest = @"
|
|
<?xml version="1.0"?>
|
|
<packageManifest>
|
|
<version>1.0</version>
|
|
<general>
|
|
<creatorCode>Alkami</creatorCode>
|
|
<element>Alkami.MicroServices.Testing.FakeService</element>
|
|
<componentType>Service</componentType>
|
|
<bankIdentifiers>
|
|
<bankIdentifier name="MyFIName">DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF</bankIdentifier>
|
|
</bankIdentifiers>
|
|
</general>
|
|
<serviceManifest>
|
|
<runtime>framework</runtime>
|
|
<entryPoint>Alkami.MicroServices.Testing.FakeService</entryPoint>
|
|
<migrations>
|
|
<package id="Alkami.MicroServices.Testing.FakeService" version="1.0" />
|
|
</migrations>
|
|
<db_role>my_service_role</db_role>
|
|
</serviceManifest>
|
|
</packageManifest>
|
|
"@
|
|
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
|
|
Set-Content -Path $testFile -value $sampleManifest
|
|
|
|
}
|
|
|
|
function New-InvalidServiceManifest {
|
|
$sampleManifest = @"
|
|
<?xml version="1.0"?>
|
|
<packageManifest>
|
|
<version>1.0</version>
|
|
<general>
|
|
<creatorCode>Alkami</creatorCode>
|
|
<element>Alkami.MicroServices.Testing.FakeService</element>
|
|
<componentType>Service</componentType>
|
|
<bankIdentifiers>
|
|
<bankIdentifier name="MyFIName">DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF</bankIdentifier>
|
|
</bankIdentifiers>
|
|
</general>
|
|
<serviceManifest>
|
|
<!-- Can't be valid if you're empty! -->
|
|
</serviceManifest>
|
|
</packageManifest>
|
|
"@
|
|
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
|
|
Set-Content -Path $testFile -value $sampleManifest
|
|
|
|
}
|
|
|
|
function New-ValidServiceManifestWithProvider {
|
|
$sampleManifest = @"
|
|
<?xml version="1.0"?>
|
|
<packageManifest>
|
|
<version>1.0</version>
|
|
<general>
|
|
<creatorCode>Alkami</creatorCode>
|
|
<element>Alkami.MicroServices.Testing.FakeService</element>
|
|
<componentType>Service</componentType>
|
|
<bankIdentifiers>
|
|
<bankIdentifier name="MyFIName">DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF</bankIdentifier>
|
|
</bankIdentifiers>
|
|
</general>
|
|
<serviceManifest>
|
|
<runtime>framework</runtime>
|
|
<entryPoint>Alkami.MicroServices.Testing.FakeService</entryPoint>
|
|
<migrations>
|
|
<package id="Alkami.MicroServices.Testing.FakeService" version="1.0" />
|
|
</migrations>
|
|
<provider>
|
|
<providerType>my_provider_type</providerType>
|
|
<providerName>my_provider_name</providerName>
|
|
</provider>
|
|
<db_role>my_service_role</db_role>
|
|
</serviceManifest>
|
|
</packageManifest>
|
|
"@
|
|
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
|
|
Set-Content -Path $testFile -value $sampleManifest
|
|
|
|
}
|
|
|
|
function New-InvalidServiceManifestWithProvider {
|
|
$sampleManifest = @"
|
|
<?xml version="1.0"?>
|
|
<packageManifest>
|
|
<version>1.0</version>
|
|
<general>
|
|
<creatorCode>Alkami</creatorCode>
|
|
<element>Alkami.MicroServices.Testing.FakeService</element>
|
|
<componentType>Service</componentType>
|
|
<bankIdentifiers>
|
|
<bankIdentifier name="MyFIName">DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF</bankIdentifier>
|
|
</bankIdentifiers>
|
|
</general>
|
|
<serviceManifest>
|
|
<runtime>framework</runtime>
|
|
<entryPoint>Alkami.MicroServices.Testing.FakeService</entryPoint>
|
|
<migrations>
|
|
<package id="Alkami.MicroServices.Testing.FakeService" version="1.0" />
|
|
</migrations>
|
|
<provider>
|
|
<!-- Oh no this is empty -->
|
|
</provider>
|
|
<db_role>my_service_role</db_role>
|
|
</serviceManifest>
|
|
</packageManifest>
|
|
"@
|
|
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
|
|
Set-Content -Path $testFile -value $sampleManifest
|
|
|
|
}
|
|
|
|
function New-InvalidServiceManifestWithAssemblyAndPackage {
|
|
$sampleManifest = @"
|
|
<?xml version="1.0"?>
|
|
<packageManifest>
|
|
<version>1.0</version>
|
|
<general>
|
|
<creatorCode>Alkami</creatorCode>
|
|
<element>Alkami.MicroServices.FluxManagement.Service.Host</element>
|
|
<componentType>Service</componentType>
|
|
</general>
|
|
<serviceManifest>
|
|
<runtime>framework</runtime>
|
|
<entryPoint>Alkami.MicroServices.FluxManagement.Service.Host</entryPoint>
|
|
<!-- Populating the migrations or db_role values will assume the microservice needs connectivity to a tenant database. -->
|
|
<migrations>
|
|
<assembly target="TENANT" online="false" role="FluxManagement_Service">Alkami.MicroServices.FluxManagement.Migrations.dll</assembly>
|
|
<package id="Alkami.MicroServices.FluxManagement.Migrations" version="1.2.0" />
|
|
</migrations>
|
|
<db_role>FluxManagement_Service</db_role>
|
|
</serviceManifest>
|
|
</packageManifest>
|
|
"@
|
|
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
|
|
Set-Content -Path $testFile -value $sampleManifest
|
|
|
|
}
|
|
|
|
Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { return "SUT" }
|
|
Mock -ModuleName $moduleForMock -CommandName Write-Verbose -MockWith { }
|
|
Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { }
|
|
Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { }
|
|
Mock -ModuleName $moduleForMock -CommandName Get-AlkamiManifestFilename -MockWith { return "NewServiceAlkamiManifest.xml" }
|
|
|
|
# The expectation is that we will have multiple versions here. We might need more contexts per version at that point.
|
|
Context "When Testing a valid Service Manifest" {
|
|
New-FakeServiceManifest
|
|
It "Returns success == true" {
|
|
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
|
|
$results.success | Should -BeTrue
|
|
}
|
|
It "Does not return an array of errors." {
|
|
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
|
|
$results.results | Should -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context "When Testing an invalid Service Manifest" {
|
|
New-InvalidServiceManifest
|
|
|
|
It "Returns success == false" {
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
$results.success | Should -BeFalse
|
|
}
|
|
|
|
It "Returns a non-empty array of errors." {
|
|
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
|
|
$results.results | Should -not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context "When Testing a valid Service Manifest with provider" {
|
|
New-ValidServiceManifestWithProvider
|
|
It "Returns success == true" {
|
|
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
|
|
$results.success | Should -BeTrue
|
|
}
|
|
|
|
It "Does not return an array of errors." {
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
|
|
$results.results | Should -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context "When Testing an invalid Service Manifest with provider" {
|
|
New-InvalidServiceManifestWithProvider
|
|
|
|
It "Returns success == false" {
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
$results.success | Should -BeFalse
|
|
}
|
|
|
|
It "Returns a non-empty array of errors." {
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
|
|
$results.results | Should -not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context "When Testing a Service Manifest with assembly and package" {
|
|
New-InvalidServiceManifestWithAssemblyAndPackage
|
|
|
|
It "Returns success == false" {
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
$results.success | Should -BeFalse
|
|
}
|
|
|
|
It "Returns a non-empty array of errors." {
|
|
$file = Get-Content "TestDrive:\NewServiceAlkamiManifest.xml"
|
|
$xml = [xml]$file
|
|
$results = Test-AlkamiServiceManifest10 $xml.packageManifest.serviceManifest
|
|
|
|
$results.results | Should -not -BeNullOrEmpty
|
|
}
|
|
}
|
|
}
|