diff --git a/PowerFGT/Public/cmdb/user/local.ps1 b/PowerFGT/Public/cmdb/user/local.ps1 index 5eede9cca..0f4e27d8f 100644 --- a/PowerFGT/Public/cmdb/user/local.ps1 +++ b/PowerFGT/Public/cmdb/user/local.ps1 @@ -386,17 +386,17 @@ function Set-FGTUserLocal { if ( $PsBoundParameters.ContainsKey('two_factor') ) { if ( $two_factor -eq "fortitoken" -or $two_factor -eq "fortitoken-cloud" ) { - $local | add-member -name "two-factor" -membertype NoteProperty -Value $two_factor - $local | add-member -name "two-factor-authentication" -membertype NoteProperty -Value "fortitoken" - $local | add-member -name "fortitoken" -membertype NoteProperty -Value $fortitoken + $_local | add-member -name "two-factor" -membertype NoteProperty -Value $two_factor + $_local | add-member -name "two-factor-authentication" -membertype NoteProperty -Value "fortitoken" + $_local | add-member -name "fortitoken" -membertype NoteProperty -Value $fortitoken } elseif ( $two_factor -eq "email" ) { - $local | add-member -name "two-factor" -membertype NoteProperty -Value $two_factor - $local | add-member -name "two-factor-authentication" -membertype NoteProperty -Value "email" + $_local | add-member -name "two-factor" -membertype NoteProperty -Value $two_factor + $_local | add-member -name "two-factor-authentication" -membertype NoteProperty -Value $two_factor } elseif ( $two_factor -eq "sms" ) { - $local | add-member -name "two-factor" -membertype NoteProperty -Value $two_factor - $local | add-member -name "two-factor-authentication" -membertype NoteProperty -Value "sms" + $_local | add-member -name "two-factor" -membertype NoteProperty -Value $two_factor + $_local | add-member -name "two-factor-authentication" -membertype NoteProperty -Value $two_factor++ } } diff --git a/Tests/integration/UserLocal.Tests.ps1 b/Tests/integration/UserLocal.Tests.ps1 index 2859839e5..156a681a2 100644 --- a/Tests/integration/UserLocal.Tests.ps1 +++ b/Tests/integration/UserLocal.Tests.ps1 @@ -107,7 +107,6 @@ Describe "Add User Local" { $userlocal.name | Should -Be $pester_userlocal $userlocal.status | Should -Be "enable" $userlocal.'email-to' | Should -Be "powerfgt@power.fgt" - $userlocal.'two-factor' | Should -Be "email" } It "Try to Add User Local $pester_userlocal (but there is already a object with same name)" { @@ -167,15 +166,15 @@ Describe "Configure User Local" { It "Change email to with -data" { $data = @{ "email-to" = "powerfgt@power.fgt" } - Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -data $data - $userlocal = Get-FGTUserLocal -name $pester_userlocal - $userlocal.name | Should -Be $pester_userlocal + 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.'email-to' | Should -Be "powerfgt@power.fgt" $userlocal.'two-factor' | Should -Be "disable" } - AfterEach { + AfterAll { Get-FGTUserLocal -name "pester_userlocal_change" | Remove-FGTUserLocal -confirm:$false }