32 lines
1.4 KiB
PowerShell
32 lines
1.4 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 "New-SftpPasswordHash" {
|
|
|
|
$fakePassword = "ThisIsAPassword"
|
|
|
|
Mock -CommandName Get-LogLeadName -ModuleName $moduleForMock -MockWith { return 'New-SftpPasswordHash.tests' }
|
|
Mock -CommandName Write-Error -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName Invoke-Command -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName New-PSSession -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName Remove-PSSession -ModuleName $moduleForMock -MockWith {}
|
|
|
|
Context "Error Handling" {
|
|
|
|
Mock -CommandName Test-Path -ModuleName $moduleForMock -MockWith { return $false }
|
|
|
|
It "Writes Error and Returns Null If Password Hash DLL Not Found" {
|
|
|
|
New-SftpPasswordHash -Password $fakePassword | Should -BeNull
|
|
|
|
Assert-MockCalled -CommandName Write-Error `
|
|
-ParameterFilter { $Message -match "Unable to find EncryptPassword.dll" } -Times 1 -Exactly -Scope It
|
|
Assert-MockCalled -CommandName Invoke-Command -Times 0 -Exactly -Scope It
|
|
}
|
|
}
|
|
} |