Skip to content

Commit

Permalink
test cascade
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaranionjc committed Dec 16, 2024
1 parent 6d0e919 commit 37931fe
Showing 1 changed file with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,4 @@ Describe -Tag:('JCUser') "Remove-JCUser 2.16.0" {
Remove-JCUser -UserID $ManagerUser._id -force
Remove-JCUser -UserID $NewUser._id -force
}

It "Remove JumpCloud Manager1 that is also managed by a Manager2. Cascade managed users manager to Manager2" {
$ManagerUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser
$ManagerUser2 = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser
$NewUser = New-RandomUser -Domain "delUser.$(New-RandomString -NumberOfChars 5)" | New-JCUser

# Set the manager for user
Set-JCUser -UserID $ManagerUser._id -manager $ManagerUser2._id # ManagerUser2 is the manager of ManagerUser
Set-JCUser -UserID $NewUser._id -manager $ManagerUser._id

Mock -CommandName Read-Host -MockWith { return 'y' }
# Remove the manager and set the new manager
$RemoveUser = Remove-JCUser -UserID $ManagerUser._id # Remove ManagerUser and should cascade to ManagerUser2. Prompts should be auto answered with 'Y'

# The manager should be removed and the new manager should be set
$RemoveUser.Results | Should -Be 'Deleted'
# The new manager should be set to ManagerUser2
$manager = Get-JCUser -UserID $NewUser._id | Select-Object -ExpandProperty manager
$manager | Should -Be $ManagerUser2._id
# Clean up
Remove-JCUser -UserID $ManagerUser2._id -force
Remove-JCUser -UserID $NewUser._id -force
}
}

0 comments on commit 37931fe

Please sign in to comment.