Conversation
Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
…lePlanObject to Private/ folder Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
- Created Test-IdleExchangeOnlinePrerequisites.ps1 helper - Updated provider to warn (not throw) on creation when prerequisites missing - Added runtime prerequisite validation in ExtractAccessToken method - Follows same pattern as AD and EntraID providers - All 17 ExchangeOnline tests passing Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
The ExchangeOnline provider was previously throwing an exception during provider creation when the ExchangeOnlineManagement module was missing (line 82 in the old code), which violated the Prerequisites Policy (rule D.2). I've now added the prerequisite check to ExchangeOnline provider in commit 7683730:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors large provider and core files by extracting nested functions into focused Private/ helpers, reducing main files by ~800 lines total. It also implements consistent prerequisite validation across all three providers (AD, EntraID, ExchangeOnline), fixing a violation where ExchangeOnline was throwing exceptions during provider creation instead of emitting warnings.
Changes:
- Extracted 10 nested functions from New-IdlePlanObject.ps1 (671 → 110 lines, 83% reduction) and 2 from Invoke-IdlePlanObject.ps1 (782 → 640 lines, 18% reduction)
- Added prerequisite validation helpers (Test-Idle*Prerequisites.ps1) for all three providers with consistent warning-at-creation / error-at-use pattern
- Extracted entitlement conversion logic into ConvertTo-Idle*Entitlement.ps1 helpers for AD and EntraID providers
- Enhanced Resolve-IdleStepHandler to support both hashtable and object StepRegistry types and module-qualified step names
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| New-IdleExchangeOnlineProvider.ps1 | Added prerequisite checks at provider creation and method invocation; reordered AuthSession type checks |
| Test-IdleExchangeOnlinePrerequisites.ps1 | New helper that validates ExchangeOnlineManagement module availability |
| New-IdleEntraIDIdentityProvider.ps1 | Added prerequisite checks; extracted entitlement conversion; reordered AuthSession type checks |
| Test-IdleEntraIDPrerequisites.ps1 | New helper that validates Invoke-RestMethod availability (minimal check for built-in dependency) |
| ConvertTo-IdleEntraIDEntitlement.ps1 | Extracted entitlement normalization logic with Mail field support |
| New-IdleADIdentityProvider.ps1 | Added prerequisite checks at provider creation and in GetEffectiveAdapter |
| Test-IdleADPrerequisites.ps1 | New helper that validates ActiveDirectory module availability |
| ConvertTo-IdleADEntitlement.ps1 | Extracted entitlement normalization logic |
| New-IdlePlanObject.ps1 | Removed 10 nested functions, now calls extracted Private helpers (83% reduction) |
| Invoke-IdlePlanObject.ps1 | Removed 2 nested functions, now calls extracted Private helpers (18% reduction) |
| Resolve-IdleStepHandler.ps1 | Enhanced to support object/hashtable StepRegistry types and module-qualified handler names |
| 10 new Core Private helpers | Extracted planning and execution helpers with Set-StrictMode and proper documentation |
src/IdLE.Provider.EntraID/Private/Test-IdleEntraIDPrerequisites.ps1
Outdated
Show resolved
Hide resolved
src/IdLE.Provider.ExchangeOnline/Private/Test-IdleExchangeOnlinePrerequisites.ps1
Show resolved
Hide resolved
src/IdLE.Provider.ExchangeOnline/Public/New-IdleExchangeOnlineProvider.ps1
Outdated
Show resolved
Hide resolved
src/IdLE.Provider.EntraID/Public/New-IdleEntraIDIdentityProvider.ps1
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/IdLE.Provider.ExchangeOnline/Public/New-IdleExchangeOnlineProvider.ps1
Outdated
Show resolved
Hide resolved
src/IdLE.Provider.EntraID/Public/New-IdleEntraIDIdentityProvider.ps1
Outdated
Show resolved
Hide resolved
- Added Set-StrictMode -Version Latest to all 5 Provider Private helpers - Fixed AuthSession type check order in EntraID and ExchangeOnline to match documentation: 1. String token 2. Object with AccessToken property 3. Object with GetAccessToken() method 4. PSCredential - Use Where-Object for property/method checks to avoid StrictMode errors on empty collections - All 333 tests passing Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
✅ Repository Structure Refactor Complete
Successfully refactored provider layout and split large files into cohesive, maintainable units.
📊 Summary of Changes
Provider Refactors (Phase 1)
AD Provider (
src/IdLE.Provider.AD/)New-IdleADIdentityProvider.ps1692 → 681 lines (1.6% reduction)Test-IdleADPrerequisites.ps1- Structured prerequisite checking (does not throw)ConvertTo-IdleADEntitlement.ps1- Entitlement normalization/validationEntraID Provider (
src/IdLE.Provider.EntraID/)New-IdleEntraIDIdentityProvider.ps1873 → 853 lines (2.3% reduction)Test-IdleEntraIDPrerequisites.ps1- Structured prerequisite checking (does not throw)ConvertTo-IdleEntraIDEntitlement.ps1- Entitlement normalization/validationExchangeOnline Provider (
src/IdLE.Provider.ExchangeOnline/) ✨ NEWNew-IdleExchangeOnlineProvider.ps1372 → 394 linesTest-IdleExchangeOnlinePrerequisites.ps1- Structured prerequisite checking (does not throw)Core Refactors (Phase 2)
New-IdlePlanObject.ps1 - 671 → 110 lines (83.6% reduction!)
Private/:ConvertTo-NullIfEmptyString.ps1Get-IdleOptionalPropertyValue.ps1ConvertTo-IdleNormalizedCapability.ps1ConvertTo-IdleRequiredCapabilities.ps1Get-IdleProvidersFromMap.ps1Get-IdleAvailableCapabilities.ps1Assert-IdlePlanCapabilitiesSatisfied.ps1Test-IdleWorkflowStepKey.ps1Get-IdleWorkflowStepValue.ps1ConvertTo-IdleWorkflowSteps.ps1Invoke-IdlePlanObject.ps1 - 782 → 640 lines (18.2% reduction)
Private/:Get-IdleCommandParameterNames.ps1Get-IdleStepField.ps1Resolve-IdleStepHandler.ps1(module-qualified name support)Total Impact:
✅ Quality Gates Passed
📋 Definition of Done
📝 Technical Notes
Prerequisites Policy:
IdLE.PrerequisitesResultobjectsCode Organization:
Set-StrictMode -Version Latestfor consistencyAuthSession Handling:
No Breaking Changes:
-Adapterparameter) continues to work🎯 Impact
This refactor significantly improves:
The repository now follows best practices for PowerShell module structure with clear separation between public contracts and internal implementation details.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.