Skip to content

Commit

Permalink
UserLocal: Fix set change status
Browse files Browse the repository at this point in the history
  • Loading branch information
alagoutte committed Sep 16, 2024
1 parent 45f8c2c commit b963339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions PowerFGT/Public/cmdb/user/local.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,13 @@ function Set-FGTUserLocal {
throw "User type ($($userlocal.type)) need to be on the same type ($($PSCmdlet.ParameterSetName))"
}

if ($status) {
$_local | add-member -name "status" -membertype NoteProperty -Value "enable"
}
else {
$_local | add-member -name "status" -membertype NoteProperty -Value "disable"
if ($PsBoundParameters.ContainsKey('status')) {
if ($status) {
$_local | add-member -name "status" -membertype NoteProperty -Value "enable"
}
else {
$_local | add-member -name "status" -membertype NoteProperty -Value "disable"
}
}

switch ( $PSCmdlet.ParameterSetName ) {
Expand Down
10 changes: 5 additions & 5 deletions Tests/integration/UserLocal.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Describe "Configure User Local" {
Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -email_to "[email protected]"
$userlocal = Get-FGTUserLocal -name $pester_userlocal
$userlocal.name | Should -Be $pester_userlocal
$userlocal.status | Should -Be "disable"
$userlocal.status | Should -Be "enable"
$userlocal.'email-to' | Should -Be "[email protected]"
$userlocal.'two-factor' | Should -Be "disable"
}
Expand All @@ -170,7 +170,7 @@ Describe "Configure User Local" {
Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -two_factor email
$userlocal = Get-FGTUserLocal -name $pester_userlocal
$userlocal.name | Should -Be $pester_userlocal
$userlocal.status | Should -Be "disable"
$userlocal.status | Should -Be "enable"
$userlocal.'email-to' | Should -Be "[email protected]"
$userlocal.'two-factor' | Should -Be "email"
}
Expand All @@ -179,7 +179,7 @@ Describe "Configure User Local" {
Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -passwd $mywrongpassword
$userlocal = Get-FGTUserLocal -name $pester_userlocal
$userlocal.name | Should -Be $pester_userlocal
$userlocal.status | Should -Be "disable"
$userlocal.status | Should -Be "enable"
$userlocal.'email-to' | Should -Be "[email protected]"
$userlocal.'two-factor' | Should -Be "email"
}
Expand All @@ -202,7 +202,7 @@ Describe "Configure User Local" {
Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -name "pester_userlocal_change"
$userlocal = Get-FGTUserLocal -name "pester_userlocal_change"
$userlocal.name | Should -Be "pester_userlocal_change"
$userlocal.status | Should -Be "disable"
$userlocal.status | Should -Be "enable"
$userlocal.'email-to' | Should -Be "[email protected]"
$userlocal.'two-factor' | Should -Be "email"
}
Expand All @@ -212,7 +212,7 @@ Describe "Configure User Local" {
Get-FGTUserLocal -name "pester_userlocal_change" | Set-FGTUserLocal -data $data
$userlocal = Get-FGTUserLocal -name "pester_userlocal_change"
$userlocal.name | Should -Be "pester_userlocal_change"
$userlocal.status | Should -Be "disable"
$userlocal.status | Should -Be "enable"
$userlocal.'email-to' | Should -Be "[email protected]"
$userlocal.'two-factor' | Should -Be "email"
}
Expand Down

0 comments on commit b963339

Please sign in to comment.