diff --git a/Tests/common.ps1 b/Tests/common.ps1 index 5a56d95b2..a64f50e46 100644 --- a/Tests/common.ps1 +++ b/Tests/common.ps1 @@ -46,6 +46,11 @@ $script:pester_zone1 = "pester_zone %/*?1" $script:pester_zone2 = "pester_zone2" $script:pester_userlocal = "pester_userlocal" $script:pester_userlocalpassword = ConvertTo-SecureString "pester_userlocalpassword" -AsPlainText -Force +$script:pester_userlocal2 = "pester_userlocal2" +$script:pester_userlocal3 = "pester_userlocal3" +$script:pester_userlocal4 = "pester_userlocal4" +$script:pester_usergroup1 = "pester_usergroup1" +$script:pester_usergroup2 = "pester_usergroup2" . ../credential.ps1 #TODO: Add check if no ipaddress/login/password info... diff --git a/Tests/integration/UserGroup.Tests.ps1 b/Tests/integration/UserGroup.Tests.ps1 index a87729880..6e836dd45 100644 --- a/Tests/integration/UserGroup.Tests.ps1 +++ b/Tests/integration/UserGroup.Tests.ps1 @@ -15,12 +15,11 @@ Describe "Get User Group" { BeforeAll { #Create User object - Add-FGTUserLocal -Name $pester_User1 -ip 192.0.2.1 -mask 255.255.255.255 - Add-FGTUserLocal -Name $pester_User2 -ip 192.0.2.2 -mask 255.255.255.255 + Add-FGTUserLocal -Name $pester_userlocal -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal2 -passwd $pester_userlocalpassword #Create Usergroup object with one member - $script:addrgrp = Add-FGTUserGroup -name $pester_Usergroup1 -member $pester_User1 - $script:uuid = $addrgrp.uuid - Add-FGTUserGroup -name $pester_Usergroup2 -member $pester_User2 + Add-FGTUserGroup -name $pester_usergroup1 -member $pester_userlocal + Add-FGTUserGroup -name $pester_usergroup2 -member $pester_userlocal2 } It "Get User Group Does not throw an error" { @@ -30,65 +29,59 @@ Describe "Get User Group" { } It "Get ALL User Group" { - $Usergroup = Get-FGTUserGroup - $Usergroup.count | Should -Not -Be $NULL + $usergroup = Get-FGTUserGroup + $usergroup.count | Should -Not -Be $NULL } It "Get ALL User Group with -skip" { - $Usergroup = Get-FGTUserGroup -skip - $Usergroup.count | Should -Not -Be $NULL + $usergroup = Get-FGTUserGroup -skip + $usergroup.count | Should -Not -Be $NULL } - It "Get User Group ($pester_Usergroup1)" { - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 + It "Get User Group ($pester_usergroup1)" { + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 } - It "Get User Group ($pester_Usergroup1) and confirm (via Confirm-FGTUserGroup)" { - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - Confirm-FGTUserGroup ($Usergroup) | Should -Be $true + It "Get User Group ($pester_usergroup1) and confirm (via Confirm-FGTUserGroup)" { + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + Confirm-FGTUserGroup ($usergroup) | Should -Be $true } - It "Get User Group ($pester_Usergroup1) and meta" { - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 -meta - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.q_ref | Should -Not -BeNullOrEmpty - $Usergroup.q_static | Should -Not -BeNullOrEmpty - $Usergroup.q_no_rename | Should -Not -BeNullOrEmpty - $Usergroup.q_global_entry | Should -Not -BeNullOrEmpty - $Usergroup.q_type | Should -Not -BeNullOrEmpty - $Usergroup.q_path | Should -Be "user" - $Usergroup.q_name | Should -Be "group" - $Usergroup.q_mkey_type | Should -Be "string" + It "Get User Group ($pester_usergroup1) and meta" { + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 -meta + $usergroup.name | Should -Be $pester_usergroup1 + $usergroup.q_ref | Should -Not -BeNullOrEmpty + $usergroup.q_static | Should -Not -BeNullOrEmpty + $usergroup.q_no_rename | Should -Not -BeNullOrEmpty + $usergroup.q_global_entry | Should -Not -BeNullOrEmpty + $usergroup.q_type | Should -Not -BeNullOrEmpty + $usergroup.q_path | Should -Be "user" + $usergroup.q_name | Should -Be "group" + $usergroup.q_mkey_type | Should -Be "string" if ($DefaultFGTConnection.version -ge "6.2.0") { - $Usergroup.q_no_edit | Should -Not -BeNullOrEmpty + $usergroup.q_no_edit | Should -Not -BeNullOrEmpty } - $Usergroup.q_class | Should -Not -BeNullOrEmpty + $usergroup.q_class | Should -Not -BeNullOrEmpty } Context "Search" { - It "Search User Group by name ($pester_Usergroup1)" { - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - @($Usergroup).count | Should -be 1 - $Usergroup.name | Should -Be $pester_Usergroup1 - } - - It "Search User Group by uuid ($script:uuid)" { - $Usergroup = Get-FGTUserGroup -uuid $script:uuid - @($Usergroup).count | Should -be 1 - $Usergroup.name | Should -Be $pester_Usergroup1 + It "Search User Group by name ($pester_usergroup1)" { + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + @($usergroup).count | Should -be 1 + $usergroup.name | Should -Be $pester_usergroup1 } } AfterAll { #Remove User group before User... - Get-FGTUserGroup -name $pester_Usergroup1 | Remove-FGTUserGroup -confirm:$false - Get-FGTUserGroup -name $pester_Usergroup2 | Remove-FGTUserGroup -confirm:$false + Get-FGTUserGroup -name $pester_usergroup1 | Remove-FGTUserGroup -confirm:$false + Get-FGTUserGroup -name $pester_usergroup2 | Remove-FGTUserGroup -confirm:$false - Get-FGTUserLocal -name $pester_User1 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User2 | Remove-FGTUser -confirm:$false + Get-FGTUserLocal -name $pester_userlocal | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal2 | Remove-FGTUserLocal -confirm:$false } } @@ -97,107 +90,62 @@ Describe "Add User Group" { BeforeAll { #Create some User object - Add-FGTUserLocal-Name $pester_User1 -ip 192.0.2.1 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User2 -ip 192.0.2.2 -mask 255.255.255.255 + Add-FGTUserLocal -Name $pester_userlocal -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal2 -passwd $pester_userlocalpassword } AfterEach { - Get-FGTUserGroup -name $pester_Usergroup1 | Remove-FGTUserGroup -confirm:$false - } - - It "Add User Group $pester_Usergroup1 (with 1 member)" { - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + Get-FGTUserGroup -name $pester_usergroup1 | Remove-FGTUserGroup -confirm:$false } - It "Add User Group $pester_Usergroup1 (with 1 member and a comment)" { - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 -comment "Add via PowerFGT" - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -Be "Add via PowerFGT" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Add User Group $pester_usergroup1 (with 1 member)" { + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "1" + $usergroup.member.name | Should -BeIn $pester_userlocal } - It "Add User Group $pester_Usergroup1 (with 1 member and visibility disable)" { - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 -visibility:$false - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be "disable" - } + It "Add User Group $pester_usergroup1 (with 2 members)" { + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal, $pester_userlocal2 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2 } - It "Add User Group $pester_Usergroup1 (with 2 members)" { - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1, $pester_User2 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Add User Group $pester_usergroup1 (with 1 member and data (1 field))" { + $data = @{ "authtimeout" = 23 } + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal -data $data + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "1" + $usergroup.member.name | Should -BeIn $pester_userlocal + $usergroup.authtimeout | Should -Be "23" } - It "Add User Group $pester_Usergroup1 (with 1 member and data (1 field))" { - $data = @{ "color" = 23 } - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 -data $data - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -BeNullOrEmpty - $Usergroup.color | Should -Be "23" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Add User Group $pester_usergroup1 (with 1 member and data (2 fields))" { + $data = @{ "authtimeout" = 23; "auth-concurrent-override" = "enable" } + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal -data $data + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "1" + $usergroup.member.name | Should -BeIn $pester_userlocal + $usergroup.authtimeout | Should -Be "23" + $usergroup.'auth-concurrent-override' | Should -Be "enable" } - It "Add User Group $pester_Usergroup1 (with 1 member and data (2 fields))" { - $data = @{ "color" = 23; "comment" = "Add via PowerFGT and -data" } - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 -data $data - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -Be "Add via PowerFGT and -data" - $Usergroup.color | Should -Be "23" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } - } - - It "Try to Add User Group $pester_Usergroup1 (but there is already a object with same name)" { + It "Try to Add User Group $pester_usergroup1 (but there is already a object with same name)" { #Add first User Group - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal #Add Second User Group with same name - { Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 } | Should -Throw "Already an Usergroup object using the same name" + { Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal } | Should -Throw "Already an User Group object using the same name" } AfterAll { - Get-FGTUserLocal -name $pester_User1 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User2 | Remove-FGTUser -confirm:$false + Get-FGTUserLocal -name $pester_userlocal | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal2 | Remove-FGTUserLocal -confirm:$false } } @@ -206,65 +154,50 @@ Describe "Add User Group Member" { BeforeAll { #Create some User object - Add-FGTUserLocal-Name $pester_User1 -ip 192.0.2.1 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User2 -ip 192.0.2.2 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User3 -ip 192.0.2.3 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User4 -ip 192.0.2.4 -mask 255.255.255.255 + Add-FGTUserLocal -Name $pester_userlocal -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal2 -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal3 -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal4 -passwd $pester_userlocalpassword } BeforeEach { - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal } AfterEach { - Get-FGTUserGroup -name $pester_Usergroup1 | Remove-FGTUserGroup -confirm:$false - } - - It "Add 1 member to User Group $pester_Usergroup1 (with 1 member before)" { - Get-FGTUserGroup -Name $pester_Usergroup1 | Add-FGTUserGroupMember -member $pester_User2 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + Get-FGTUserGroup -name $pester_usergroup1 | Remove-FGTUserGroup -confirm:$false } - It "Add 2 members to User Group $pester_Usergroup1 (with 1 member before)" { - Get-FGTUserGroup -Name $pester_Usergroup1 | Add-FGTUserGroupMember -member $pester_User2, $pester_User3 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "3" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2, $pester_User3 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Add 1 member to User Group $pester_usergroup1 (with 1 member before)" { + Get-FGTUserGroup -Name $pester_usergroup1 | Add-FGTUserGroupMember -member $pester_userlocal2 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2 } - It "Add 2 members to User Group $pester_Usergroup1 (with 2 members before)" { - Get-FGTUserGroup -Name $pester_Usergroup1 | Add-FGTUserGroupMember -member $pester_User2 - Get-FGTUserGroup -Name $pester_Usergroup1 | Add-FGTUserGroupMember -member $pester_User3, $pester_User4 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "4" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2, $pester_User3, $pester_User4 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Add 2 members to User Group $pester_usergroup1 (with 1 member before)" { + Get-FGTUserGroup -Name $pester_usergroup1 | Add-FGTUserGroupMember -member $pester_userlocal2, $pester_userlocal3 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "3" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2, $pester_userlocal3 + } + + It "Add 2 members to User Group $pester_usergroup1 (with 2 members before)" { + Get-FGTUserGroup -Name $pester_usergroup1 | Add-FGTUserGroupMember -member $pester_userlocal2 + Get-FGTUserGroup -Name $pester_usergroup1 | Add-FGTUserGroupMember -member $pester_userlocal3, $pester_userlocal4 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "4" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2, $pester_userlocal3, $pester_userlocal4 } AfterAll { - Get-FGTUserLocal -name $pester_User1 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User2 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User3 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User4 | Remove-FGTUser -confirm:$false + Get-FGTUserLocal -name $pester_userlocal | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal2 | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal3 | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal4 | Remove-FGTUserLocal -confirm:$false } } @@ -273,114 +206,64 @@ Describe "Configure User Group" { BeforeAll { #Create some User object - Add-FGTUserLocal-Name $pester_User1 -ip 192.0.2.1 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User2 -ip 192.0.2.2 -mask 255.255.255.255 + Add-FGTUserLocal -Name $pester_userlocal -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal2 -passwd $pester_userlocalpassword - $addrgrp = Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 + $addrgrp = Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal $script:uuid = $addrgrp.uuid } - It "Change comment" { - Get-FGTUserGroup -name $pester_Usergroup1 | Set-FGTUserGroup -comment "Modified by PowerFGT" - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -Be "Modified by PowerFGT" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Change 1 Member ($pester_userlocal2)" { + Get-FGTUserGroup -name $pester_usergroup1 | Set-FGTUserGroup -member $pester_userlocal2 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "1" + $usergroup.member.name | Should -BeIn $pester_userlocal2 } - It "Change visiblity" { - Get-FGTUserGroup -name $pester_Usergroup1 | Set-FGTUserGroup -visibility:$false - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -Be "Modified by PowerFGT" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be "disable" - } - } - - It "Change 1 Member ($pester_User2)" { - Get-FGTUserGroup -name $pester_Usergroup1 | Set-FGTUserGroup -member $pester_User2 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User2 - $Usergroup.comment | Should -Be "Modified by PowerFGT" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be "disable" - } - } - - It "Change 2 Members ($pester_User1 and $pester_User2)" { - Get-FGTUserGroup -name $pester_Usergroup1 | Set-FGTUserGroup -member $pester_User1, $pester_User2 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2 - $Usergroup.comment | Should -Be "Modified by PowerFGT" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be "disable" - } + It "Change 2 Members ($pester_userlocal and $pester_userlocal2)" { + Get-FGTUserGroup -name $pester_usergroup1 | Set-FGTUserGroup -member $pester_userlocal, $pester_userlocal2 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2 } It "Change -data (1 field)" { - $data = @{ "color" = 23 } - Get-FGTUserGroup -name $pester_Usergroup1 | Set-FGTUserGroup -data $data - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2 - $Usergroup.comment | Should -Be "Modified by PowerFGT" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be "disable" - } - $Usergroup.color | Should -Be "23" + $data = @{ "authtimeout" = 23 } + Get-FGTUserGroup -name $pester_usergroup1 | Set-FGTUserGroup -data $data + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2 + $usergroup.authtimeout | Should -Be "23" } It "Change -data (2 fields)" { - $data = @{ "color" = 4 ; comment = "Modified by PowerFGT via -data" } - Get-FGTUserGroup -name $pester_Usergroup1 | Set-FGTUserGroup -data $data - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2 - $Usergroup.comment | Should -Be "Modified by PowerFGT via -data" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be "disable" - } - $Usergroup.color | Should -Be "4" + $data = @{ "authtimeout" = 44 ; "auth-concurrent-override" = "enable" } + Get-FGTUserGroup -name $pester_usergroup1 | Set-FGTUserGroup -data $data + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2 + $usergroup.authtimeout | Should -Be "44" + $usergroup.'auth-concurrent-override' | Should -Be "enable" } It "Change Name" { - Get-FGTUserGroup -name $pester_Usergroup1 | Set-FGTUserGroup -name "pester_Usergroup1_change" - $Usergroup = Get-FGTUserGroup -name "pester_Usergroup1_change" - $Usergroup.name | Should -Be "pester_Usergroup1_change" - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2 - $Usergroup.comment | Should -Be "Modified by PowerFGT via -data" - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be "disable" - } + Get-FGTUserGroup -name $pester_usergroup1 | Set-FGTUserGroup -name "pester_usergroup1_change" + $usergroup = Get-FGTUserGroup -name "pester_usergroup1_change" + $usergroup.name | Should -Be "pester_usergroup1_change" + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2 } AfterAll { #Remove User group before User... - Get-FGTUserGroup -uuid $script:uuid | Remove-FGTUserGroup -confirm:$false + Get-FGTUserGroup -name pester_usergroup1_change | Remove-FGTUserGroup -confirm:$false - Get-FGTUserLocal -name $pester_User1 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User2 | Remove-FGTUser -confirm:$false + Get-FGTUserLocal -name $pester_userlocal | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal2 | Remove-FGTUserLocal -confirm:$false } } @@ -389,24 +272,19 @@ Describe "Copy User Group" { BeforeAll { #Create some User object - Add-FGTUserLocal-Name $pester_User1 -ip 192.0.2.1 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User2 -ip 192.0.2.2 -mask 255.255.255.255 + Add-FGTUserLocal -Name $pester_userlocal -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal2 -passwd $pester_userlocalpassword - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1, $pester_User2 + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal, $pester_userlocal2 } - It "Copy User Group ($pester_Usergroup1 => copy_pester_Usergroup1)" { - Get-FGTUserGroup -name $pester_Usergroup1 | Copy-FGTUserGroup -name copy_pester_Usergroup1 - $Usergroup = Get-FGTUserGroup -name copy_pester_Usergroup1 - $Usergroup.name | Should -Be "copy_pester_Usergroup1" - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User1, $pester_User2 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Copy User Group ($pester_usergroup1 => copy_pester_Usergroup1)" { + Get-FGTUserGroup -name $pester_usergroup1 | Copy-FGTUserGroup -name copy_pester_Usergroup1 + $usergroup = Get-FGTUserGroup -name copy_pester_Usergroup1 + $usergroup.name | Should -Be "copy_pester_Usergroup1" + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal, $pester_userlocal2 } AfterAll { @@ -415,10 +293,10 @@ Describe "Copy User Group" { #Remove copy_pester_User1 Get-FGTUserGroup -name copy_pester_Usergroup1 | Remove-FGTUserGroup -confirm:$false - Get-FGTUserGroup -name $pester_Usergroup1 | Remove-FGTUserGroup -confirm:$false + Get-FGTUserGroup -name $pester_usergroup1 | Remove-FGTUserGroup -confirm:$false - Get-FGTUserLocal -name $pester_User1 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User2 | Remove-FGTUser -confirm:$false + Get-FGTUserLocal -name $pester_userlocal | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal2 | Remove-FGTUserLocal -confirm:$false } } @@ -426,20 +304,20 @@ Describe "Copy User Group" { Describe "Remove User Group" { BeforeEach { - Add-FGTUserLocal-Name $pester_User1 -ip 192.0.2.1 -mask 255.255.255.255 + Add-FGTUserLocal -Name $pester_userlocal -passwd $pester_userlocalpassword - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1 + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal } - It "Remove User Group $pester_Usergroup1 by pipeline" { - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup | Remove-FGTUserGroup -confirm:$false - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup | Should -Be $NULL + It "Remove User Group $pester_usergroup1 by pipeline" { + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup | Remove-FGTUserGroup -confirm:$false + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup | Should -Be $NULL } AfterAll { - Get-FGTUserLocal -name $pester_User1 | Remove-FGTUser -confirm:$false + Get-FGTUserLocal -name $pester_userlocal | Remove-FGTUserLocal -confirm:$false } } @@ -448,55 +326,46 @@ Describe "Remove User Group Member" { BeforeAll { #Create some User object - Add-FGTUserLocal-Name $pester_User1 -ip 192.0.2.1 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User2 -ip 192.0.2.2 -mask 255.255.255.255 - Add-FGTUserLocal-Name $pester_User3 -ip 192.0.2.3 -mask 255.255.255.255 + Add-FGTUserLocal -Name $pester_userlocal -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal2 -passwd $pester_userlocalpassword + Add-FGTUserLocal -Name $pester_userlocal3 -passwd $pester_userlocalpassword } BeforeEach { - Add-FGTUserGroup -Name $pester_Usergroup1 -member $pester_User1, $pester_User2, $pester_User3 + Add-FGTUserGroup -Name $pester_usergroup1 -member $pester_userlocal, $pester_userlocal2, $pester_userlocal3 } AfterEach { - Get-FGTUserGroup -name $pester_Usergroup1 | Remove-FGTUserGroup -confirm:$false - } - - It "Remove 1 member to User Group $pester_Usergroup1 (with 3 members before)" { - Get-FGTUserGroup -Name $pester_Usergroup1 | Remove-FGTUserGroupMember -member $pester_User1 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "2" - $Usergroup.member.name | Should -BeIn $pester_User2, $pester_User3 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + Get-FGTUserGroup -name $pester_usergroup1 | Remove-FGTUserGroup -confirm:$false } - It "Remove 2 members to User Group $pester_Usergroup1 (with 3 members before)" { - Get-FGTUserGroup -Name $pester_Usergroup1 | Remove-FGTUserGroupMember -member $pester_User2, $pester_User3 - $Usergroup = Get-FGTUserGroup -name $pester_Usergroup1 - $Usergroup.name | Should -Be $pester_Usergroup1 - $Usergroup.uuid | Should -Not -BeNullOrEmpty - ($Usergroup.member).count | Should -Be "1" - $Usergroup.member.name | Should -BeIn $pester_User1 - $Usergroup.comment | Should -BeNullOrEmpty - if ($DefaultFGTConnection.version -lt "6.4.0") { - $Usergroup.visibility | Should -Be $true - } + It "Remove 1 member to User Group $pester_usergroup1 (with 3 members before)" { + Get-FGTUserGroup -Name $pester_usergroup1 | Remove-FGTUserGroupMember -member $pester_userlocal + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "2" + $usergroup.member.name | Should -BeIn $pester_userlocal2, $pester_userlocal3 } - It "Try Remove 3 members to User Group $pester_Usergroup1 (with 3 members before)" { - { - Get-FGTUserGroup -Name $pester_Usergroup1 | Remove-FGTUserGroupMember -member $pester_User1, $pester_User2, $pester_User3 - } | Should -Throw "You can't remove all members. Use Remove-FGTUserGroup to remove User Group" + It "Remove 2 members to User Group $pester_usergroup1 (with 3 members before)" { + Get-FGTUserGroup -Name $pester_usergroup1 | Remove-FGTUserGroupMember -member $pester_userlocal2, $pester_userlocal3 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "1" + $usergroup.member.name | Should -BeIn $pester_userlocal + } + + It "Remove 3 members to User Group $pester_usergroup1 (with 3 members before)" { + Get-FGTUserGroup -Name $pester_usergroup1 | Remove-FGTUserGroupMember -member $pester_userlocal, $pester_userlocal2, $pester_userlocal3 + $usergroup = Get-FGTUserGroup -name $pester_usergroup1 + $usergroup.name | Should -Be $pester_usergroup1 + ($usergroup.member).count | Should -Be "0" } AfterAll { - Get-FGTUserLocal-name $pester_User1 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal-name $pester_User2 | Remove-FGTUser -confirm:$false - Get-FGTUserLocal -name $pester_User3 | Remove-FGTUser -confirm:$false + Get-FGTUserLocal -name $pester_userlocal | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal2 | Remove-FGTUserLocal -confirm:$false + Get-FGTUserLocal -name $pester_userlocal3 | Remove-FGTUserLocal -confirm:$false } }