Implement New and Remove SsoGroup cmdlets.
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
This commit is contained in:
@@ -65,7 +65,7 @@ Describe "Connect-SsoAdminServer and Disconnect-SsoAdminServer Tests" {
|
||||
-User $User `
|
||||
-Password $Password `
|
||||
-ErrorAction Stop } | `
|
||||
Should -Throw "The SSL connection could not be established, see inner exception."
|
||||
Should -Throw "*The SSL connection could not be established, see inner exception.*"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,57 +20,111 @@ param(
|
||||
$modulePath = Join-Path (Split-Path $PSScriptRoot | Split-Path) "VMware.vSphere.SsoAdmin.psd1"
|
||||
Import-Module $modulePath
|
||||
|
||||
Describe "Get-SsoGroup Tests" {
|
||||
BeforeEach {
|
||||
Connect-SsoAdminServer `
|
||||
-Server $VcAddress `
|
||||
-User $User `
|
||||
-Password $Password `
|
||||
-SkipCertificateCheck
|
||||
}
|
||||
Describe "SsoGroup Tests" {
|
||||
BeforeEach {
|
||||
Connect-SsoAdminServer `
|
||||
-Server $VcAddress `
|
||||
-User $User `
|
||||
-Password $Password `
|
||||
-SkipCertificateCheck
|
||||
|
||||
AfterEach {
|
||||
$connectionsToCleanup = $global:DefaultSsoAdminServers.ToArray()
|
||||
foreach ($connection in $connectionsToCleanup) {
|
||||
Disconnect-SsoAdminServer -Server $connection
|
||||
}
|
||||
}
|
||||
$script:testGroupsToDelete = @()
|
||||
}
|
||||
|
||||
Context "Get-SsoGroup" {
|
||||
It 'Gets groups without filters' {
|
||||
# Act
|
||||
$actual = Get-SsoGroup
|
||||
AfterEach {
|
||||
|
||||
# Assert
|
||||
$actual | Should -Not -Be $null
|
||||
$actual.Count | Should -BeGreaterThan 0
|
||||
$actual[0].Name | Should -Not -Be $null
|
||||
$actual[0].Domain | Should -Be 'localos'
|
||||
}
|
||||
foreach ($group in $script:testGroupsToDelete) {
|
||||
Remove-SsoGroup -Group $group
|
||||
}
|
||||
|
||||
It 'Gets groups for default domain' {
|
||||
# Arrange
|
||||
$newUserName = "NewUser1"
|
||||
$password = '$tr0NG_TestPa$$w0rd'
|
||||
$connectionsToCleanup = $global:DefaultSsoAdminServers.ToArray()
|
||||
foreach ($connection in $connectionsToCleanup) {
|
||||
Disconnect-SsoAdminServer -Server $connection
|
||||
}
|
||||
}
|
||||
|
||||
## Create Person User to determine default domain name
|
||||
## Person Users are created in the default domain
|
||||
$newPersonUser = New-SsoPersonUser `
|
||||
-UserName $newUserName `
|
||||
-Password $password
|
||||
Context "Get-SsoGroup" {
|
||||
It 'Gets groups without filters' {
|
||||
# Act
|
||||
$actual = Get-SsoGroup
|
||||
|
||||
# Act
|
||||
$actual = Get-SsoGroup `
|
||||
-Domain $newPersonUser.Domain
|
||||
# Assert
|
||||
$actual | Should -Not -Be $null
|
||||
$actual.Count | Should -BeGreaterThan 0
|
||||
$actual[0].Name | Should -Not -Be $null
|
||||
$actual[0].Domain | Should -Be 'localos'
|
||||
}
|
||||
|
||||
# Assert
|
||||
$actual | Should -Not -Be $null
|
||||
$actual.Count | Should -BeGreaterThan 0
|
||||
$actual[0].Name | Should -Not -Be $null
|
||||
$actual[0].Domain | Should -Be $newPersonUser.Domain
|
||||
It 'Gets groups for default domain' {
|
||||
# Arrange
|
||||
$newUserName = "NewUser1"
|
||||
$password = '$tr0NG_TestPa$$w0rd'
|
||||
|
||||
# Cleanup
|
||||
Remove-SsoPersonUser -User $newPersonUser
|
||||
}
|
||||
}
|
||||
## Create Person User to determine default domain name
|
||||
## Person Users are created in the default domain
|
||||
$newPersonUser = New-SsoPersonUser `
|
||||
-UserName $newUserName `
|
||||
-Password $password
|
||||
|
||||
# Act
|
||||
$actual = Get-SsoGroup `
|
||||
-Domain $newPersonUser.Domain
|
||||
|
||||
# Assert
|
||||
$actual | Should -Not -Be $null
|
||||
$actual.Count | Should -BeGreaterThan 0
|
||||
$actual[0].Name | Should -Not -Be $null
|
||||
$actual[0].Domain | Should -Be $newPersonUser.Domain
|
||||
|
||||
# Cleanup
|
||||
Remove-SsoPersonUser -User $newPersonUser
|
||||
}
|
||||
}
|
||||
|
||||
Context "New-SsoGroup" {
|
||||
It 'Should create SsoGroup specifying only the name of the group' {
|
||||
# Arrange
|
||||
$expectedName = 'TestGroup1'
|
||||
|
||||
# Act
|
||||
$actual = New-SsoGroup -Name $expectedName
|
||||
|
||||
# Assert
|
||||
$actual | Should -Not -Be $null
|
||||
$script:testGroupsToDelete += $actual
|
||||
$actual.Name | Should -Be $expectedName
|
||||
$actual.Domain | Should -Be 'vsphere.local'
|
||||
$actual.Description | Should -Be ([string]::Empty)
|
||||
}
|
||||
|
||||
It 'Should create SsoGroup specifying name and description' {
|
||||
# Arrange
|
||||
$expectedName = 'TestGroup2'
|
||||
$expectedDescription = 'Test Description 2'
|
||||
|
||||
# Act
|
||||
$actual = New-SsoGroup -Name $expectedName -Description $expectedDescription
|
||||
|
||||
# Assert
|
||||
$actual | Should -Not -Be $
|
||||
$script:testGroupsToDelete += $actual
|
||||
$actual.Name | Should -Be $expectedName
|
||||
$actual.Domain | Should -Be 'vsphere.local'
|
||||
$actual.Description | Should -Be $expectedDescription
|
||||
}
|
||||
}
|
||||
|
||||
Context "Remove-SsoGroup" {
|
||||
It 'Should remove SsoGroup' {
|
||||
# Arrange
|
||||
$groupName = 'TestGroup3'
|
||||
$groupToRemove = New-SsoGroup -Name $groupName
|
||||
|
||||
# Act
|
||||
$groupToRemove | Remove-SsoGroup
|
||||
|
||||
# Assert
|
||||
Get-SsoGroup -Name $groupName -Domain 'vsphere.local' | Should -Be $null
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user