From 8aa673e37586491f71dee261f365c27c17f29c5e Mon Sep 17 00:00:00 2001 From: dmilov Date: Tue, 6 Oct 2020 10:56:00 +0300 Subject: [PATCH] Add tests for String to SsoAdminServer argument transformation in Disconnect-SsoAdminServer funciton --- .../net45/VMware.vSphere.SsoAdmin.Utils.dll | Bin 6656 -> 7168 bytes .../VMware.vSphere.SsoAdmin.Utils.dll | Bin 7168 -> 7168 bytes ...inServerArgumentTransformationAttribute.cs | 2 +- .../src/test/ConnectDisconnect.Tests.ps1 | 57 +++++++++++++++++- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll b/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll index 0a89d22c152b75fb7d87c676aeccd213d9a4f0ee..405d8fa7e87736f9ffecfc307d18041aba908c6e 100644 GIT binary patch delta 342 zcmZoLX|R~kp}1QxV>$yAJYY~#;AS*nU=RWda6knAOkl^E|$W@Hj(E#P5bV4NH%X1+Oq=>enU z2cS~r&|rocTnr2#t;+79o-ROo#b!^I)trpIlfUv-s22lGEMrJyC}PM2l1U6X45A#8*0z1~1imwjqU@J9?POr|4PXMAav6v>0NuA?a-o1YYqLHB zL-XWb0c8RAjkmcc-DP*2a)tex-jaZGlMe_SGlB{#!UTZ^SzfSh{b#UKN>*{dF8d{* zb{KdAVk=Bk6a)I|yrBJNd5MRNlMR@pH}eU7X5|Ei70{Oq3Ms?N*JqCu5$%;%m zlOq|`xxk7PfQkercQI-+3QgX|sLm)c`5vPZ`(DTP)mCaN5&M+DtKb*IPfzdaB324G)AYKD>+ZvFwp@0!c3j?t_5ZCJi z@#KjD$^uWs`d>ZU{n~Nrd&%2+>+f++J|b|;2r4Le6)Ffa`U%hX)K1N{Dx4R+TFwEr m!@vs=TVbN27|@TG1?@NUiF{_|RA68LdX?di{boU-Z;SxYOj!Q#I&xo={R3}ey6mEnwXlNlM+Sx@LOFoaB2WYU=&$*9g)F}abko-t@L zBa<-e9UcY-#>tIB=9>eU9xzINU|?WS4h?3I;AUVD0I}UeJzapb#%50zZ7#;%$)$W1 z>ctES3}p<73`Go?Kr)FThar`Lk%8g!q9^zL=WX|1+mqLs*A;$pvjG1NM$xxP-K!ZG zeFK<)rrZW%8GRt0d{;o6^*fODeezEMWdVzxl85y&P0l@nFU&%MT@xqk2%a;73GzS% zfd*;wvOi6Hc=nLN!IdY%-3)-HK|unDtuRqhj4^1lv(RzI&3q!iSeZ%;HVaCj!Lsg#;SB5i6O=e_NXFa0Fzz{N7kx6HAB%?ZG$>c`HdPcv= zj7-9;H+UEr7$-LhnQsnYdcY|8hJk@WIW(9-gqwju0K|3=^>hK!Dw{o7w7D3&CztY7 zC@V0OF(fh+F=PVCB!(P@R0hWKGASdm*+IU0cg9D~$tat(S%iNFqo}O&t?vwsz5z@? z6K(^sggy{YekdT$`WeXjJo&GHvVdyBZg(!erLMC~6Ds=tol&1`Ab8FQD##iI6$Bbo zUL)|~B7dOg%p+>odYlY^ra?grh^;VDQH;@Vv%Ao7#)$?joB2e3u`(4HY!;My59G50 E0Jg$Uy8r+H diff --git a/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StirngToSsoAdminServerArgumentTransformationAttribute.cs b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StirngToSsoAdminServerArgumentTransformationAttribute.cs index 16d200f..5d8c885 100644 --- a/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StirngToSsoAdminServerArgumentTransformationAttribute.cs +++ b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StirngToSsoAdminServerArgumentTransformationAttribute.cs @@ -43,7 +43,7 @@ namespace VMware.vSphere.SsoAdmin.Utils result = obnMatchingServers.ToArray(); } else { // Non-terminating error for not matching value - engineIntrinsics.Host.UI.WriteErrorLine($"'{obnValue}' doesn't match any objects in $global:DefaultSsoAdminServer variable"); + engineIntrinsics.Host.UI.WriteErrorLine($"'{obnValue}' doesn't match any objects in $global:DefaultSsoAdminServers variable"); } } diff --git a/Modules/VMware.vSphere.SsoAdmin/src/test/ConnectDisconnect.Tests.ps1 b/Modules/VMware.vSphere.SsoAdmin/src/test/ConnectDisconnect.Tests.ps1 index 53ef770..e7ee61c 100644 --- a/Modules/VMware.vSphere.SsoAdmin/src/test/ConnectDisconnect.Tests.ps1 +++ b/Modules/VMware.vSphere.SsoAdmin/src/test/ConnectDisconnect.Tests.ps1 @@ -114,7 +114,7 @@ Describe "Connect-SsoAdminServer and Disconnect-SsoAdminServer Tests" { -SkipCertificateCheck) # Act - + # Assert {Disconnect-SsoAdminServer} | should -Throw 'Connected to more than 1 SSO server, please specify a SSO server via -Server parameter' (Compare-Object $global:DefaultSsoAdminServers $expected -IncludeEqual).Count | Should Be 2 @@ -159,5 +159,60 @@ Describe "Connect-SsoAdminServer and Disconnect-SsoAdminServer Tests" { $global:DefaultSsoAdminServers | Should Not Contain $expected $expected.IsConnected | Should Be $false } + + It 'Disconnects DefaultSsoAdminServers when * is specified on -Server parameter' { + # Arrange + $expected = Connect-SsoAdminServer ` + -Server $VcAddress ` + -User $User ` + -Password $Password ` + -SkipCertificateCheck + + # Act + Disconnect-SsoAdminServer -Server "*" + + + # Assert + $global:DefaultSsoAdminServers.Count | Should Be 0 + $expected.IsConnected | Should Be $false + } + + It 'Disconnects server specified as string that is equal to VC Address' { + # Arrange + $expected = Connect-SsoAdminServer ` + -Server $VcAddress ` + -User $User ` + -Password $Password ` + -SkipCertificateCheck + + # Act + Disconnect-SsoAdminServer -Server $VcAddress + + + # Assert + $global:DefaultSsoAdminServers.Count | Should Be 0 + $expected.IsConnected | Should Be $false + } + + It 'Disconnect-SsoAdminServer fails when string that does not match any servers is specified' { + # Arrange + $expected = Connect-SsoAdminServer ` + -Server $VcAddress ` + -User $User ` + -Password $Password ` + -SkipCertificateCheck + + # Act + { Disconnect-SsoAdminServer -Server "testserver" } | Should Throw + + + # Assert + $global:DefaultSsoAdminServers.Count | Should Be 1 + $global:DefaultSsoAdminServers[0] | Should Be $expected + $expected.IsConnected | Should Be $true + + # Cleanup + Disconnect-SsoAdminServer -Server $expected + } } } \ No newline at end of file