792 lines
34 KiB
PowerShell
792 lines
34 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 = ""
|
|
|
|
. $PSScriptRoot\..\TestFiles\Write-OrderedJson.ps1
|
|
|
|
Describe "Get-PackageMetadata for legacy" {
|
|
|
|
# Global Mocks
|
|
Mock -CommandName Write-Host -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName Write-Warning -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName Get-MigrationRunnerExe -ModuleName $moduleForMock -MockWith {
|
|
return "C:\temp\FakeMigrationRunner.exe"
|
|
}
|
|
|
|
Mock Get-PackageNuspecXmlV2 -ModuleName $moduleForMock {
|
|
param($Package, $Credential)
|
|
$name = $Package.Name
|
|
return (New-Object PSObject -Property @{ package = @{ metadata = @{ id = $name } } })
|
|
}
|
|
|
|
# this long magic string is a barebones package folder with no useful contents. Just the basic nuget structure and a choco install file set
|
|
Mock Get-PackageFileListV2 -ModuleName $moduleForMock -MockWith { return (ConvertFrom-Json '[{"fullPath":"package/services/metadata/core-properties/","parentFullPath":"package/services/metadata/","name":"core-properties","isDirectory":true},{"fullPath":"package/services/metadata/","parentFullPath":"package/services/","name":"metadata","isDirectory":true},{"fullPath":"package/services/","parentFullPath":"package/","name":"services","isDirectory":true},{"fullPath":"package/","parentFullPath":"/","name":"package","isDirectory":true},{"fullPath":"package/services/metadata/core-properties/629d5521ad934906a0d3c36051d35320.psmdcp","parentFullPath":"package/services/metadata/core-properties/","name":"629d5521ad934906a0d3c36051d35320.psmdcp","isDirectory":false},{"fullPath":"lib/net472/","parentFullPath":"lib/","name":"net472","isDirectory":true},{"fullPath":"lib/","parentFullPath":"/","name":"lib","isDirectory":true},{"fullPath":"_rels/","parentFullPath":"/","name":"_rels","isDirectory":true},{"fullPath":"_rels/.rels","parentFullPath":"_rels/","name":".rels","isDirectory":false},{"fullPath":"tools/","parentFullPath":"/","name":"tools","isDirectory":true},{"fullPath":"tools/chocolateyInstall.ps1","parentFullPath":"tools/","name":"chocolateyInstall.ps1","isDirectory":false},{"fullPath":"tools/chocolateyUninstall.ps1","parentFullPath":"tools/","name":"chocolateyUninstall.ps1","isDirectory":false},{"fullPath":"[Content_Types].xml","parentFullPath":"/","name":"[Content_Types].xml","isDirectory":false}]')}
|
|
|
|
Mock -CommandName Get-PackageFileV2 -ModuleName $moduleForMock -MockWith {}
|
|
|
|
# Define fake PSCredential user.
|
|
$fakeCredential = New-Object System.Management.Automation.PSCredential('AlkamiFakeUser', (Get-SecureString 'abc123'))
|
|
|
|
# Define a good testable spread of packages.
|
|
# This is the list of packages that will be built based on the json files in \TestFiles\PackageObjects
|
|
# If you add a new package to the list, you need a new object there. See \TestFiles\readme.md for additional details.
|
|
$packageText = @"
|
|
# Installers
|
|
Alkami.MicroServices.Choco.Installer.Database 2.4.6
|
|
Alkami.MicroServices.Choco.Installer.Logic 2.4.6
|
|
Alkami.MicroServices.Choco.Installer.MasterDatabase 2.4.6
|
|
Alkami.Installer.Provider 3.0.6
|
|
Alkami.Installer.WebExtension 3.0.1
|
|
Alkami.Installer.Widget 3.0.2
|
|
|
|
# Infrastructure
|
|
Alkami.MicroServices.Broker.Host 2.8.1
|
|
Alkami.Services.Subscriptions.Host 3.9.0
|
|
|
|
# Providers
|
|
Alkami.App.Nag.Providers 1.1.4
|
|
Alkami.App.Processor.Wire.FedwireOutput 1.6.0
|
|
Alkami.App.Providers.CheckImaging.CorporateOne 1.0.1
|
|
Alkami.App.Providers.Multiplexer.Client 1.0.4
|
|
Alkami.App.Providers.Radium.BillPay 1.1.0
|
|
|
|
# Tier 1 Microservices
|
|
Alkami.MicroServices.Forms.Service.Host 1.1.1
|
|
Alkami.MicroServices.Authorization.Service.Host 1.4.3
|
|
Alkami.MicroServices.Security.Service.Host 2.17.2
|
|
Alkami.MicroServices.UserInterface.Service.Host 1.17.0
|
|
Alkami.MicroServices.Audit.Service.Host 6.11.0
|
|
Alkami.MicroServices.Contacts.Service.Host 2.4.8
|
|
Alkami.MicroServices.Holidays.Service.Host 2.1.12
|
|
Alkami.MicroServices.Images.Service.Host 3.1.14
|
|
Alkami.MicroServices.Notifications.Service.Host 1.6.12
|
|
Alkami.MicroServices.Settings.Service.Host 4.4.0
|
|
Alkami.MicroServices.SiteText.Service.Host 1.1.17
|
|
Alkami.MicroServices.Transactions.Service.Host 1.7.1
|
|
Alkami.MicroServices.EventManagement.Service.Host 3.4.9
|
|
|
|
# Tier 2 Microservices
|
|
Alkami.MicroServices.QuickApply.Service.Host 9.0.0
|
|
Alkami.MicroServices.Registration.Service.Host 2.5.1
|
|
Alkami.MicroServices.RemoteDeposit.Service.Host 2.4.1
|
|
Alkami.MicroServices.CardManagementProviders.SymConnect.Host 3.7.1
|
|
|
|
# Powershell Modules
|
|
Alkami.Ops.Common 3.0.3
|
|
Alkami.PowerShell.Choco 3.5.4
|
|
Alkami.PowerShell.Common 3.2.6
|
|
|
|
# SDK
|
|
DS.AccountService.MS.Service.Host 1.0.9
|
|
DS.BranchService.MS.Service.Host 1.0.10
|
|
DS.CMN.MS.Service.Host 1.0.8
|
|
DS.CopyRequestService.MS.Host 1.0.1
|
|
DS.CoreService.MS.Service.Host 2.0.5
|
|
DS.EStatements.MS.Service.Host 1.0.7
|
|
DS.MarketingEmailService.MS.Host 1.0.7
|
|
DS.MicroService.ContentService.Service.Host 2.0.4
|
|
DS.SecureMessage.MS.Service.Host 1.0.10
|
|
DS.Settings.MS.Service.Host 1.0.8
|
|
DS.SkipAPayService.MS.Host 1.0.8
|
|
|
|
# Symitar
|
|
Alkami.MicroServices.AutoBiller.Symitar.Service.Host 2.1.4
|
|
Alkami.MicroServices.RDCoreDeposit.Symitar.Service.Host 1.1.3
|
|
Alkami.MicroServices.SymConnectMultiplexer.Service.Host 2.1.2
|
|
Alkami.Providers.FakeSymitarProvider 1.2.3
|
|
"@;
|
|
|
|
# Strip out the comment lines and parse the packages out into package objects.
|
|
$packageText = ($packageText -split "`r`n") | Where-Object { $_ -notlike "*#*"}
|
|
$packages = Format-ParseChocoPackages -text $packageText -delimiter " "
|
|
|
|
# Attach fake source feeds onto each package, since we don't want to run this test against real nuget feeds.
|
|
foreach($package in $packages)
|
|
{
|
|
$feedMap = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $package.Name -like "DS.*" # Mark the desert schools packages as SDK.
|
|
}
|
|
$package.Feed = New-Object PSObject -Property $feedMap
|
|
$package.Version = "1.2.3"
|
|
}
|
|
|
|
# Run classification function on all of the packages.
|
|
$nonFabPackageData = $packages | ForEach-Object { Get-PackageMetadataV2 -Package $_ -NugetCredential $fakeCredential }
|
|
|
|
Context "Package Classification" {
|
|
|
|
It "Determines Microservices to be Upgrade Only" {
|
|
$nonUpgradeMicroservices = $nonFabPackageData | Where-Object { $_.IsMicroservice -and (!$_.Upgrade) }
|
|
$nonUpgradeMicroservices.Count | Should -be 0
|
|
}
|
|
|
|
It "Determines Non-Microservice Upgrade-Only Packages to be Upgrade Only" {
|
|
# Make sure that all of the Test-IsPackageUpgradeOnly positive packages come out with "Upgrade == $true"
|
|
$upgradeOnlyPackages = $nonFabPackageData | Where-Object { (!$_.IsMicroservice) -and (Test-IsPackageUpgradeOnlyV2 -Package $_) }
|
|
$badUpgradePackages = $upgradeOnlyPackages | Where-Object { $_.Upgrade -ne $true }
|
|
$badUpgradePackages | Should -be $null
|
|
}
|
|
|
|
It "Determines Infrastructure Packages to be Infrastructure Packages" {
|
|
$badInfraPackages = $nonFabPackageData | Where-Object { (Test-IsPackageInfrastructureMicroserviceV2 -Package $_) -and (!$_.IsInfrastructure) }
|
|
$badInfraPackages | Should -be $null
|
|
}
|
|
|
|
It "Determines Installer Packages to be Installer Packages" {
|
|
$badInstallerPackages = $nonFabPackageData | Where-Object { (Test-IsPackageInstallerV2 -Package $_) -and (!$_.IsInstaller) }
|
|
$badInstallerPackages | Should -be $null
|
|
}
|
|
|
|
It "Determines Installer Packages to be Upgrade Only" {
|
|
$nonUpgradeInstallers = $nonFabPackageData | Where-Object { (Test-IsPackageInstallerV2 -Package $_) -and (!$_.Upgrade) }
|
|
$nonUpgradeInstallers.Count | Should -be 0
|
|
}
|
|
|
|
It "Determines Microservice Packages to be Microservice Packages" {
|
|
$badMicroPackages = $nonFabPackageData | Where-Object { (Test-IsPackageMicroserviceV2 -NuspecXmlObject $null -Package $_) -and (!$_.IsMicroservice) }
|
|
$badMicroPackages = $badMicroPackages | Where-Object { !$_.IsSdk } # Consequence of how the sdk packages are determined in these tests.
|
|
$badMicroPackages | Should -be $null
|
|
}
|
|
|
|
It "Determines Database Packages to be Database Packages" {
|
|
$badDbmsPackages = $nonFabPackageData | Where-Object { (Test-IsPackageDbmsV2 -NuspecXmlObject $null) -and (!$_.IsDbms) }
|
|
$badDbmsPackages | Should -be $null
|
|
}
|
|
|
|
It "Determines SDK Packages to be SDK Packages" {
|
|
$badSdkPackages = $nonFabPackageData | Where-Object { ($_.Feed.IsSDK) -and (!$_.IsSDK) }
|
|
$badSdkPackages | Should -be $null
|
|
}
|
|
}
|
|
}
|
|
|
|
Describe "Get-PackageMetadata with Manifests" {
|
|
# Global Mocks
|
|
Mock -CommandName Write-Host -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName Write-Warning -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName Get-MigrationRunnerExe -ModuleName $moduleForMock -MockWith {
|
|
return "C:\temp\FakeMigrationRunner.exe"
|
|
}
|
|
|
|
|
|
# Define fake PSCredential user.
|
|
$fakeCredential = New-Object System.Management.Automation.PSCredential('AlkamiFakeUser', (Get-SecureString 'abc123'))
|
|
|
|
|
|
Mock Get-PackageNuspecXmlV2 -ModuleName $moduleForMock {
|
|
param($Package, $Credential)
|
|
$name = $Package.Name
|
|
return (New-Object PSObject -Property @{ package = @{ metadata = @{ id = $name } } })
|
|
}
|
|
|
|
# this long magic string is a barebones package folder with no useful contents. Just the basic nuget structure and a choco install file set
|
|
Mock Get-PackageFileListV2 -ModuleName $moduleForMock -MockWith { return (ConvertFrom-Json '[{"fullPath":"/AlkamiManifest.xml","parentFullPath":"/","name":"AlkamiManifest.xml","isDirectory":false},{"fullPath":"package/services/metadata/core-properties/","parentFullPath":"package/services/metadata/","name":"core-properties","isDirectory":true},{"fullPath":"package/services/metadata/","parentFullPath":"package/services/","name":"metadata","isDirectory":true},{"fullPath":"package/services/","parentFullPath":"package/","name":"services","isDirectory":true},{"fullPath":"package/","parentFullPath":"/","name":"package","isDirectory":true},{"fullPath":"package/services/metadata/core-properties/629d5521ad934906a0d3c36051d35320.psmdcp","parentFullPath":"package/services/metadata/core-properties/","name":"629d5521ad934906a0d3c36051d35320.psmdcp","isDirectory":false},{"fullPath":"lib/net472/","parentFullPath":"lib/","name":"net472","isDirectory":true},{"fullPath":"lib/","parentFullPath":"/","name":"lib","isDirectory":true},{"fullPath":"_rels/","parentFullPath":"/","name":"_rels","isDirectory":true},{"fullPath":"_rels/.rels","parentFullPath":"_rels/","name":".rels","isDirectory":false},{"fullPath":"tools/","parentFullPath":"/","name":"tools","isDirectory":true},{"fullPath":"tools/chocolateyInstall.ps1","parentFullPath":"tools/","name":"chocolateyInstall.ps1","isDirectory":false},{"fullPath":"tools/chocolateyUninstall.ps1","parentFullPath":"tools/","name":"chocolateyUninstall.ps1","isDirectory":false},{"fullPath":"[Content_Types].xml","parentFullPath":"/","name":"[Content_Types].xml","isDirectory":false}]')}
|
|
|
|
Mock -CommandName Get-PackageFileV2 -ModuleName $moduleForMock -MockWith {}
|
|
|
|
Context "Is a service" {
|
|
$package = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'StickyService'
|
|
Version = '999.999.999'
|
|
}
|
|
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith {
|
|
return @{
|
|
general = @{
|
|
element = 'StickyService'
|
|
componentType = 'Service'
|
|
}
|
|
serviceManifest = @{
|
|
runtime = 'framework'
|
|
}
|
|
}
|
|
}
|
|
Mock -CommandName Get-ValidatedRuntimeParameter -ModuleName $moduleForMock -MockWith {return "framework"}
|
|
Mock -CommandName Test-ServiceManifestRequiresDbAccess -ModuleName $moduleForMock -MockWith {$false}
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $package -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is not going to web tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is not going to app tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is going to mic tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'IsMicroservice'" {
|
|
$classifiedPackage.IsMicroservice | Should -BeTrue
|
|
}
|
|
|
|
It "Is not a dbms service" {
|
|
# because our fake service doesn't have a serviceManifest definition, much less declares that it needs dbms access
|
|
$classifiedPackage.IsDbms | Should -BeFalse
|
|
}
|
|
|
|
It "Is not IsSDK" {
|
|
$classifiedPackage.IsSDK | Should -BeFalse
|
|
}
|
|
}
|
|
|
|
Context "Is a service with migrations" {
|
|
$package = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $true
|
|
}
|
|
Name = 'StickyService'
|
|
Version = '999.999.999'
|
|
}
|
|
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith {
|
|
return @{
|
|
general = @{
|
|
element = 'StickyService'
|
|
componentType = 'Service'
|
|
}
|
|
serviceManifest = @{
|
|
runtime = 'framework'
|
|
db_role = "totally_fake_role"
|
|
}
|
|
}
|
|
}
|
|
Mock -CommandName Get-ValidatedRuntimeParameter -ModuleName $moduleForMock -MockWith {return "framework"}
|
|
Mock -CommandName Test-ServiceManifestRequiresDbAccess -ModuleName $moduleForMock -MockWith {$true}
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $package -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is not going to web tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is not going to app tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is going to mic tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'IsMicroservice'" {
|
|
$classifiedPackage.IsMicroservice | Should -BeTrue
|
|
}
|
|
|
|
It "Is a dbms service" {
|
|
# because our fake service doesn't have a serviceManifest definition, much less declares that it needs dbms access
|
|
$classifiedPackage.IsDbms | Should -BeTrue
|
|
}
|
|
|
|
It "Is IsSDK" {
|
|
$classifiedPackage.IsSDK | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context "Is a legacy WebApplication" {
|
|
$package = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'StickyWebApplication'
|
|
Version = '999.999.999'
|
|
}
|
|
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith { return @{ general = @{ element = 'StickyWebApplication'; componentType = 'WebApplication'}; webApplicationManifest = @{ appInstall = "Legacy" } } }
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $package -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is not going to web tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is going to app tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is not going to mic tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is not classified 'IsMicroservice'" {
|
|
$classifiedPackage.IsMicroservice | Should -BeFalse
|
|
}
|
|
|
|
It "Is not a dbms service" {
|
|
# because our fake service doesn't have a serviceManifest definition, much less declares that it needs dbms access
|
|
$classifiedPackage.IsDbms | Should -BeFalse
|
|
}
|
|
|
|
It "Is not IsSDK" {
|
|
$classifiedPackage.IsSDK | Should -BeFalse
|
|
}
|
|
}
|
|
|
|
Context "Is a web tier WebApplication" {
|
|
$package = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'StickyWebApplication'
|
|
Version = '999.999.999'
|
|
}
|
|
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith { return @{ general = @{ element = 'StickyWebApplication'; componentType = 'WebApplication'}; webApplicationManifest = @{ appInstall = "Generic" } } }
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $package -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is going to web tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is not going to app tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is not going to mic tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is not classified 'IsMicroservice'" {
|
|
$classifiedPackage.IsMicroservice | Should -BeFalse
|
|
}
|
|
|
|
It "Is not a dbms service" {
|
|
# because our fake service doesn't have a serviceManifest definition, much less declares that it needs dbms access
|
|
$classifiedPackage.IsDbms | Should -BeFalse
|
|
}
|
|
|
|
It "Is not IsSDK" {
|
|
$classifiedPackage.IsSDK | Should -BeFalse
|
|
}
|
|
}
|
|
|
|
Context -Name "OrbHotfix with NO serverTier" {
|
|
$hotfixPackage = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'FakeHotfixPackage'
|
|
Version = '999.999.999'
|
|
}
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith {
|
|
return @{
|
|
general = @{
|
|
element = 'HotfixDooDad';
|
|
componentType = 'Hotfix'
|
|
};
|
|
hotfixManifest = @{
|
|
targetVersion = "ORB.VERSION"
|
|
}
|
|
}
|
|
}
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $hotfixPackage -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is going to web tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is going to app tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is going to mic tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'IsHotfix'" {
|
|
$classifiedPackage.IsHotfix | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context -Name "OrbHotfix with EMPTY STRING serverTier" {
|
|
$hotfixPackage = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'FakeHotfixPackage'
|
|
Version = '999.999.999'
|
|
}
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith {
|
|
return @{
|
|
general = @{
|
|
element = 'HotfixDooDad';
|
|
componentType = 'Hotfix'
|
|
};
|
|
hotfixManifest = @{
|
|
targetVersion = "ORB.VERSION";
|
|
serverTier = ""
|
|
}
|
|
}
|
|
}
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $hotfixPackage -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is going to web tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is going to app tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is going to mic tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'IsHotfix'" {
|
|
$classifiedPackage.IsHotfix | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context -Name "OrbHotfix with APP serverTier" {
|
|
$hotfixPackage = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'FakeHotfixPackage'
|
|
Version = '999.999.999'
|
|
}
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith {
|
|
return @{
|
|
general = @{
|
|
element = 'HotfixDooDad';
|
|
componentType = 'Hotfix'
|
|
};
|
|
hotfixManifest = @{
|
|
targetVersion = "ORB.VERSION";
|
|
serverTier = "APP"
|
|
}
|
|
}
|
|
}
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $hotfixPackage -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is NOT going to WEB tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is going to APP tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is going to MIC tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'IsHotfix'" {
|
|
$classifiedPackage.IsHotfix | Should -BeTrue
|
|
}
|
|
|
|
}
|
|
Context -Name "OrbHotfix with WEB serverTier" {
|
|
$hotfixPackage = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'FakeHotfixPackage'
|
|
Version = '999.999.999'
|
|
}
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith {
|
|
return @{
|
|
general = @{
|
|
element = 'HotfixDooDad';
|
|
componentType = 'Hotfix'
|
|
};
|
|
hotfixManifest = @{
|
|
targetVersion = "ORB.VERSION";
|
|
serverTier = "WEB"
|
|
}
|
|
}
|
|
}
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $hotfixPackage -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is going to WEB tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is NOT going to APP tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is NOT going to MIC tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeFalse
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'IsHotfix'" {
|
|
$classifiedPackage.IsHotfix | Should -BeTrue
|
|
}
|
|
|
|
}
|
|
Context -Name "OrbHotfix with ALL serverTier" {
|
|
$hotfixPackage = @{
|
|
Feed = @{
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
IsSdk = $false
|
|
}
|
|
Name = 'FakeHotfixPackage'
|
|
Version = '999.999.999'
|
|
}
|
|
Mock -CommandName Get-PackageAlkamiManifestV2 -ModuleName $moduleForMock -MockWith {
|
|
return @{
|
|
general = @{
|
|
element = 'HotfixDooDad';
|
|
componentType = 'Hotfix'
|
|
};
|
|
hotfixManifest = @{
|
|
targetVersion = "ORB.VERSION";
|
|
serverTier = "ALL"
|
|
}
|
|
}
|
|
}
|
|
|
|
$classifiedPackage = Get-PackageMetadataV2 -Package $hotfixPackage -NugetCredential $fakeCredential -MicroserviceTierPresent
|
|
|
|
It "Is going to WEB tier" {
|
|
$classifiedPackage.InstallToWebTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is going to APP tier" {
|
|
$classifiedPackage.InstallToAppTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is going to MIC tier" {
|
|
$classifiedPackage.InstallToMicTier | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'HasAlkamiManifest'" {
|
|
$classifiedPackage.HasAlkamiManifest | Should -BeTrue
|
|
}
|
|
|
|
It "Is classified 'IsHotfix'" {
|
|
$classifiedPackage.IsHotfix | Should -BeTrue
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
Describe "Json Comparison Tests" {
|
|
|
|
$packageText = @"
|
|
# Installers
|
|
Alkami.MicroServices.Choco.Installer.Database 2.4.6
|
|
Alkami.MicroServices.Choco.Installer.Logic 2.4.6
|
|
Alkami.MicroServices.Choco.Installer.MasterDatabase 2.4.6
|
|
Alkami.Installer.Provider 3.0.6
|
|
Alkami.Installer.WebExtension 3.0.1
|
|
Alkami.Installer.Widget 3.0.2
|
|
|
|
# Infrastructure
|
|
Alkami.MicroServices.Broker.Host 2.8.1
|
|
Alkami.Services.Subscriptions.Host 3.9.0
|
|
|
|
# Providers
|
|
Alkami.App.Nag.Providers 1.1.4
|
|
Alkami.App.Processor.Wire.FedwireOutput 1.6.0
|
|
Alkami.App.Providers.CheckImaging.CorporateOne 1.0.1
|
|
Alkami.App.Providers.Multiplexer.Client 1.0.4
|
|
Alkami.App.Providers.Radium.BillPay 1.1.0
|
|
|
|
# Tier 1 Microservices
|
|
Alkami.MicroServices.Forms.Service.Host 1.1.1
|
|
Alkami.MicroServices.Authorization.Service.Host 1.4.3
|
|
Alkami.MicroServices.Security.Service.Host 2.17.2
|
|
Alkami.MicroServices.UserInterface.Service.Host 1.17.0
|
|
Alkami.MicroServices.Audit.Service.Host 6.11.0
|
|
Alkami.MicroServices.Contacts.Service.Host 2.4.8
|
|
Alkami.MicroServices.Holidays.Service.Host 2.1.12
|
|
Alkami.MicroServices.Images.Service.Host 3.1.14
|
|
Alkami.MicroServices.Notifications.Service.Host 1.6.12
|
|
Alkami.MicroServices.Settings.Service.Host 4.4.0
|
|
Alkami.MicroServices.SiteText.Service.Host 1.1.17
|
|
Alkami.MicroServices.Transactions.Service.Host 1.7.1
|
|
Alkami.MicroServices.EventManagement.Service.Host 3.4.9
|
|
|
|
# Tier 2 Microservices
|
|
Alkami.MicroServices.QuickApply.Service.Host 9.0.0
|
|
Alkami.MicroServices.Registration.Service.Host 2.5.1
|
|
Alkami.MicroServices.RemoteDeposit.Service.Host 2.4.1
|
|
Alkami.MicroServices.CardManagementProviders.SymConnect.Host 3.7.1
|
|
|
|
# Powershell Modules
|
|
Alkami.Ops.Common 3.0.3
|
|
Alkami.PowerShell.Choco 3.5.4
|
|
Alkami.PowerShell.Common 3.2.6
|
|
|
|
# SDK
|
|
DS.AccountService.MS.Service.Host 1.0.9
|
|
DS.BranchService.MS.Service.Host 1.0.10
|
|
DS.CMN.MS.Service.Host 1.0.8
|
|
DS.CopyRequestService.MS.Host 1.0.1
|
|
DS.CoreService.MS.Service.Host 2.0.5
|
|
DS.EStatements.MS.Service.Host 1.0.7
|
|
DS.MarketingEmailService.MS.Host 1.0.7
|
|
DS.MicroService.ContentService.Service.Host 2.0.4
|
|
DS.SecureMessage.MS.Service.Host 1.0.10
|
|
DS.Settings.MS.Service.Host 1.0.8
|
|
DS.SkipAPayService.MS.Host 1.0.8
|
|
|
|
# Symitar
|
|
Alkami.MicroServices.AutoBiller.Symitar.Service.Host 2.1.4
|
|
Alkami.MicroServices.RDCoreDeposit.Symitar.Service.Host 1.1.3
|
|
Alkami.MicroServices.SymConnectMultiplexer.Service.Host 2.1.2
|
|
Alkami.Providers.FakeSymitarProvider 1.2.3
|
|
"@;
|
|
|
|
# We get the tags from the nuspec which comes from proget. Mocking fake values...
|
|
Mock Get-PackageNuspecXmlV2 -ModuleName $moduleForMock {
|
|
param($Package, $Credential)
|
|
$name = $Package.Name
|
|
return (New-Object PSObject -Property @{
|
|
package = @{
|
|
metadata = @{ id = $name
|
|
tags = @(
|
|
"FakeTag",
|
|
"OtherFakeTag"
|
|
)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
Mock -CommandName Get-PackageFileV2 -ModuleName $moduleForMock -MockWith {}
|
|
|
|
# Strip out the comment lines and parse the packages out into package objects.
|
|
$packageText = ($packageText -split "`r`n") | Where-Object { $_ -notlike "*#*"}
|
|
$packages = Format-ParseChocoPackages -text $packageText -delimiter " "
|
|
$fakeCredential = New-Object System.Management.Automation.PSCredential('AlkamiFakeUser', (Get-SecureString 'abc123'))
|
|
|
|
# Attach fake source feeds onto each package, since we don't want to run this test against real nuget feeds.
|
|
foreach($package in $packages)
|
|
{
|
|
$feedMap = @{
|
|
Disabled = $false
|
|
IsDefault = $false
|
|
IsSdk = $package.Name -like "DS.*" # Mark the desert schools packages as SDK.
|
|
Name = if ($package.Name -like "DS.*") {"SDK"} Else {"Alkami"}
|
|
Priority = "0"
|
|
Source = "https://packagerepo.orb.alkamitech.com/nuget/fake.feed"
|
|
}
|
|
$package.Feed = New-Object PSObject -Property $feedMap
|
|
}
|
|
# Run classification function on all of the packages.
|
|
|
|
Context "When Generating Packages"{
|
|
# Create Test cases. See Get-ChocolateyParameterStrings tests.
|
|
$testCases = @()
|
|
foreach ($package in $packages){
|
|
$testCases += @{
|
|
caseDescription = 'Matches Pre-Defined Files'
|
|
package = $package
|
|
testName = $package.Name
|
|
environment = ''
|
|
}
|
|
}
|
|
|
|
Mock -CommandName Write-Host -MockWith {}
|
|
|
|
It "<caseDescription> for <testName>" -TestCases $testCases {
|
|
param(
|
|
$package,
|
|
$environment
|
|
)
|
|
|
|
# this long magic string is a barebones package folder with no useful contents. Just the basic nuget structure and a choco install file set
|
|
Mock Get-PackageFileListV2 -ModuleName $moduleForMock -MockWith {return (ConvertFrom-Json ('[{{"fullPath":"package/services/metadata/core-properties/","parentFullPath":"package/services/metadata/","name":"core-properties","isDirectory":true}},{{"fullPath":"package/services/metadata/","parentFullPath":"package/services/","name":"metadata","isDirectory":true}},{{"fullPath":"package/services/","parentFullPath":"package/","name":"services","isDirectory":true}},{{"fullPath":"package/","parentFullPath":"/","name":"package","isDirectory":true}},{{"fullPath":"package/services/metadata/core-properties/629d5521ad934906a0d3c36051d35320.psmdcp","parentFullPath":"package/services/metadata/core-properties/","name":"629d5521ad934906a0d3c36051d35320.psmdcp","isDirectory":false}},{{"fullPath":"lib/net472/","parentFullPath":"lib/","name":"net472","isDirectory":true}},{{"fullPath":"lib/","parentFullPath":"/","name":"lib","isDirectory":true}},{{"fullPath":"_rels/","parentFullPath":"/","name":"_rels","isDirectory":true}},{{"fullPath":"_rels/.rels","parentFullPath":"_rels/","name":".rels","isDirectory":false}},{{"fullPath":"tools/","parentFullPath":"/","name":"tools","isDirectory":true}},{{"fullPath":"tools/chocolateyInstall.ps1","parentFullPath":"tools/","name":"chocolateyInstall.ps1","isDirectory":false}},{{"fullPath":"tools/chocolateyUninstall.ps1","parentFullPath":"tools/","name":"chocolateyUninstall.ps1","isDirectory":false}},{{"fullPath":"[Content_Types].xml","parentFullPath":"/","name":"[Content_Types].xml","isDirectory":false}},{{"fullPath": "{0}.exe.config","parentFullPath": "/","name": "{0}.exe.config","isDirectory": false}}]' -f $package.Name))}.GetNewClosure()
|
|
|
|
# NR AppName comes from a nuspec. We're arbitrarily deciding that microservices have one and others don't for our tests.
|
|
Mock Get-AppSetting -ModuleName $moduleForMock -MockWith {
|
|
# Microservices have a NR app name
|
|
if(($package.Name -like "*.MicroService*.*") -or ($package.Name -like "*.MS.*")){
|
|
return "FakeNRAppName"
|
|
}
|
|
# Other packages have no NR app name.
|
|
else {
|
|
return $null
|
|
}
|
|
}.GetNewClosure()
|
|
|
|
$packageData = Get-PackageMetadataV2 -Package $package -NugetCredential $fakeCredential
|
|
|
|
$packageJson = ConvertTo-Json $packageData
|
|
|
|
# Find matching file in .\\TestFiles\PackageObjects\
|
|
$jsonFiles = Get-ChildItem -Path $PSScriptRoot\..\TestFiles\PackageObjects
|
|
foreach ($file in $jsonFiles) {
|
|
if ($file.Name -like "$($package.Name).json" ) {
|
|
$fileContents = Get-Content $file.FullName
|
|
# Sort the Json Alphabetically
|
|
|
|
Write-OrderedJson -JsonObject $fileContents -Path "TestDrive:\expected.json"
|
|
Write-OrderedJson -JsonObject $packageJson -Path "TestDrive:\results.json"
|
|
|
|
$expectedContent = Get-Content "TestDrive:\expected.json"
|
|
$actualContent = Get-Content "TestDrive:\results.json"
|
|
|
|
# Debugging a single package can be frustrating without being able to look at it specifically.
|
|
# Specifying a specific package name here will run the test for a single package, and give 2 files that you can examine in beyond compare.
|
|
# To do so, uncomment this if block and the Copy-Item lines. (You'll get automatic "successes" for other packages as they would no longer run the assert step)
|
|
|
|
#if($package.Name -eq "Alkami.Installer.Widget"){
|
|
#Copy-Item "TestDrive:\Expected.json" ".\Expected.Json"
|
|
#Copy-Item "TestDrive:\results.json" ".\results.Json"
|
|
# Assert equality.
|
|
$actualContent | Should -Be $expectedContent
|
|
#}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |