From ae7eef34ee150f08064edecd170bddf499cb6021 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 09:13:47 -0600 Subject: [PATCH 01/12] manager username/ email through filter search --- .../Public/Users/Get-JCUser.ps1 | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 24bbcca62..9dfbee268 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -315,9 +315,10 @@ Function Get-JCUser () if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('id') + $managerSearch = @{ + filter = @( + @{'id' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + ) } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -326,10 +327,9 @@ Function Get-JCUser () # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') - } + filter = @( + @{'username' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + ) } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -341,9 +341,10 @@ Function Get-JCUser () $null = [mailaddress]$EmailAddress # Search manager using email $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('email') + $managerSearch = @{ + filter = @( + @{'email' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + ) } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -351,9 +352,10 @@ Function Get-JCUser () $managerValue = $managerResults.id if (!$managerValue){ $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + $managerSearch = @{ + filter = @( + @{'username' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + ) } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -364,9 +366,10 @@ Function Get-JCUser () catch { # search the username in the search endpoint $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + $managerSearch = @{ + filter = @( + @{'username' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + ) } } $managerResults = Search-JcSdkUser -Body:($managerSearch) From 2de849dc7f97b437b10dd6f6f13177de3a8a08b1 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 09:23:41 -0600 Subject: [PATCH 02/12] dependancy table --- PowerShell/Deploy/Setup-Dependencies.ps1 | 62 ++++++++++++++++-------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/PowerShell/Deploy/Setup-Dependencies.ps1 b/PowerShell/Deploy/Setup-Dependencies.ps1 index 2938414c5..46c5639ec 100644 --- a/PowerShell/Deploy/Setup-Dependencies.ps1 +++ b/PowerShell/Deploy/Setup-Dependencies.ps1 @@ -1,6 +1,6 @@ Param( - [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, Position = 0)][System.String[]]$DependentModules = ('PowerShellGet', 'PackageManagement', 'PSScriptAnalyzer', 'PlatyPS', 'Pester', 'AWS.Tools.Common', 'AWS.Tools.CodeArtifact') - , [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, Position = 1)][System.String]$RequiredModulesRepo = 'PSGallery' + # [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, Position = 0)][System.String[]]$DependentModules = ('PowerShellGet', 'PackageManagement', 'PSScriptAnalyzer', 'PlatyPS', 'Pester', 'AWS.Tools.Common', 'AWS.Tools.CodeArtifact') + [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, Position = 0)][System.String]$RequiredModulesRepo = 'PSGallery' ) # Install NuGet If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) @@ -8,30 +8,52 @@ If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('Silently Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force } -# Install dependent modules -ForEach ($DependentModule In $DependentModules) + +$PSDependencies = @{ + 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } + 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } + 'PSScriptAnalyzer' = @{Repository = 'PSGallery'; RequiredVersion = '1.19.1' } + 'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } + 'Pester' = @{Repository = 'PSGallery'; RequiredVersion = '5.3.3' } + 'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } + 'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } +} + +foreach ($RequiredModule in $PSDependencies.Keys) { - # Check to see if the module is installed - If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $DependentModule }))) - { - Write-Host("[status]Installing module: '$DependentModule' from 'PSGallery'") - if ($DependentModule -eq 'PowerShellGet'){ - Install-Module -Name $DependentModule -Repository:('PSGallery') -RequiredVersion '3.0.12-beta' -AllowPrerelease -Force - } - elseif ($DependentModule -eq 'PSScriptAnalyzer') { - Install-Module -Name $DependentModule -Repository:('PSGallery') -RequiredVersion '1.19.1' -Force - } - else{ - Install-Module -Repository:('PSGallery') -Force -Name:($DependentModule) -Scope:('CurrentUser') -AllowClobber - } - } + Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force # Get-Module -Refresh -ListAvailable - If ([System.String]::IsNullOrEmpty((Get-Module | Where-Object { $_.Name -eq $DependentModule }))) + If ([System.String]::IsNullOrEmpty((Get-Module | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Importing module: '$DependentModule'") Import-Module -Name:($DependentModule) -Force -Global } } +# # Install dependent modules +# ForEach ($DependentModule In $DependentModules) +# { +# # Check to see if the module is installed +# If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $DependentModule }))) +# { +# Write-Host("[status]Installing module: '$DependentModule' from 'PSGallery'") +# if ($DependentModule -eq 'PowerShellGet'){ +# Install-Module -Name $DependentModule -Repository:('PSGallery') -RequiredVersion '3.0.12-beta' -AllowPrerelease -Force +# } +# elseif ($DependentModule -eq 'PSScriptAnalyzer') { +# Install-Module -Name $DependentModule -Repository:('PSGallery') -RequiredVersion '1.19.1' -Force +# } +# else{ +# Install-Module -Repository:('PSGallery') -Force -Name:($DependentModule) -Scope:('CurrentUser') -AllowClobber +# } +# } +# # Get-Module -Refresh -ListAvailable +# If ([System.String]::IsNullOrEmpty((Get-Module | Where-Object { $_.Name -eq $DependentModule }))) +# { +# Write-Host("[status]Importing module: '$DependentModule'") +# Import-Module -Name:($DependentModule) -Force -Global +# } +# } ### TODO: Switch to CodeArtifact If ($RequiredModulesRepo -ne 'PSGallery') { @@ -86,7 +108,7 @@ If (-not [System.String]::IsNullOrEmpty($Psd1)) } elseif ($PowerShellModulesPaths -match 'documents') { - # Windows Ststems + # Windows Systems $LocalPSModulePath = $env:PSModulePath.split(';') | Where-Object { $_ -like '*documents*' } Write-Host "Module Installation Path: $LocalPSModulePath" } From 4bf82186d6ce7e25c8ce9d1ab2f40de860192406 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 09:54:03 -0600 Subject: [PATCH 03/12] import from table --- PowerShell/Deploy/Setup-Dependencies.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/Deploy/Setup-Dependencies.ps1 b/PowerShell/Deploy/Setup-Dependencies.ps1 index 46c5639ec..f1e3dc7d3 100644 --- a/PowerShell/Deploy/Setup-Dependencies.ps1 +++ b/PowerShell/Deploy/Setup-Dependencies.ps1 @@ -26,8 +26,8 @@ foreach ($RequiredModule in $PSDependencies.Keys) # Get-Module -Refresh -ListAvailable If ([System.String]::IsNullOrEmpty((Get-Module | Where-Object { $_.Name -eq $RequiredModule }))) { - Write-Host("[status]Importing module: '$DependentModule'") - Import-Module -Name:($DependentModule) -Force -Global + Write-Host("[status]Importing module: '$RequiredModule'") + Import-Module -Name:($RequiredModule) -Force -Global } } # # Install dependent modules From a93501d1ea05daf6be370654fb19f4d353e918b0 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 09:55:06 -0600 Subject: [PATCH 04/12] check installed for non CI systems --- PowerShell/Deploy/Setup-Dependencies.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PowerShell/Deploy/Setup-Dependencies.ps1 b/PowerShell/Deploy/Setup-Dependencies.ps1 index f1e3dc7d3..24329970d 100644 --- a/PowerShell/Deploy/Setup-Dependencies.ps1 +++ b/PowerShell/Deploy/Setup-Dependencies.ps1 @@ -21,9 +21,11 @@ $PSDependencies = @{ foreach ($RequiredModule in $PSDependencies.Keys) { - Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force - # Get-Module -Refresh -ListAvailable + If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) + { + Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force + } If ([System.String]::IsNullOrEmpty((Get-Module | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Importing module: '$RequiredModule'") From d1a7e56e76c4d52da11cbeaf60565a2d66344af4 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 11 Jul 2022 16:03:38 +0000 Subject: [PATCH 05/12] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 4 ++-- PowerShell/ModuleBanner.md | 6 ++--- PowerShell/ModuleChangelog.md | 22 +++++++++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 379097009..83bc31624 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.1 +Help Version: 1.23.2 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 5d5e9e5a7..23910c241 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: 7/7/2022 +# Generated on: 7/11/2022 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.23.1' +ModuleVersion = '1.23.2' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 9de6a5fc1..9f0084d04 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,17 @@ #### Latest Version ``` -1.23.1 +1.23.2 ``` #### Banner Current ``` -* Get-JCUser -State should accept case insensitive values such as "suspended" "activated" "staged" and validate input +{{Fill in the Banner Current}} ``` #### Banner Old ``` -* Added search endpoint functionality and parameters to Get-jCCommand +{{Fill in the Banner Old}} ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 3122e5a63..3cfd661e8 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 1.23.2 + +Release Date: July 11, 2022 + +#### RELEASE NOTES + +``` +{{Fill in the Release Notes}} +``` + +#### FEATURES: + +{{Fill in the Features}} + +#### IMPROVEMENTS: + +{{Fill in the Improvements}} + +#### BUG FIXES: + +{{Fill in the Bug Fixes}} + ## 1.23.1 Release Date: June 21, 2022 From 1d43653d6733080803a0a6abef56809af106c4ed Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 10:15:15 -0600 Subject: [PATCH 06/12] banner/ changelog --- PowerShell/ModuleBanner.md | 2 +- PowerShell/ModuleChangelog.md | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 9de6a5fc1..08018109f 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,7 +1,7 @@ #### Latest Version ``` -1.23.1 +1.23.2 ``` #### Banner Current diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 3122e5a63..e5f02ba33 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,15 @@ +## 1.23.2 + +Release Date: June 21, 2022 + +#### RELEASE NOTES + +This release modifies how the Manager Username Lookup works with Get-JCUser. Only usernames/ emails that match the full string of the search are now returned + +#### BUG FIXES: + +* Get-JCUser -Manager "someUser" could return multiple values if another user username: "User" exists in the Organization + ## 1.23.1 Release Date: June 21, 2022 From 6598b9ed386b73e9d15fe8182e0e3a858bd644d4 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 10:23:57 -0600 Subject: [PATCH 07/12] Parallel help & nuspec --- .circleci/workflows.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 8f97ecc25..5266a6f26 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -85,7 +85,6 @@ workflows: requires: - Initial Setup - Build Modules - - Build Help and Test Files context: aws-credentials - Module Validation Tests: requires: @@ -104,7 +103,6 @@ workflows: - Initial Setup - Build Help and Test Files - Build Nuspec - - Module Validation Tests - Invoke Git Commit context: aws-credentials - Pester Tests Mac: @@ -112,7 +110,6 @@ workflows: - Initial Setup - Build Help and Test Files - Build Nuspec - - Module Validation Tests - Invoke Git Commit context: aws-credentials - Pester Tests Linux: @@ -120,7 +117,6 @@ workflows: - Initial Setup - Build Help and Test Files - Build Nuspec - - Module Validation Tests - Invoke Git Commit context: aws-credentials - Publish Module Validation: @@ -128,7 +124,6 @@ workflows: - Initial Setup - Build Help and Test Files - Build Nuspec - - Module Validation Tests - Invoke Git Commit release: when: From 484087d9e5893eeb68fa2024daabd2c87beef053 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 12:09:39 -0600 Subject: [PATCH 08/12] get/set/new searchjcsdk filter [skip CI] --- .../Public/Users/Get-JCUser.ps1 | 39 ++++++----- .../Public/Users/New-JCUser.ps1 | 44 ++++++++----- .../Public/Users/Set-JCUser.ps1 | 64 +++++++++++-------- 3 files changed, 87 insertions(+), 60 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 9dfbee268..205682b7f 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -315,11 +315,12 @@ Function Get-JCUser () if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - $managerSearch = @{ - filter = @( - @{'id' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + filter = @{ + 'and' = @( + @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } ) } + fields = 'id' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id @@ -327,9 +328,12 @@ Function Get-JCUser () # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @( - @{'username' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } - ) + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) + } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -341,22 +345,24 @@ Function Get-JCUser () $null = [mailaddress]$EmailAddress # Search manager using email $managerSearch = @{ - $managerSearch = @{ - filter = @( - @{'email' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + filter = @{ + 'and' = @( + @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } ) } + fields = 'email' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id if (!$managerValue){ $managerSearch = @{ - $managerSearch = @{ - filter = @( - @{'username' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -366,11 +372,12 @@ Function Get-JCUser () catch { # search the username in the search endpoint $managerSearch = @{ - $managerSearch = @{ - filter = @( - @{'username' = @{'$regex' = "(?i)(^$($param.Value)`$)" } } + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -388,7 +395,7 @@ Function Get-JCUser () } } - # case insensitve state param + # case insensitive state param if ("state" -eq $param.Key) { if ($param.Value -cin @('ACTIVATED', 'SUSPENDED', 'STAGED')) diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index 90e717290..430f926c0 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -326,21 +326,25 @@ Function New-JCUser () if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('id') + filter = @{ + 'and' = @( + @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'id' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -351,21 +355,25 @@ Function New-JCUser () try { $null = [mailaddress]$EmailAddress $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('email') + filter = @{ + 'and' = @( + @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'email' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -375,10 +383,12 @@ Function New-JCUser () catch { # search the username in the search endpoint $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index c47cb0cb0..dd8ae56e2 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -606,10 +606,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('id') + filter = @{ + 'and' = @( + @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'id' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id @@ -617,10 +619,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -632,10 +636,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $null = [mailaddress]$EmailAddress # Search for manager using email $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('email') + filter = @{ + 'and' = @( + @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'email' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id @@ -643,10 +649,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -656,10 +664,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline catch { # search the username in the search endpoint $managerSearch = @{ - searchFilter = @{ - searchTerm = @($param.Value) - fields = @('username') + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } + ) } + fields = 'username' } $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue from the matched username @@ -1148,12 +1158,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $body['state'] = 'SUSPENDED' } else { - switch ($state) + switch ($state) { - SUSPENDED { - $body['suspended'] = $true + SUSPENDED { + $body['suspended'] = $true } - ACTIVATED { + ACTIVATED { $body['suspended'] = $false } } @@ -1311,12 +1321,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $body['state'] = 'SUSPENDED' } else { - switch ($state) + switch ($state) { - SUSPENDED { - $body['suspended'] = $true + SUSPENDED { + $body['suspended'] = $true } - ACTIVATED { + ACTIVATED { $body['suspended'] = $false } } @@ -1467,12 +1477,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $body['state'] = 'SUSPENDED' } else { - switch ($state) + switch ($state) { - SUSPENDED { - $body['suspended'] = $true + SUSPENDED { + $body['suspended'] = $true } - ACTIVATED { + ACTIVATED { $body['suspended'] = $false } } From 9cbc9b53a0e8bb1ef87a5f22a15ebaf845148b98 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 13:18:45 -0600 Subject: [PATCH 09/12] new tests managerlookup (retain case insensitive search) --- .../Tests/Public/Users/Get-JCUser.tests.ps1 | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) 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 d49ea29bc..5ee3abe20 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 @@ -94,6 +94,28 @@ Describe -Tag:('JCUser') 'Get-JCUser 1.1' { $NewUser.manager | Should -Be $managerId Remove-JCUser -UserID $NewUser._id -force } + It "Searches a JumpCloud user by managerUsername & Email and should not return user with similar username" { + # Define two users who's username is contained by another user + $newUser1 = New-JCUser -username "jemartin" -firstname "je" -lastname "martin" -email "jemartin@deleteme.com" + $newUser2 = New-JCUser -username "emartin" -firstname "e" -lastname "martin" -email "emartin@deleteme.come" + $NewUser = New-RandomUser -Domain DeleteMe | New-JCUser -manager $newUser2.username + $NewUser = Get-JCUser -manager $newUser2.username + $NewUser = Get-JCUser -manager $newUser2.email + $NewUser.manager | Should -Be $newUser2.Id + $NewUser.manager | Should -Not -Be $newUser1.Id + # Remove all users from the test + Remove-JCUser -UserID $NewUser._id -force + Remove-JCUser -UserID $NewUser1._id -force + Remove-JCUser -UserID $NewUser2._id -force + } + It "Searches a JumpCloud user by managerUsername (Case Insensitive)" { + $managerUsername = $PesterParams_User1.username + $managerId = $PesterParams_User1.id + $NewUser = New-RandomUser -Domain DeleteMe | New-JCUser -manager $managerUsername + $NewUser = Get-JCUser -manager $($managerUsername.ToUpper()) + $NewUser.manager | Should -Be $managerId + Remove-JCUser -UserID $NewUser._id -force + } It "Searches a JumpCloud user by managerEmail" { $managerEmail = $PesterParams_User1.email $managerId = $PesterParams_User1.id @@ -102,6 +124,14 @@ Describe -Tag:('JCUser') 'Get-JCUser 1.1' { $NewUser.manager | Should -Be $managerId Remove-JCUser -UserID $NewUser._id -force } + It "Searches a JumpCloud user by managerEmail (Case Insensitive)" { + $managerEmail = $PesterParams_User1.email + $managerId = $PesterParams_User1.id + $NewUser = New-RandomUser -Domain DeleteMe | New-JCUser -manager $managerEmail + $NewUser = Get-JCUser -manager $($managerEmail.ToUpper()) + $NewUser.manager | Should -Be $managerId + Remove-JCUser -UserID $NewUser._id -force + } 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 @@ -415,4 +445,157 @@ 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 + } + } } \ No newline at end of file From 3594694733b3048e1c25261d08d752888bb35d2b Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 13:19:29 -0600 Subject: [PATCH 10/12] clear out case insensitive tests for different branch --- .../Tests/Public/Users/Get-JCUser.tests.ps1 | 153 ------------------ 1 file changed, 153 deletions(-) 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 5ee3abe20..6d0ed4fc7 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 @@ -445,157 +445,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 - } - } } \ No newline at end of file From ec1db1bd2f3b7dc8039342b09c8a199866d15fa5 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 11 Jul 2022 13:30:54 -0600 Subject: [PATCH 11/12] banner & Publish [skip ci] --- .circleci/workflows.yml | 2 +- PowerShell/ModuleBanner.md | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 5266a6f26..73d684267 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/ModuleBanner.md b/PowerShell/ModuleBanner.md index 9f0084d04..d2541cf92 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -7,11 +7,10 @@ #### Banner Current ``` -{{Fill in the Banner Current}} -``` +* Get-JCUser -State should accept case insensitive values such as "suspended" "activated" "staged" and validate input``` #### Banner Old ``` -{{Fill in the Banner Old}} +* Added search endpoint functionality and parameters to Get-jCCommand ``` From 6ad3476da06f2588c4c4577af667cda82ffa8f40 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 13 Jul 2022 11:21:37 -0600 Subject: [PATCH 12/12] cleanup remove comments [skip ci] --- PowerShell/Deploy/Setup-Dependencies.ps1 | 25 ------------------------ 1 file changed, 25 deletions(-) diff --git a/PowerShell/Deploy/Setup-Dependencies.ps1 b/PowerShell/Deploy/Setup-Dependencies.ps1 index 24329970d..6845030ef 100644 --- a/PowerShell/Deploy/Setup-Dependencies.ps1 +++ b/PowerShell/Deploy/Setup-Dependencies.ps1 @@ -1,5 +1,4 @@ Param( - # [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, Position = 0)][System.String[]]$DependentModules = ('PowerShellGet', 'PackageManagement', 'PSScriptAnalyzer', 'PlatyPS', 'Pester', 'AWS.Tools.Common', 'AWS.Tools.CodeArtifact') [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, Position = 0)][System.String]$RequiredModulesRepo = 'PSGallery' ) # Install NuGet @@ -32,30 +31,6 @@ foreach ($RequiredModule in $PSDependencies.Keys) Import-Module -Name:($RequiredModule) -Force -Global } } -# # Install dependent modules -# ForEach ($DependentModule In $DependentModules) -# { -# # Check to see if the module is installed -# If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $DependentModule }))) -# { -# Write-Host("[status]Installing module: '$DependentModule' from 'PSGallery'") -# if ($DependentModule -eq 'PowerShellGet'){ -# Install-Module -Name $DependentModule -Repository:('PSGallery') -RequiredVersion '3.0.12-beta' -AllowPrerelease -Force -# } -# elseif ($DependentModule -eq 'PSScriptAnalyzer') { -# Install-Module -Name $DependentModule -Repository:('PSGallery') -RequiredVersion '1.19.1' -Force -# } -# else{ -# Install-Module -Repository:('PSGallery') -Force -Name:($DependentModule) -Scope:('CurrentUser') -AllowClobber -# } -# } -# # Get-Module -Refresh -ListAvailable -# If ([System.String]::IsNullOrEmpty((Get-Module | Where-Object { $_.Name -eq $DependentModule }))) -# { -# Write-Host("[status]Importing module: '$DependentModule'") -# Import-Module -Name:($DependentModule) -Force -Global -# } -# } ### TODO: Switch to CodeArtifact If ($RequiredModulesRepo -ne 'PSGallery') {