Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Authentication:

**Synopsis**

Triggers an Entra Connect directory sync cycle and optionally waits for completion.
Triggers a directory sync cycle and optionally waits for completion.

**Description**

Expand Down
7 changes: 7 additions & 0 deletions src/IdLE.Core/Private/Get-IdleStepRegistry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,12 @@ function Get-IdleStepRegistry {
}
}

if (-not $registry.ContainsKey('IdLE.Step.TriggerDirectorySync')) {
$handler = Resolve-IdleStepHandlerName -CommandName 'Invoke-IdleStepTriggerDirectorySync' -ModuleName 'IdLE.Steps.DirectorySync'
if (-not [string]::IsNullOrWhiteSpace($handler)) {
$registry['IdLE.Step.TriggerDirectorySync'] = $handler
}
}

return $registry
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@{
RootModule = 'IdLE.Steps.DirectorySync.EntraConnect.psm1'
RootModule = 'IdLE.Steps.DirectorySync.psm1'
ModuleVersion = '0.8.0'
GUID = 'b2c3d4e5-6f78-9012-bcde-f12345678901'
Author = 'Matthias Fleschuetz'
Copyright = '(c) Matthias Fleschuetz. All rights reserved.'
Description = 'Entra Connect directory sync steps for IdLE.'
Description = 'Generic directory sync steps for IdLE.'
PowerShellVersion = '7.0'

RequiredModules = @(
Expand All @@ -17,7 +17,7 @@

PrivateData = @{
PSData = @{
Tags = @('IdentityLifecycleEngine', 'IdLE', 'Steps', 'DirectorySync', 'EntraConnect')
Tags = @('IdentityLifecycleEngine', 'IdLE', 'Steps', 'DirectorySync')
LicenseUri = 'https://www.apache.org/licenses/LICENSE-2.0'
ProjectUri = 'https://github.com/blindzero/IdentityLifecycleEngine'
ContactEmail = '13959569+blindzero@users.noreply.github.com'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function Invoke-IdleStepTriggerDirectorySync {
<#
.SYNOPSIS
Triggers an Entra Connect directory sync cycle and optionally waits for completion.
Triggers a directory sync cycle and optionally waits for completion.

.DESCRIPTION
This is a provider-agnostic step. The host must supply a provider instance via
Expand Down Expand Up @@ -35,10 +35,10 @@ function Invoke-IdleStepTriggerDirectorySync {

.EXAMPLE
$step = @{
Name = 'Trigger Entra Connect sync'
Name = 'Trigger directory sync'
Type = 'IdLE.Step.TriggerDirectorySync'
With = @{
AuthSessionName = 'EntraConnect'
AuthSessionName = 'DirectorySync'
PolicyType = 'Delta'
Wait = $true
}
Expand Down
2 changes: 1 addition & 1 deletion src/IdLE/IdLE.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
NestedModules = @(
'..\IdLE.Core\IdLE.Core.psd1',
'..\IdLE.Steps.Common\IdLE.Steps.Common.psd1',
'..\IdLE.Steps.DirectorySync.EntraConnect\IdLE.Steps.DirectorySync.EntraConnect.psd1',
'..\IdLE.Steps.DirectorySync\IdLE.Steps.DirectorySync.psd1',
'..\IdLE.Provider.DirectorySync.EntraConnect\IdLE.Provider.DirectorySync.EntraConnect.psd1',
'..\IdLE.Provider.AD\IdLE.Provider.AD.psd1'
)
Expand Down
38 changes: 19 additions & 19 deletions tests/Invoke-IdleStepTriggerDirectorySync.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,39 +100,39 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
Type = 'IdLE.Step.TriggerDirectorySync'
}

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $step } | Should -Throw
}

It 'throws when With.AuthSessionName is missing' {
$step = $script:StepTemplate
$step.With.Remove('AuthSessionName')

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $step } | Should -Throw -ErrorId * -ExpectedMessage '*AuthSessionName*'
}

It 'throws when With.PolicyType is missing' {
$step = $script:StepTemplate
$step.With.Remove('PolicyType')

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $step } | Should -Throw -ErrorId * -ExpectedMessage '*PolicyType*'
}

It 'throws when With.PolicyType is invalid' {
$step = $script:StepTemplate
$step.With.PolicyType = 'Invalid'

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $step } | Should -Throw -ErrorId * -ExpectedMessage '*PolicyType*'
}

It 'accepts Delta as PolicyType' {
$step = $script:StepTemplate
$step.With.PolicyType = 'Delta'

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$result = & $handler -Context $script:Context -Step $step

$result.Status | Should -Be 'Completed'
Expand All @@ -142,7 +142,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step = $script:StepTemplate
$step.With.PolicyType = 'Initial'

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$result = & $handler -Context $script:Context -Step $step

$result.Status | Should -Be 'Completed'
Expand All @@ -152,7 +152,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step = $script:StepTemplate
$step.With.Remove('Provider')

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$result = & $handler -Context $script:Context -Step $step

$result.Status | Should -Be 'Completed'
Expand All @@ -162,15 +162,15 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step = $script:StepTemplate
$step.With.TimeoutSeconds = -1

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $step } | Should -Throw -ErrorId * -ExpectedMessage '*TimeoutSeconds*'
}

It 'throws when PollIntervalSeconds is invalid' {
$step = $script:StepTemplate
$step.With.PollIntervalSeconds = 0

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $step } | Should -Throw -ErrorId * -ExpectedMessage '*PollIntervalSeconds*'
}
}
Expand All @@ -180,7 +180,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step = $script:StepTemplate
$step.With.Wait = $false

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$result = & $handler -Context $script:Context -Step $step

$result.Status | Should -Be 'Completed'
Expand All @@ -191,7 +191,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
It 'defaults to not waiting when Wait is not specified' {
$step = $script:StepTemplate

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$result = & $handler -Context $script:Context -Step $step

$result.Status | Should -Be 'Completed'
Expand All @@ -204,7 +204,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step.With.Wait = $true
$step.With.PollIntervalSeconds = 1

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$result = & $handler -Context $script:Context -Step $step

$result.Status | Should -Be 'Completed'
Expand All @@ -227,7 +227,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step.With.TimeoutSeconds = 2
$step.With.PollIntervalSeconds = 1

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $step } | Should -Throw -ErrorId * -ExpectedMessage '*Timeout*'
}

Expand All @@ -249,7 +249,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step.With.Wait = $true
$step.With.PollIntervalSeconds = 1

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$result = & $handler -Context $script:Context -Step $step

$script:MockProvider.PollCount | Should -BeGreaterThan 1
Expand All @@ -260,15 +260,15 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
It 'throws when provider is missing' {
$script:Context.Providers.Clear()

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $script:StepTemplate } | Should -Throw -ErrorId * -ExpectedMessage '*Provider*'
}

It 'throws when provider does not implement StartSyncCycle' {
$badProvider = [pscustomobject]@{ Name = 'BadProvider' }
$script:Context.Providers['DirectorySync'] = $badProvider

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
{ & $handler -Context $script:Context -Step $script:StepTemplate } | Should -Throw -ErrorId * -ExpectedMessage '*StartSyncCycle*'
}
}
Expand All @@ -282,7 +282,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$null = $capturedEvents.Add(@{ Type = $Type; Message = $Message; StepName = $StepName; Data = $Data })
} -Force

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $script:StepTemplate

$capturedEvents.Type | Should -Contain 'DirectorySyncTriggered'
Expand All @@ -296,7 +296,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$null = $capturedEvents.Add(@{ Type = $Type; Message = $Message; StepName = $StepName; Data = $Data })
} -Force

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $script:StepTemplate

$capturedEvents.Type | Should -Contain 'DirectorySyncCompleted'
Expand All @@ -314,7 +314,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$step.With.Wait = $true
$step.With.PollIntervalSeconds = 1

$handler = 'IdLE.Steps.DirectorySync.EntraConnect\Invoke-IdleStepTriggerDirectorySync'
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $step

$capturedEvents.Type | Should -Contain 'DirectorySyncWaiting'
Expand Down
2 changes: 1 addition & 1 deletion tests/_testHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Import-IdleTestModule {
$stepsCommonManifestPath = Resolve-Path -Path (Join-Path (Get-RepoRootPath) 'src/IdLE.Steps.Common/IdLE.Steps.Common.psd1')
Import-Module -Name $stepsCommonManifestPath -Force -ErrorAction Stop

$stepsDirectorySyncManifestPath = Resolve-Path -Path (Join-Path (Get-RepoRootPath) 'src/IdLE.Steps.DirectorySync.EntraConnect/IdLE.Steps.DirectorySync.EntraConnect.psd1')
$stepsDirectorySyncManifestPath = Resolve-Path -Path (Join-Path (Get-RepoRootPath) 'src/IdLE.Steps.DirectorySync/IdLE.Steps.DirectorySync.psd1')
Import-Module -Name $stepsDirectorySyncManifestPath -Force -ErrorAction Stop

$mockProviderManifestPath = Resolve-Path -Path (Join-Path (Get-RepoRootPath) 'src/IdLE.Provider.Mock/IdLE.Provider.Mock.psd1')
Expand Down
2 changes: 1 addition & 1 deletion tools/Generate-IdleStepReference.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ param(
# Restrict which step modules are scanned.
[Parameter()]
[ValidateNotNullOrEmpty()]
[string[]] $StepModules = @('IdLE.Steps.Common', 'IdLE.Steps.DirectorySync.EntraConnect'),
[string[]] $StepModules = @('IdLE.Steps.Common', 'IdLE.Steps.DirectorySync'),

# Optional: Step function names to exclude (exact command names).
[Parameter()]
Expand Down