Update Connect-ZertoServer.Tests.ps1

This commit is contained in:
2023-06-22 18:03:58 -07:00
parent cce96a9783
commit e7694831b3
+28 -28
View File
@@ -21,7 +21,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
It "port variable has a non-mandatory String parameter" { It "port variable has a non-mandatory String parameter" {
Get-Command $global:function | Should -HaveParameter zertoPort -Not -Mandatory Get-Command $global:function | Should -HaveParameter zertoPort -Not -Mandatory
Get-Command $global:function | Should -HaveParameter zertoPort -Type String Get-Command $global:function | Should -HaveParameter zertoPort -Type String
Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "9669" Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "443"
} }
It "port variable does not accecpt an empty or null input" { It "port variable does not accecpt an empty or null input" {
@@ -47,7 +47,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
} }
It "has a switch parameter to return the headers" { It "has a switch parameter to return the headers" {
Get-Command $global:function | Should -HaveParameter returnHeaders #Get-Command $global:function | Should -HaveParameter returnHeaders
Get-Command $global:function | Should -HaveParameter returnHeaders -Type Switch Get-Command $global:function | Should -HaveParameter returnHeaders -Type Switch
} }
@@ -73,7 +73,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
$server = '192.168.1.100' $server = '192.168.1.100'
$password = ConvertTo-SecureString -String "NotARealPassword" -AsPlainText -Force $password = ConvertTo-SecureString -String "NotARealPassword" -AsPlainText -Force
$credential = New-Object pscredential('NotARealUser', $password) $credential = New-Object pscredential('NotARealUser', $password)
$now = $(Get-Date).ticks #$now = $(Get-Date).ticks
Connect-ZertoServer -zertoServer $server -credential $credential Connect-ZertoServer -zertoServer $server -credential $credential
} }
@@ -84,7 +84,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
It "Module Scope zvmPort variable tests" { It "Module Scope zvmPort variable tests" {
$script:zvmPort | Should -Not -BeNullOrEmpty $script:zvmPort | Should -Not -BeNullOrEmpty
$script:zvmPort | Should -Be '9669' $script:zvmPort | Should -Be '443'
} }
It "Module Scope zvmLastAction variable tests" { It "Module Scope zvmLastAction variable tests" {
@@ -92,38 +92,38 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
$script:zvmLastAction | Should -BeGreaterOrEqual $now $script:zvmLastAction | Should -BeGreaterOrEqual $now
} }
It "Module Scope zvmHeaders variable tests" { #It "Module Scope zvmHeaders variable tests" {
$script:zvmHeaders | Should -Not -BeNullOrEmpty # $script:zvmHeaders | Should -Not -BeNullOrEmpty
$script:zvmHeaders | Should -BeOfType PSCustomObject # $script:zvmHeaders | Should -BeOfType PSCustomObject
$script:zvmHeaders.keys.count | Should -BeExactly 3 # $script:zvmHeaders.keys.count | Should -BeExactly 3
$script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue #$script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue
$script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue # $script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue
$script:zvmHeaders['x-zerto-session'] | Should -BeOfType String #$script:zvmHeaders['x-zerto-session'] | Should -BeOfType String
$script:zvmHeaders['Accept'] | Should -BeOfType String # $script:zvmHeaders['Accept'] | Should -BeOfType String
} #}
$headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders #$headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders
It "returns a Hashtable with 2 keys" { #It "returns a Hashtable with 2 keys" {
$headers | Should -BeOfType Hashtable # $headers | Should -BeOfType Hashtable
$headers.keys.count | Should -Be 3 # $headers.keys.count | Should -Be 3
} #}
It "return value has a key called 'x-zerto-session'" { #It "return value has a key called 'x-zerto-session'" {
$headers.ContainsKey('x-zerto-session') | Should -Be $true # $headers.ContainsKey('x-zerto-session') | Should -Be $true
} #}
It "return key 'x-zerto-session' value should be a string" { #It "return key 'x-zerto-session' value should be a string" {
$headers['x-zerto-session'] | Should -BeOfType "String" # $headers['x-zerto-session'] | Should -BeOfType "String"
$headers['x-zerto-session'] | Should -BeExactly "e34da0b0-4bc2-4cda-b316-0384e35bdca5" # $headers['x-zerto-session'] | Should -BeExactly "e34da0b0-4bc2-4cda-b316-0384e35bdca5"
} #}
It "return value has a key called 'accept'" { It "return value has a key called 'accept'" {
$headers.ContainsKey('accept') | Should -Be $true $headers.ContainsKey('accept') | Should -Be $true
} }
It "return key 'accept' value should be 'application/json'" { #It "return key 'accept' value should be 'application/json'" {
$headers['accept'] | Should -Be 'application/json' # $headers['accept'] | Should -Be 'application/json'
} #}
It "should not require a port to be specified" { It "should not require a port to be specified" {
Connect-ZertoServer -zertoServer $Server -credential $credential Connect-ZertoServer -zertoServer $Server -credential $credential