diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 8462c1f..a0d48b7 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -1,25 +1,39 @@ -$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' -. ../$sut -. ../Invoke-ZertoRestRequest.ps1 -. ../Disconnect-ZertoServer.ps1 +$moduleFileName = "ZertoApiWrapper.psm1" +$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' +$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' +$modulePath = $filePath -replace "Public", "" +Import-Module $modulePath/$moduleFileName -Force -$credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml -$zertoServer = "192.168.222.20" -$zertoPort = "9669" +$userName = "zerto\build" +$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force +$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) + +# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml +$zertoServer = "192.168.1.100" +$zertoPort = "7669" Describe "Connect-ZertoServer" { it "should exist" { - "../Invoke-ZertoRestRequest.ps1" | should exist + "$filePath\$fileName" | should exist } it "has a function called Connect-ZertoServer" { get-command Connect-ZertoServer | should be $true } - Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential - it "set an Env variable called zertoConnectionInformation" { - Test-Path Env:/zertoConnectionInformation | should be $true + $headers = Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential + it "returns a Hashtable with 2 keys" { + $headers.keys.count | should be 2 } - it "set an Env variable called zertoAuthorizationHeaders" { - Test-Path Env:/zertoAuthorizationHeaders | should be $true + it "return value has a key called 'x-zerto-session'" { + $headers.ContainsKey('x-zerto-session') | should be $true + } + it "return key 'x-zerto-session' value should be a string" { + $headers['x-zerto-session'].gettype().name | should be "String" + } + it "return value has a key called 'accept'" { + $headers.ContainsKey('accept') | should be $true + } + it "return key 'accept' value should be 'application/json'" { + $headers['accept'] | should be 'application/json' } Disconnect-ZertoServer }