-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a2cd9c
commit c12ac71
Showing
90 changed files
with
8,068 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
PowerShell/JumpCloud Module/Tests/ModuleValidation/moduleValidation.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Describe -Tag:('ModuleValidation') 'Module Manifest Tests' { | ||
It ('Passes Test-ModuleManifest') { | ||
$module = Test-ModuleManifest -Path:("$FilePath_psd1") | ||
# validate module | ||
$module.RootModule | Should -Be "JumpCloud.psm1" | ||
$module.Author | Should -Be "JumpCloud Solutions Architect Team" | ||
$module.CompanyName | Should -Be "JumpCloud" | ||
$module.Copyright | Should -Be "(c) JumpCloud. All rights reserved." | ||
$module.Description | Should -Be "PowerShell functions to manage a JumpCloud Directory-as-a-Service" | ||
|
||
# validate required Modules | ||
$RequiredModules = @('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') | ||
$RequiredModules | ForEach-Object { | ||
$module.RequiredModules.Name | should -Contain $_ | ||
} | ||
|
||
$ExportedFuncs = $module.ExportedFunctions.keys | Group-Object | ||
foreach ($func in $ExportedFuncs) { | ||
$func.count | should -BeExactly 1 | ||
} | ||
# Validate module version | ||
$latestModule = Find-Module -Name JumpCloud | ||
$module.Version | should -BeGreaterThan $latestModule.version | ||
# GHA Env Variables | ||
if (-Not $env:OVERRIDE_VERSION) { | ||
switch ($env:RELEASE_TYPE) { | ||
'major' { | ||
$module.Version.Major | Should -Be (([version]$latestModule.Version).Major + 1) | ||
} | ||
'minor' { | ||
$module.Version.Minor | Should -Be (([version]$latestModule.Version).Minor + 1) | ||
} | ||
'patch' { | ||
$module.Version.Build | Should -Be (([version]$latestModule.Version).Build + 1) | ||
} | ||
} | ||
} | ||
} | ||
It 'When Update-ModuleManifest is run, no changes in the current branch are behind' { | ||
Update-ModuleManifest -Path:($FilePath_psd1) | ||
$diff = git diff -- $FilePath_psd1 | ||
if ($diff) { | ||
write-warning "diff found in file: $FilePath_psd1 when we expected none to exist; have you run `Update-ModuleManifest -Path /src/PowerShell/JumpCloud Module/JumpCloud.psd1` and committed the resulting changes?" | ||
} | ||
$diff | Should -BeNullOrEmpty | ||
$moduleContent = Get-COntent -Path ("$FilePath_psd1") | ||
$stringMatch = Select-String -InputObject $moduleContent -Pattern "# Generated on: ([\d]+\/[\d]+\/[\d]+)" | ||
$PSD1_date = $stringMatch.matches.groups[1].value | ||
$PSD1_date | Should -Be ( Get-Date -Format "M/d/yyyy" ) | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
90 changes: 90 additions & 0 deletions
90
PowerShell/JumpCloud Module/Tests/Private/HashFunctions/Get-DynamicHash.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Describe -Tag:('DynamicHash') "Get-DynamicHash" { | ||
BeforeAll { Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKey) -force | Out-Null } | ||
It "User Hash" { | ||
$UserHash = Get-DynamicHash -Object User -returnProperties 'created', 'account_locked', 'activated', 'addresses', 'allow_public_key', 'attributes', 'email', 'enable_managed_uid', 'enable_user_portal_multifactor', 'externally_managed', 'firstname', 'lastname', 'ldap_binding_user', 'passwordless_sudo', 'password_expired', 'password_never_expires', 'phoneNumbers', 'samba_service_user', 'ssh_keys', 'sudo', 'suspended', 'totp_enabled', 'unix_guid', 'unix_uid', 'username', 'alternateEmail', 'managedAppleId', 'recoveryEmail' | ||
|
||
$UserHash.count | Should -Be (Get-JCUser).count | ||
|
||
$UserHash.values.account_locked | Should -Not -Be $null | ||
$UserHash.values.activated | Should -Not -Be $null | ||
$UserHash.values.addresses | Should -Not -Be $null | ||
$UserHash.values.allow_public_key | Should -Not -Be $null | ||
$UserHash.values.alternateEmail | Should -Not -Be $null | ||
$UserHash.values.attributes | Should -Not -Be $null | ||
$UserHash.values.created | Should -Not -Be $null | ||
$UserHash.values.email | Should -Not -Be $null | ||
$UserHash.values.recoveryEmail | Should -Not -Be $null | ||
$UserHash.values.enable_managed_uid | Should -Not -Be $null | ||
$UserHash.values.enable_user_portal_multifactor | Should -Not -Be $null | ||
$UserHash.values.externally_managed | Should -Not -Be $null | ||
$UserHash.values.firstname | Should -Not -Be $null | ||
$UserHash.values.lastname | Should -Not -Be $null | ||
$UserHash.values.ldap_binding_user | Should -Not -Be $null | ||
$UserHash.values.managedAppleID | Should -Not -Be $null | ||
$UserHash.values.password_expired | Should -Not -Be $null | ||
$UserHash.values.password_never_expires | Should -Not -Be $null | ||
$UserHash.values.passwordless_sudo | Should -Not -Be $null | ||
$UserHash.values.phoneNumbers | Should -Not -Be $null | ||
$UserHash.values.samba_service_user | Should -Not -Be $null | ||
$UserHash.values.sudo | Should -Not -Be $null | ||
$UserHash.values.suspended | Should -Not -Be $null | ||
$UserHash.values.totp_enabled | Should -Not -Be $null | ||
$UserHash.values.unix_guid | Should -Not -Be $null | ||
$UserHash.values.unix_uid | Should -Not -Be $null | ||
$UserHash.values.username | Should -Not -Be $null | ||
} | ||
It "System Hash" { | ||
$SystemHash = Get-DynamicHash -Object System -returnProperties 'created', 'active', 'agentVersion', 'allowMultiFactorAuthentication', 'allowPublicKeyAuthentication', 'allowSshPasswordAuthentication', 'allowSshRootLogin', 'arch', 'created', 'displayName', 'hostname', 'lastContact', 'modifySSHDConfig', 'organization', 'os', 'remoteIP', 'serialNumber', 'systemTimezone', 'templateName', 'version' | ||
|
||
$SystemHash.count | Should -Be (Get-JCSystem).count | ||
|
||
$SystemHash.values.created | Should -Not -Be $null | ||
$SystemHash.values.active | Should -Not -Be $null | ||
$SystemHash.values.agentVersion | Should -Not -Be $null | ||
$SystemHash.values.allowMultiFactorAuthentication | Should -Not -Be $null | ||
$SystemHash.values.allowPublicKeyAuthentication | Should -Not -Be $null | ||
$SystemHash.values.allowSshPasswordAuthentication | Should -Not -Be $null | ||
$SystemHash.values.allowSshRootLogin | Should -Not -Be $null | ||
$SystemHash.values.arch | Should -Not -Be $null | ||
$SystemHash.values.created | Should -Not -Be $null | ||
$SystemHash.values.displayName | Should -Not -Be $null | ||
$SystemHash.values.hostname | Should -Not -Be $null | ||
$SystemHash.values.lastContact | Should -Not -Be $null | ||
$SystemHash.values.modifySSHDConfig | Should -Not -Be $null | ||
$SystemHash.values.organization | Should -Not -Be $null | ||
$SystemHash.values.os | Should -Not -Be $null | ||
$SystemHash.values.remoteIP | Should -Not -Be $null | ||
$SystemHash.values.serialNumber | Should -Not -Be $null | ||
$SystemHash.values.systemTimezone | Should -Not -Be $null | ||
$SystemHash.values.templateName | Should -Not -Be $null | ||
$SystemHash.values.version | Should -Not -Be $null | ||
} | ||
It "SystemGroup Hash" { | ||
$SystemGroupHash = Get-DynamicHash -Object Group -GroupType System -returnProperties 'name', 'type' | ||
|
||
$SystemGroupHash.count | Should -Be (Get-JCGroup -Type System).count | ||
|
||
$SystemGroupHash.values.name | Should -Not -Be $null | ||
$SystemGroupHash.values.type | Should -Not -Be $null | ||
} | ||
It "UserGroup Hash" { | ||
$UserGroupHash = Get-DynamicHash -Object Group -GroupType User -returnProperties 'name', 'type' | ||
|
||
$UserGroupHash.count | Should -Be (Get-JCGroup -Type User).count | ||
|
||
$UserGroupHash.values.name | Should -Not -Be $null | ||
$UserGroupHash.values.type | Should -Not -Be $null | ||
} | ||
It "Command Hash" { | ||
$CommandHash = Get-DynamicHash -Object Command -returnProperties 'command', 'name', 'launchType', 'commandType', 'trigger', 'scheduleRepeatType' | ||
|
||
$CommandHash.count | Should -Be (Get-JCCommand).count | ||
|
||
$CommandHash.Values.command | Should -Not -Be $null | ||
$CommandHash.Values.name | Should -Not -Be $null | ||
$CommandHash.Values.launchType | Should -Not -Be $null | ||
$CommandHash.Values.commandType | Should -Not -Be $null | ||
$CommandHash.Values.trigger | Should -Not -Be $null | ||
$CommandHash.Values.scheduleRepeatType | Should -Not -Be $null | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
42 changes: 42 additions & 0 deletions
42
PowerShell/JumpCloud Module/Tests/Public/Authentication/Connect-JCOnline.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Describe -Tag:('JCOnline') 'Connect-JCOnline Tests' { | ||
BeforeAll { | ||
$StartingApiKey = If (-not [System.String]::IsNullOrEmpty($env:JCApiKey)) { $env:JCApiKey } | ||
$StartingOrgId = If (-not [System.String]::IsNullOrEmpty($env:JCOrgId)) { $env:JCOrgId } | ||
} | ||
Context 'Single Org Tests' { | ||
It ('Should connect using the JumpCloudApiKey and JumpCloudOrgId parameters.') { | ||
$Connect = Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKey) -JumpCloudOrgId:($PesterParams_Org.OrgID) -force | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$PesterParams_Org.OrgID | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
It ('Should connect using the JumpCloudApiKey parameter.') { | ||
$Connect = Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKey) -force | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$PesterParams_Org.OrgID | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
It ('Should connect using the JumpCloudOrgId parameter.') { | ||
$Connect = Connect-JCOnline -JumpCloudOrgId:($PesterParams_ApiKey) -force | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$PesterParams_Org.OrgID | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
It('Should connect without parameters using the previously set env:jc* parameters.') { | ||
$Connect = Connect-JCOnline -force | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$PesterParams_Org.OrgID | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $env:JCOrgId | ||
# $Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
} | ||
AfterAll { | ||
If (-not [System.String]::IsNullOrEmpty($StartingApiKey) -and -not [System.String]::IsNullOrEmpty($StartingOrgId)) { Connect-JCOnline -JumpCloudApiKey:($StartingApiKey) -JumpCloudOrgId:($StartingOrgId) -force | Out-Null } | ||
ElseIf (-not [System.String]::IsNullOrEmpty($StartingApiKey) -and [System.String]::IsNullOrEmpty($StartingOrgId)) { Connect-JCOnline -JumpCloudApiKey:($StartingApiKey) -force | Out-Null } | ||
ElseIf ([System.String]::IsNullOrEmpty($StartingApiKey) -and -not [System.String]::IsNullOrEmpty($StartingOrgId)) { Connect-JCOnline -JumpCloudOrgId:($StartingOrgId) -force | Out-Null } | ||
Else { Write-Error ('Unknown scenario encountered') } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
PowerShell/JumpCloud Module/Tests/Public/Authentication/Get-JCOrganization.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Describe -Tag:('JCOrganization') 'Get-JCOrganization 1.6' { | ||
It 'Returns JumpCloud Organizations ' { | ||
Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKeyMsp) -JumpCloudOrgId:($PesterParams_OrgIDMsp1) -force | ||
$Connect | Should -Be $null | ||
$Organizations = Get-JCOrganization | ||
$OrgVerify = $Organizations | Select-Object OrgID -Unique | ||
$OrgVerify.Count | Should -BeGreaterThan 1 | ||
} | ||
It 'Returns JumpCloud Organizations connected to two different orgs' { | ||
Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKeyMsp) -JumpCloudOrgId:($PesterParams_OrgIDMsp1) -force | ||
$Connect | Should -Be $null | ||
$Organizations = Get-JCOrganization | ||
$OrgVerify = $Organizations | Select-Object OrgID -Unique | ||
$OrgVerify.Count | Should -BeGreaterThan 1 | ||
|
||
Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKeyMsp) -JumpCloudOrgId:($PesterParams_OrgIDMsp2) -force | ||
$Connect | Should -Be $null | ||
$Organizations = Get-JCOrganization | ||
$OrgVerify = $Organizations | Select-Object OrgID -Unique | ||
$OrgVerify.Count | Should -BeGreaterThan 1 | ||
} | ||
AfterAll { | ||
Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKey) -force | Out-Null | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
PowerShell/JumpCloud Module/Tests/Public/Authentication/Set-JCOrganization.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Describe -Tag:('JCOrganization') 'Set-JCOrganization Tests' { | ||
BeforeAll { | ||
# Prevent the Update-JCModule from running | ||
$env:JcUpdateModule = $false | ||
$StartingApiKey = If (-not [System.String]::IsNullOrEmpty($env:JCApiKey)) { $env:JCApiKey } | ||
$StartingOrgId = If (-not [System.String]::IsNullOrEmpty($env:JCOrgId)) { $env:JCOrgId } | ||
} | ||
Context 'Single Org Tests' { | ||
It ('Should connect using the JumpCloudApiKey and JumpCloudOrgId parameters.') { | ||
$Connect = Set-JCOrganization -JumpCloudApiKey:($PesterParams_ApiKey) -JumpCloudOrgId:($PesterParams_Org.OrgID) | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
It ('Should connect using the JumpCloudApiKey parameter.') { | ||
$Connect = Set-JCOrganization -JumpCloudApiKey:($PesterParams_ApiKey) | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
It ('Should connect using the JumpCloudOrgId parameter.') { | ||
$Connect = Set-JCOrganization -JumpCloudOrgId:($PesterParams_ApiKey) | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
It('Should connect without parameters using the previously set env:jc* parameters.') { | ||
$Connect = Set-JCOrganization | ||
$PesterParams_ApiKey | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_Org.OrgID | ||
} | ||
} | ||
Context 'MSP OrgId 1 Tests' { | ||
It ('Should connect using the JumpCloudApiKey and JumpCloudOrgId parameters.') { | ||
$Connect = Set-JCOrganization -JumpCloudApiKey:($PesterParams_ApiKeyMsp) -JumpCloudOrgId:($PesterParams_OrgIDMsp1) | ||
$PesterParams_ApiKeyMsp | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_OrgIDMsp1 | ||
} | ||
It ('Should connect using the JumpCloudOrgId parameter.') { | ||
$Connect = Set-JCOrganization -JumpCloudOrgId:($PesterParams_OrgIDMsp1) | ||
$PesterParams_ApiKeyMsp | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_OrgIDMsp1 | ||
} | ||
} | ||
Context 'MSP OrgId 2 Tests' { | ||
It ('Should connect using the JumpCloudApiKey and JumpCloudOrgId parameters.') { | ||
$Connect = Set-JCOrganization -JumpCloudApiKey:($PesterParams_ApiKeyMsp) -JumpCloudOrgId:($PesterParams_OrgIDMsp2) | ||
$PesterParams_ApiKeyMsp | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_OrgIDMsp2 | ||
} | ||
It ('Should connect using the JumpCloudOrgId parameter.') { | ||
$Connect = Set-JCOrganization -JumpCloudOrgId:($PesterParams_OrgIDMsp2) | ||
$PesterParams_ApiKeyMsp | Should -Be $env:JCApiKey | ||
$Connect.JCOrgId | Should -Be $env:JCOrgId | ||
$Connect.JCOrgId | Should -Be $PesterParams_OrgIDMsp2 | ||
} | ||
} | ||
AfterAll { | ||
Connect-JCOnline -JumpCloudApiKey:($PesterParams_ApiKey) -force | Out-Null | ||
} | ||
} |
Oops, something went wrong.