From 9236a7fa3124e5a45f775159d0d8566a7ced11b2 Mon Sep 17 00:00:00 2001 From: Ryan Bailey Date: Thu, 23 Jun 2022 15:09:10 -0400 Subject: [PATCH 01/10] Standardized language and fixed -name typo --- PowerShell/JumpCloud Module/Docs/Get-JCCommand.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md b/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md index ece9505be..fad2775df 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md @@ -56,9 +56,8 @@ Note that when running this command the time for the output to display will be d PS C:\> Get-JCCommand -name '*BitLocker*' | Get-JCCommand -ByID ``` -Returns all information describing all JumpCloud commands with a name of '*trigger*' by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the name BitLocker somewhere in the name would be returned. +Returns all information describing all JumpCloud commands with a name of '*Bitlocker*' by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "BitLocker" somewhere in the name would be returned. -Note that when running this command the time for the output to display will be directly proportionate to how many JumpCloud commands you have with a launchType of 'trigger'. The command 'Get-JCCommand -ByID' runs once for every JumpCloud command within your tenant with a launchType of 'trigger'. ### Example 5 ```powershell @@ -74,9 +73,8 @@ Note that when running this command the time for the output to display will be d PS C:\> Get-JCCommand -command '*fdesetup*' | Get-JCCommand -ByID ``` -Returns all information describing all JumpCloud commands with a command string and the search term "fdesetup", by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "fdesetup" somewhere in the command body would be returned. +Returns all information describing all JumpCloud commands with a command string and the search term "*fdesetup*", by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "fdesetup" somewhere in the command body would be returned. -Note that when running this command the time for the output to display will be directly proportionate to how many JumpCloud commands you have with a launchType of 'trigger'. The command 'Get-JCCommand -ByID' runs once for every JumpCloud command within your tenant with a launchType of 'trigger'. ## PARAMETERS From b1db933a6a3f382023b396bc55d4dbf9c86e4064 Mon Sep 17 00:00:00 2001 From: Ryan Bailey Date: Thu, 23 Jun 2022 15:19:55 -0400 Subject: [PATCH 02/10] Fix casing on BitLocker --- PowerShell/JumpCloud Module/Docs/Get-JCCommand.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md b/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md index fad2775df..883fa4a03 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md @@ -56,7 +56,7 @@ Note that when running this command the time for the output to display will be d PS C:\> Get-JCCommand -name '*BitLocker*' | Get-JCCommand -ByID ``` -Returns all information describing all JumpCloud commands with a name of '*Bitlocker*' by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "BitLocker" somewhere in the name would be returned. +Returns all information describing all JumpCloud commands with a name of '*BitLocker*' by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "BitLocker" somewhere in the name would be returned. ### Example 5 From 6bfecc0528ea5bb24eaa9664b5685048db9ef67e Mon Sep 17 00:00:00 2001 From: mmathesonjc <107208335+mmathesonjc@users.noreply.github.com> Date: Thu, 30 Jun 2022 13:00:30 -0400 Subject: [PATCH 03/10] Add validate set to Get-JCUser --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 7dda14111..3f6194c83 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.23.0' +ModuleVersion = '1.23.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 4e8f8c8b0..cadd8f457 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -121,6 +121,7 @@ Function Get-JCUser () [String]$manager, [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'A search filter to return users that are in an ACTIVATED, STAGED or SUSPENDED state')] + [ValidateSet('ACTIVATED','SUSPENDED','STAGED')] [String]$state, [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'The recovery email of the JumpCloud user you wish to search for.')] From f99ad8bc2d5728c67d187b83ef78d1ccac96ade4 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 6 Jul 2022 13:27:21 -0600 Subject: [PATCH 04/10] todos for state param [skip ci] --- .../JumpCloud Module/Public/Users/Get-JCUser.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index cadd8f457..4e75b7d9e 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -385,6 +385,17 @@ Function Get-JCUser () } } + # case insensitve state param + if ("state" -eq $param.Key) + { + $stateValue = # TODO: Figure out what parameter value needs to be added here ($param.Value) + # TODO: Convert $stateValue to uppercase characters + if ($stateValue) { + # if an ID was validated + ($Search.filter).GetEnumerator().add($param.Key, $stateValue) + } + } + $Value = ($param.value).replace('*', '') if (($param.Value -match '.+?\*$') -and ($param.Value -match '^\*.+?')) @@ -420,6 +431,8 @@ Function Get-JCUser () $SearchJSON = $Search | ConvertTo-Json -Compress -Depth 4 + Write-Debug $SearchJSON + $URL = "$JCUrlBasePath/api/search/systemusers" $Results = Invoke-RestMethod -Method POST -Uri $Url -Header $hdrs -Body $SearchJSON -UserAgent:(Get-JCUserAgent) From 6e522daeef1280242569b395a944cd510ff0f4ea Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 6 Jul 2022 13:40:14 -0600 Subject: [PATCH 05/10] ToDo for state param --- .../Public/Users/Get-JCUser.ps1 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 4e75b7d9e..321d6e3aa 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -388,12 +388,16 @@ Function Get-JCUser () # case insensitve state param if ("state" -eq $param.Key) { - $stateValue = # TODO: Figure out what parameter value needs to be added here ($param.Value) - # TODO: Convert $stateValue to uppercase characters - if ($stateValue) { - # if an ID was validated - ($Search.filter).GetEnumerator().add($param.Key, $stateValue) + # TODO: If $param.Value is exactly 'ACTIVATED','SUSPENDED' or 'STAGED' (test that the $param.value does case match 'ACTIVATED','SUSPENDED','STAGED')){ + if (#TODO Write the if statement ^) + { + $stateValue = $param.Value + } + else { + # This case should mean that the value passed in was not does not case match 'ACTIVATED','SUSPENDED'or 'STAGED' + $stateValue = # TODO: convert $param.value to all uppercase letters } + continue } $Value = ($param.value).replace('*', '') @@ -428,6 +432,10 @@ Function Get-JCUser () { (($Search.filter).GetEnumerator()).add('recoveryEmail.address', $recoveryEmail ) } + if ($stateValue) + { + (($Search.filter).GetEnumerator()).add('state', $stateValue ) + } $SearchJSON = $Search | ConvertTo-Json -Compress -Depth 4 From 3183683df4e18c9bdb15a982a04f6ab77e624e53 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 7 Jul 2022 10:26:05 -0600 Subject: [PATCH 06/10] case insensitive search for state + tests --- .../Public/Users/Get-JCUser.ps1 | 6 +- .../Tests/Public/Users/Get-JCUser.tests.ps1 | 318 ++++++++++++++++++ 2 files changed, 320 insertions(+), 4 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 321d6e3aa..24bbcca62 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -388,14 +388,12 @@ Function Get-JCUser () # case insensitve state param if ("state" -eq $param.Key) { - # TODO: If $param.Value is exactly 'ACTIVATED','SUSPENDED' or 'STAGED' (test that the $param.value does case match 'ACTIVATED','SUSPENDED','STAGED')){ - if (#TODO Write the if statement ^) + if ($param.Value -cin @('ACTIVATED', 'SUSPENDED', 'STAGED')) { $stateValue = $param.Value } else { - # This case should mean that the value passed in was not does not case match 'ACTIVATED','SUSPENDED'or 'STAGED' - $stateValue = # TODO: convert $param.value to all uppercase letters + $stateValue = ($param.Value).ToUpper() } continue } diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 index 3707ee602..8fdb45957 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 @@ -105,19 +105,31 @@ Describe -Tag:('JCUser') 'Get-JCUser 1.1' { It "Searches a JumpCloud user by state SUSPENDED" { $NewUser = New-RandomUser -Domain DeleteMe | New-JcUser -state "SUSPENDED" $SearchUser = Get-JCUser -state "SUSPENDED" | Select-Object -First 1 + $SearchUserLower = Get-JCUser -state "suspended" | Select-Object -First 1 + $SearchUserMixed = Get-JCUser -state "Suspended" | Select-Object -First 1 $SearchUser.state | Should -Be "SUSPENDED" + $SearchUserLower.state | Should -Be "SUSPENDED" + $SearchUserMixed.state | Should -Be "SUSPENDED" Remove-JCUser -UserId $NewUser._id -force } It "Searches a JumpCloud user by state STAGED" { $NewUser = New-RandomUser -Domain DeleteMe | New-JcUser -state "STAGED" $SearchUser = Get-JCUser -state "STAGED" | Select-Object -First 1 + $SearchUserLower = Get-JCUser -state "staged" | Select-Object -First 1 + $SearchUserMixed = Get-JCUser -state "Staged" | Select-Object -First 1 $SearchUser.state | Should -Be "STAGED" + $SearchUserLower.state | Should -Be "STAGED" + $SearchUserMixed.state | Should -Be "STAGED" Remove-JCUser -UserId $NewUser._id -force } It "Searches a JumpCloud user by state ACTIVATED" { $NewUser = New-RandomUser -Domain DeleteMe | New-JcUser -state "ACTIVATED" $SearchUser = Get-JCUser -state "ACTIVATED" | Select-Object -First 1 + $SearchUserLower = Get-JCUser -state "activated" | Select-Object -First 1 + $SearchUserMixed = Get-JCUser -state "Activated" | Select-Object -First 1 $SearchUser.state | Should -Be "ACTIVATED" + $SearchUserLower.state | Should -Be "ACTIVATED" + $SearchUserMixed.state | Should -Be "ACTIVATED" Remove-JCUser -UserId $NewUser._id -force } @@ -403,4 +415,310 @@ Describe -Tag:('JCUser') "Get-JCUser 1.12" { $SearchUser._id | Should -Be $Newuser._id } +} + +Describe -Tag:('JCUser') "Case Insensitivity Tests" { + It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { + # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username + # Get-JCuser -username username should return same user as Get-JCuser -username Username + # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username + # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname + # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname + # Etc. + $commandParameters = (GCM Get-JCSystem).Parameters + $gmr = Get-JCUser -username $PesterParams_User1.username | GM + # Get parameters that are not ID, ORGID and have a string following the param name + $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } + + foreach ($param in $parameters.Name) { + # Write-host "Testing $param" + $string = $PesterParams_User1.$param.toLower() + $stringList = @() + $stringFinal = "" + # for i in string length, get the letters and capatlize ever other letter + for ($i = 0; $i -lt $string.length; $i++) { + <# Action that will repeat until the condition is met #> + $letter = $string.Substring($i, 1) + if ($i % 2 -eq 1) { + $letter = $letter.TOUpper() + } + $stringList += ($letter) + } + foreach ($letter in $stringList) { + <# $letter is the current item #> + $stringFinal += $letter + } + $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" + $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" + $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" + # Write-Host $mixedCaseSearch + # Write-Host $lowerCaseSearch + # Write-Host $upperCaseSearch + $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) + $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) + $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) + # DefaultSearch is the expression without text formatting + $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" + $userSearchDefault = Invoke-Expression -Command:($defaultSearch) + # Ids returned here should return the same restuls + $userSearchUpper._id | Should -Be $userSearchDefault._id + $userSearchLower._id | Should -Be $userSearchDefault._id + $userSearchMixed._id | Should -Be $userSearchDefault._id + } + } +} + +Describe -Tag:('JCUser') "Case Insensitivity Tests" { + It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { + # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username + # Get-JCuser -username username should return same user as Get-JCuser -username Username + # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username + # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname + # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname + # Etc. + $commandParameters = (GCM Get-JCSystem).Parameters + $gmr = Get-JCUser -username $PesterParams_User1.username | GM + # Get parameters that are not ID, ORGID and have a string following the param name + $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } + + foreach ($param in $parameters.Name) { + # Write-host "Testing $param" + $string = $PesterParams_User1.$param.toLower() + $stringList = @() + $stringFinal = "" + # for i in string length, get the letters and capatlize ever other letter + for ($i = 0; $i -lt $string.length; $i++) { + <# Action that will repeat until the condition is met #> + $letter = $string.Substring($i, 1) + if ($i % 2 -eq 1) { + $letter = $letter.TOUpper() + } + $stringList += ($letter) + } + foreach ($letter in $stringList) { + <# $letter is the current item #> + $stringFinal += $letter + } + $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" + $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" + $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" + # Write-Host $mixedCaseSearch + # Write-Host $lowerCaseSearch + # Write-Host $upperCaseSearch + $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) + $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) + $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) + # DefaultSearch is the expression without text formatting + $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" + $userSearchDefault = Invoke-Expression -Command:($defaultSearch) + # Ids returned here should return the same restuls + $userSearchUpper._id | Should -Be $userSearchDefault._id + $userSearchLower._id | Should -Be $userSearchDefault._id + $userSearchMixed._id | Should -Be $userSearchDefault._id + } + } +} + +Describe -Tag:('JCUser') "Case Insensitivity Tests" { + It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { + # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username + # Get-JCuser -username username should return same user as Get-JCuser -username Username + # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username + # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname + # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname + # Etc. + $commandParameters = (GCM Get-JCSystem).Parameters + $gmr = Get-JCUser -username $PesterParams_User1.username | GM + # Get parameters that are not ID, ORGID and have a string following the param name + $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } + + foreach ($param in $parameters.Name) { + # Write-host "Testing $param" + $string = $PesterParams_User1.$param.toLower() + $stringList = @() + $stringFinal = "" + # for i in string length, get the letters and capatlize ever other letter + for ($i = 0; $i -lt $string.length; $i++) { + <# Action that will repeat until the condition is met #> + $letter = $string.Substring($i, 1) + if ($i % 2 -eq 1) { + $letter = $letter.TOUpper() + } + $stringList += ($letter) + } + foreach ($letter in $stringList) { + <# $letter is the current item #> + $stringFinal += $letter + } + $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" + $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" + $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" + # Write-Host $mixedCaseSearch + # Write-Host $lowerCaseSearch + # Write-Host $upperCaseSearch + $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) + $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) + $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) + # DefaultSearch is the expression without text formatting + $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" + $userSearchDefault = Invoke-Expression -Command:($defaultSearch) + # Ids returned here should return the same restuls + $userSearchUpper._id | Should -Be $userSearchDefault._id + $userSearchLower._id | Should -Be $userSearchDefault._id + $userSearchMixed._id | Should -Be $userSearchDefault._id + } + } +} + +Describe -Tag:('JCUser') "Case Insensitivity Tests" { + It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { + # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username + # Get-JCuser -username username should return same user as Get-JCuser -username Username + # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username + # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname + # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname + # Etc. + $commandParameters = (GCM Get-JCSystem).Parameters + $gmr = Get-JCUser -username $PesterParams_User1.username | GM + # Get parameters that are not ID, ORGID and have a string following the param name + $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } + + foreach ($param in $parameters.Name) { + # Write-host "Testing $param" + $string = $PesterParams_User1.$param.toLower() + $stringList = @() + $stringFinal = "" + # for i in string length, get the letters and capatlize ever other letter + for ($i = 0; $i -lt $string.length; $i++) { + <# Action that will repeat until the condition is met #> + $letter = $string.Substring($i, 1) + if ($i % 2 -eq 1) { + $letter = $letter.TOUpper() + } + $stringList += ($letter) + } + foreach ($letter in $stringList) { + <# $letter is the current item #> + $stringFinal += $letter + } + $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" + $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" + $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" + # Write-Host $mixedCaseSearch + # Write-Host $lowerCaseSearch + # Write-Host $upperCaseSearch + $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) + $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) + $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) + # DefaultSearch is the expression without text formatting + $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" + $userSearchDefault = Invoke-Expression -Command:($defaultSearch) + # Ids returned here should return the same restuls + $userSearchUpper._id | Should -Be $userSearchDefault._id + $userSearchLower._id | Should -Be $userSearchDefault._id + $userSearchMixed._id | Should -Be $userSearchDefault._id + } + } +} + +Describe -Tag:('JCUser') "Case Insensitivity Tests" { + It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { + # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username + # Get-JCuser -username username should return same user as Get-JCuser -username Username + # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username + # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname + # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname + # Etc. + $commandParameters = (GCM Get-JCSystem).Parameters + $gmr = Get-JCUser -username $PesterParams_User1.username | GM + # Get parameters that are not ID, ORGID and have a string following the param name + $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } + + foreach ($param in $parameters.Name) { + # Write-host "Testing $param" + $string = $PesterParams_User1.$param.toLower() + $stringList = @() + $stringFinal = "" + # for i in string length, get the letters and capatlize ever other letter + for ($i = 0; $i -lt $string.length; $i++) { + <# Action that will repeat until the condition is met #> + $letter = $string.Substring($i, 1) + if ($i % 2 -eq 1) { + $letter = $letter.TOUpper() + } + $stringList += ($letter) + } + foreach ($letter in $stringList) { + <# $letter is the current item #> + $stringFinal += $letter + } + $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" + $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" + $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" + # Write-Host $mixedCaseSearch + # Write-Host $lowerCaseSearch + # Write-Host $upperCaseSearch + $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) + $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) + $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) + # DefaultSearch is the expression without text formatting + $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" + $userSearchDefault = Invoke-Expression -Command:($defaultSearch) + # Ids returned here should return the same restuls + $userSearchUpper._id | Should -Be $userSearchDefault._id + $userSearchLower._id | Should -Be $userSearchDefault._id + $userSearchMixed._id | Should -Be $userSearchDefault._id + } + } +} + +Describe -Tag:('JCUser') "Case Insensitivity Tests" { + It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { + # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username + # Get-JCuser -username username should return same user as Get-JCuser -username Username + # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username + # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname + # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname + # Etc. + $commandParameters = (GCM Get-JCSystem).Parameters + $gmr = Get-JCUser -username $PesterParams_User1.username | GM + # Get parameters that are not ID, ORGID and have a string following the param name + $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } + + foreach ($param in $parameters.Name) { + # Write-host "Testing $param" + $string = $PesterParams_User1.$param.toLower() + $stringList = @() + $stringFinal = "" + # for i in string length, get the letters and capatlize ever other letter + for ($i = 0; $i -lt $string.length; $i++) { + <# Action that will repeat until the condition is met #> + $letter = $string.Substring($i, 1) + if ($i % 2 -eq 1) { + $letter = $letter.TOUpper() + } + $stringList += ($letter) + } + foreach ($letter in $stringList) { + <# $letter is the current item #> + $stringFinal += $letter + } + $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" + $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" + $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" + # Write-Host $mixedCaseSearch + # Write-Host $lowerCaseSearch + # Write-Host $upperCaseSearch + $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) + $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) + $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) + # DefaultSearch is the expression without text formatting + $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" + $userSearchDefault = Invoke-Expression -Command:($defaultSearch) + # Ids returned here should return the same restuls + $userSearchUpper._id | Should -Be $userSearchDefault._id + $userSearchLower._id | Should -Be $userSearchDefault._id + $userSearchMixed._id | Should -Be $userSearchDefault._id + } + } } \ No newline at end of file From 3d1b4a37f2933cc0d5e5f070066ab5a0d76a0209 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 7 Jul 2022 10:33:19 -0600 Subject: [PATCH 07/10] changelog/ banner --- .circleci/workflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 8e4572fba..8f97ecc25 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -32,7 +32,7 @@ parameters: description: 'Release Type. Accepted values [ Major, Minor, Patch ]' type: enum enum: ["Major", "Minor", "Patch"] - default: "Minor" + default: "Patch" RequiredModulesRepo: description: 'PowerShell Repository for JumpCloud SDKs' type: enum From df80c4654a1aa24aa9941384603abde07e3028e0 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 7 Jul 2022 10:33:33 -0600 Subject: [PATCH 08/10] changelog/ banner --- PowerShell/ModuleBanner.md | 6 +++--- PowerShell/ModuleChangelog.md | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 57feda7b0..9de6a5fc1 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,17 @@ #### Latest Version ``` -1.23.0 +1.23.1 ``` #### Banner Current ``` -* Added search endpoint functionality and parameters to Get-jCCommand +* Get-JCUser -State should accept case insensitive values such as "suspended" "activated" "staged" and validate input ``` #### Banner Old ``` -* Added functionality for Set, Get, New-JCUser to Search by Email to Manager Field +* Added search endpoint functionality and parameters to Get-jCCommand ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index fd2750d88..3122e5a63 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,12 @@ +## 1.23.1 + +Release Date: June 21, 2022 + +#### RELEASE NOTES + +This release adds validate to the Get-JCUser -State parameter set. It should now validate supplied acceptable values. +Documentation for Get-JCCommand updated thanks to JumpCloud Community member: Ryan Bailey @rybai + ## 1.23.0 Release Date: June 21, 2022 From fbd9495f369d6ca2785b9117c5730b15d4d6e662 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 7 Jul 2022 16:42:52 +0000 Subject: [PATCH 09/10] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Get-JCCommand.md | 2 -- PowerShell/JumpCloud Module/Docs/Get-JCUser.md | 1 + PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml | 11 +++++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md b/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md index 883fa4a03..a21435f88 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCCommand.md @@ -58,7 +58,6 @@ PS C:\> Get-JCCommand -name '*BitLocker*' | Get-JCCommand -ByID Returns all information describing all JumpCloud commands with a name of '*BitLocker*' by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "BitLocker" somewhere in the name would be returned. - ### Example 5 ```powershell PS C:\> Get-JCCommand -launchType 'trigger' | Get-JCCommand -ByID @@ -75,7 +74,6 @@ PS C:\> Get-JCCommand -command '*fdesetup*' | Get-JCCommand -ByID Returns all information describing all JumpCloud commands with a command string and the search term "*fdesetup*", by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "fdesetup" somewhere in the command body would be returned. - ## PARAMETERS ### -ByID diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCUser.md b/PowerShell/JumpCloud Module/Docs/Get-JCUser.md index 27b482931..422b8b7c9 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCUser.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCUser.md @@ -583,6 +583,7 @@ A search filter to return users that are in an ACTIVATED or SUSPENDED state Type: System.String Parameter Sets: SearchFilter Aliases: +Accepted values: ACTIVATED, SUSPENDED, STAGED Required: False Position: Named diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 0d95a1d73..379097009 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 1.23.0 +Help Version: 1.23.1 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 3f6194c83..5d5e9e5a7 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 6/22/2022 +# Generated on: 7/7/2022 # @{ diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 85a77563c..44c6f2749 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -3769,8 +3769,7 @@ PS C:\> $BackupJcOrganizationResults.User -------------------------- Example 4 -------------------------- PS C:\> Get-JCCommand -name '*BitLocker*' | Get-JCCommand -ByID - Returns all information describing all JumpCloud commands with a name of ' trigger ' by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the name BitLocker somewhere in the name would be returned. - Note that when running this command the time for the output to display will be directly proportionate to how many JumpCloud commands you have with a launchType of 'trigger'. The command 'Get-JCCommand -ByID' runs once for every JumpCloud command within your tenant with a launchType of 'trigger'. + Returns all information describing all JumpCloud commands with a name of ' BitLocker ' by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "BitLocker" somewhere in the name would be returned. @@ -3785,8 +3784,7 @@ PS C:\> $BackupJcOrganizationResults.User -------------------------- Example 6 -------------------------- PS C:\> Get-JCCommand -command '*fdesetup*' | Get-JCCommand -ByID - Returns all information describing all JumpCloud commands with a command string and the search term "fdesetup", by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "fdesetup" somewhere in the command body would be returned. - Note that when running this command the time for the output to display will be directly proportionate to how many JumpCloud commands you have with a launchType of 'trigger'. The command 'Get-JCCommand -ByID' runs once for every JumpCloud command within your tenant with a launchType of 'trigger'. + Returns all information describing all JumpCloud commands with a command string and the search term " fdesetup ", by passing the -CommandID Parameter to the -ByID Parameter using the pipeline and Parameter Binding. Note, search parameters on Get-JCCommand support wildcard characters. In this example commands with the string "fdesetup" somewhere in the command body would be returned. @@ -7855,6 +7853,11 @@ PS C:\> $BackupJcOrganizationResults.User A search filter to return users that are in an ACTIVATED or SUSPENDED state + + ACTIVATED + SUSPENDED + STAGED + System.String System.String From 61744a25c151616eec8f848f98a177eee4f870fa Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 7 Jul 2022 11:32:50 -0600 Subject: [PATCH 10/10] release param and remove tests from different branch --- .circleci/workflows.yml | 2 +- .../Tests/Public/Users/Get-JCUser.tests.ps1 | 306 ------------------ 2 files changed, 1 insertion(+), 307 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 8f97ecc25..6a1c471c2 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -45,7 +45,7 @@ parameters: PublishToPSGallery: description: 'When `true` and when run against Master branch, this workflow will publish the latest code to PSGallery' type: boolean - default: false + default: true ManualModuleVersion: description: 'When `true` the pipeline will use the Module Version specified in JumpCloud Module JumpCloud.psd1 file' type: boolean diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 index 8fdb45957..d49ea29bc 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 @@ -415,310 +415,4 @@ Describe -Tag:('JCUser') "Get-JCUser 1.12" { $SearchUser._id | Should -Be $Newuser._id } -} - -Describe -Tag:('JCUser') "Case Insensitivity Tests" { - It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { - # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username - # Get-JCuser -username username should return same user as Get-JCuser -username Username - # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username - # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname - # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname - # Etc. - $commandParameters = (GCM Get-JCSystem).Parameters - $gmr = Get-JCUser -username $PesterParams_User1.username | GM - # Get parameters that are not ID, ORGID and have a string following the param name - $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } - - foreach ($param in $parameters.Name) { - # Write-host "Testing $param" - $string = $PesterParams_User1.$param.toLower() - $stringList = @() - $stringFinal = "" - # for i in string length, get the letters and capatlize ever other letter - for ($i = 0; $i -lt $string.length; $i++) { - <# Action that will repeat until the condition is met #> - $letter = $string.Substring($i, 1) - if ($i % 2 -eq 1) { - $letter = $letter.TOUpper() - } - $stringList += ($letter) - } - foreach ($letter in $stringList) { - <# $letter is the current item #> - $stringFinal += $letter - } - $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" - $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" - $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" - # Write-Host $mixedCaseSearch - # Write-Host $lowerCaseSearch - # Write-Host $upperCaseSearch - $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) - $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) - $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) - # DefaultSearch is the expression without text formatting - $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" - $userSearchDefault = Invoke-Expression -Command:($defaultSearch) - # Ids returned here should return the same restuls - $userSearchUpper._id | Should -Be $userSearchDefault._id - $userSearchLower._id | Should -Be $userSearchDefault._id - $userSearchMixed._id | Should -Be $userSearchDefault._id - } - } -} - -Describe -Tag:('JCUser') "Case Insensitivity Tests" { - It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { - # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username - # Get-JCuser -username username should return same user as Get-JCuser -username Username - # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username - # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname - # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname - # Etc. - $commandParameters = (GCM Get-JCSystem).Parameters - $gmr = Get-JCUser -username $PesterParams_User1.username | GM - # Get parameters that are not ID, ORGID and have a string following the param name - $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } - - foreach ($param in $parameters.Name) { - # Write-host "Testing $param" - $string = $PesterParams_User1.$param.toLower() - $stringList = @() - $stringFinal = "" - # for i in string length, get the letters and capatlize ever other letter - for ($i = 0; $i -lt $string.length; $i++) { - <# Action that will repeat until the condition is met #> - $letter = $string.Substring($i, 1) - if ($i % 2 -eq 1) { - $letter = $letter.TOUpper() - } - $stringList += ($letter) - } - foreach ($letter in $stringList) { - <# $letter is the current item #> - $stringFinal += $letter - } - $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" - $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" - $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" - # Write-Host $mixedCaseSearch - # Write-Host $lowerCaseSearch - # Write-Host $upperCaseSearch - $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) - $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) - $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) - # DefaultSearch is the expression without text formatting - $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" - $userSearchDefault = Invoke-Expression -Command:($defaultSearch) - # Ids returned here should return the same restuls - $userSearchUpper._id | Should -Be $userSearchDefault._id - $userSearchLower._id | Should -Be $userSearchDefault._id - $userSearchMixed._id | Should -Be $userSearchDefault._id - } - } -} - -Describe -Tag:('JCUser') "Case Insensitivity Tests" { - It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { - # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username - # Get-JCuser -username username should return same user as Get-JCuser -username Username - # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username - # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname - # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname - # Etc. - $commandParameters = (GCM Get-JCSystem).Parameters - $gmr = Get-JCUser -username $PesterParams_User1.username | GM - # Get parameters that are not ID, ORGID and have a string following the param name - $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } - - foreach ($param in $parameters.Name) { - # Write-host "Testing $param" - $string = $PesterParams_User1.$param.toLower() - $stringList = @() - $stringFinal = "" - # for i in string length, get the letters and capatlize ever other letter - for ($i = 0; $i -lt $string.length; $i++) { - <# Action that will repeat until the condition is met #> - $letter = $string.Substring($i, 1) - if ($i % 2 -eq 1) { - $letter = $letter.TOUpper() - } - $stringList += ($letter) - } - foreach ($letter in $stringList) { - <# $letter is the current item #> - $stringFinal += $letter - } - $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" - $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" - $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" - # Write-Host $mixedCaseSearch - # Write-Host $lowerCaseSearch - # Write-Host $upperCaseSearch - $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) - $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) - $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) - # DefaultSearch is the expression without text formatting - $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" - $userSearchDefault = Invoke-Expression -Command:($defaultSearch) - # Ids returned here should return the same restuls - $userSearchUpper._id | Should -Be $userSearchDefault._id - $userSearchLower._id | Should -Be $userSearchDefault._id - $userSearchMixed._id | Should -Be $userSearchDefault._id - } - } -} - -Describe -Tag:('JCUser') "Case Insensitivity Tests" { - It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { - # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username - # Get-JCuser -username username should return same user as Get-JCuser -username Username - # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username - # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname - # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname - # Etc. - $commandParameters = (GCM Get-JCSystem).Parameters - $gmr = Get-JCUser -username $PesterParams_User1.username | GM - # Get parameters that are not ID, ORGID and have a string following the param name - $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } - - foreach ($param in $parameters.Name) { - # Write-host "Testing $param" - $string = $PesterParams_User1.$param.toLower() - $stringList = @() - $stringFinal = "" - # for i in string length, get the letters and capatlize ever other letter - for ($i = 0; $i -lt $string.length; $i++) { - <# Action that will repeat until the condition is met #> - $letter = $string.Substring($i, 1) - if ($i % 2 -eq 1) { - $letter = $letter.TOUpper() - } - $stringList += ($letter) - } - foreach ($letter in $stringList) { - <# $letter is the current item #> - $stringFinal += $letter - } - $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" - $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" - $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" - # Write-Host $mixedCaseSearch - # Write-Host $lowerCaseSearch - # Write-Host $upperCaseSearch - $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) - $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) - $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) - # DefaultSearch is the expression without text formatting - $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" - $userSearchDefault = Invoke-Expression -Command:($defaultSearch) - # Ids returned here should return the same restuls - $userSearchUpper._id | Should -Be $userSearchDefault._id - $userSearchLower._id | Should -Be $userSearchDefault._id - $userSearchMixed._id | Should -Be $userSearchDefault._id - } - } -} - -Describe -Tag:('JCUser') "Case Insensitivity Tests" { - It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { - # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username - # Get-JCuser -username username should return same user as Get-JCuser -username Username - # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username - # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname - # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname - # Etc. - $commandParameters = (GCM Get-JCSystem).Parameters - $gmr = Get-JCUser -username $PesterParams_User1.username | GM - # Get parameters that are not ID, ORGID and have a string following the param name - $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } - - foreach ($param in $parameters.Name) { - # Write-host "Testing $param" - $string = $PesterParams_User1.$param.toLower() - $stringList = @() - $stringFinal = "" - # for i in string length, get the letters and capatlize ever other letter - for ($i = 0; $i -lt $string.length; $i++) { - <# Action that will repeat until the condition is met #> - $letter = $string.Substring($i, 1) - if ($i % 2 -eq 1) { - $letter = $letter.TOUpper() - } - $stringList += ($letter) - } - foreach ($letter in $stringList) { - <# $letter is the current item #> - $stringFinal += $letter - } - $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" - $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" - $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" - # Write-Host $mixedCaseSearch - # Write-Host $lowerCaseSearch - # Write-Host $upperCaseSearch - $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) - $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) - $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) - # DefaultSearch is the expression without text formatting - $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" - $userSearchDefault = Invoke-Expression -Command:($defaultSearch) - # Ids returned here should return the same restuls - $userSearchUpper._id | Should -Be $userSearchDefault._id - $userSearchLower._id | Should -Be $userSearchDefault._id - $userSearchMixed._id | Should -Be $userSearchDefault._id - } - } -} - -Describe -Tag:('JCUser') "Case Insensitivity Tests" { - It "Searches parameters dynamically with mixed, lower and upper capitalaztion" { - # Get-JCuser -username uSeRnAmE should return same user as Get-JCuser -username Username - # Get-JCuser -username username should return same user as Get-JCuser -username Username - # Get-JCuser -username USERNAME should return same user as Get-JCuser -username Username - # Get-JCuser -firstname fIrStNaMe should return same user as Get-JCuser -firstname Firstname - # Get-JCuser -lastname lAsTnAmE should return same user as Get-JCuser -lastname Lastname - # Etc. - $commandParameters = (GCM Get-JCSystem).Parameters - $gmr = Get-JCUser -username $PesterParams_User1.username | GM - # Get parameters that are not ID, ORGID and have a string following the param name - $parameters = $gmr | Where-Object { ($_.Definition -notmatch "organization") -And ($_.Definition -notmatch "id") -And ($_.Definition -match "string\s\w+=(\w+)") -And ($_.Name -In $commandParameters.Keys) } - - foreach ($param in $parameters.Name) { - # Write-host "Testing $param" - $string = $PesterParams_User1.$param.toLower() - $stringList = @() - $stringFinal = "" - # for i in string length, get the letters and capatlize ever other letter - for ($i = 0; $i -lt $string.length; $i++) { - <# Action that will repeat until the condition is met #> - $letter = $string.Substring($i, 1) - if ($i % 2 -eq 1) { - $letter = $letter.TOUpper() - } - $stringList += ($letter) - } - foreach ($letter in $stringList) { - <# $letter is the current item #> - $stringFinal += $letter - } - $mixedCaseSearch = "Get-JCUser -$($param) `"$stringFinal`"" - $lowerCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.toLower())`"" - $upperCaseSearch = "Get-JCUser -$($param) `"$($stringFinal.TOUpper())`"" - # Write-Host $mixedCaseSearch - # Write-Host $lowerCaseSearch - # Write-Host $upperCaseSearch - $userSearchMixed = Invoke-Expression -Command:($mixedCaseSearch) - $userSearchLower = Invoke-Expression -Command:($lowerCaseSearch) - $userSearchUpper = Invoke-Expression -Command:($upperCaseSearch) - # DefaultSearch is the expression without text formatting - $defaultSearch = "Get-JCUser -$($param) `"$($PesterParams_User1.$param)`"" - $userSearchDefault = Invoke-Expression -Command:($defaultSearch) - # Ids returned here should return the same restuls - $userSearchUpper._id | Should -Be $userSearchDefault._id - $userSearchLower._id | Should -Be $userSearchDefault._id - $userSearchMixed._id | Should -Be $userSearchDefault._id - } - } } \ No newline at end of file