-
Notifications
You must be signed in to change notification settings - Fork 31
AdcsOnlineResponder: Convert to class-based
#158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dan-hughes
wants to merge
20
commits into
dsccommunity:main
Choose a base branch
from
dan-hughes:class/AdcsOnlineResponder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
314d40a
Remove MOF
dan-hughes bf1c391
Add class
dan-hughes 553587e
Update changelog
dan-hughes 2e8e65b
Fix misplaced It block
dan-hughes 51b7e02
Enable Test and Set tests
dan-hughes 5c28b65
coderabbit fixes
dan-hughes c200798
Use preview common module
dan-hughes 43c519f
Enable string
dan-hughes 343bca2
Work around type not existing
dan-hughes 16761af
Add GetCurrentState tests
dan-hughes 05c2164
Add setup exception stub
dan-hughes 3be68e8
Update Modify and GetCurrentState
dan-hughes 58f1c2f
Fix tests
dan-hughes bb1d9c7
Update Modify tests
dan-hughes 8ad4cf0
Fully qualify command names and remove used functions table
dan-hughes 1001230
Remove fully qualified command names
dan-hughes 43ad21f
Improve Integration test reliability
dan-hughes 4ba8b9a
Use preview DscResource.Test
dan-hughes 0c42817
Add HQRM fix
dan-hughes b0ef088
Move to latest DscResource.Test
dan-hughes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,137 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| The `AdcsOnlineResponder` DSC resource is used to configure the | ||
| ADCS Online Responder after the feature has been installed on the server. | ||
|
|
||
| .DESCRIPTION | ||
| This resource can be used to install an ADCS Online Responder after the feature | ||
| has been installed on the server. | ||
| Using this DSC Resource to configure an ADCS Certificate Authority assumes that | ||
| the ```ADCS-Online-Responder``` feature has already been installed. | ||
|
|
||
| .PARAMETER IsSingleInstance | ||
| Specifies the resource is a single instance, the value must be 'Yes'. | ||
|
|
||
| .PARAMETER Credential | ||
| If the Online Responder service is configured to use Standalone certification authority, | ||
| then an account that is a member of the local Administrators on the CA is required. If | ||
| the Online Responder service is configured to use an Enterprise CA, then an account that | ||
| is a member of Domain Admins is required. | ||
|
|
||
| .PARAMETER Ensure | ||
| Specifies whether the Online Responder feature should be installed or uninstalled. | ||
|
|
||
| .PARAMETER Reasons | ||
| Returns the reason a property is not in desired state. | ||
|
|
||
| .NOTES | ||
| Used Functions: | ||
| Name | Module | ||
| ----------------------------- |------------------- | ||
| Install-AdcsOnlineResponder | ADCSDeployment | ||
| Uninstall-AdcsOnlineResponder | ADCSDeployment | ||
| Assert-Module | DscResource.Common | ||
| New-InvalidOperationException | DscResource.Common | ||
| #> | ||
|
|
||
| [DscResource()] | ||
| class AdcsOnlineResponder : ResourceBase | ||
dan-hughes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| [DscProperty(Key)] | ||
| [System.String] | ||
| $IsSingleInstance = 'Yes' | ||
|
|
||
| [DscProperty(Mandatory)] | ||
| [System.Management.Automation.PSCredential] | ||
| [System.Management.Automation.Credential()] | ||
| $Credential | ||
|
|
||
| [DscProperty()] | ||
| [Ensure] | ||
| $Ensure = [Ensure]::Present | ||
|
|
||
| [DscProperty(NotConfigurable)] | ||
| [AdcsReason[]] | ||
| $Reasons | ||
|
|
||
| AdcsOnlineResponder () : base ($PSScriptRoot) | ||
| { | ||
| # These properties will not be enforced. | ||
| $this.ExcludeDscProperties = @( | ||
| 'IsSingleInstance' | ||
| 'Credential' | ||
| ) | ||
| } | ||
|
|
||
| [AdcsOnlineResponder] Get() | ||
| { | ||
| # Call the base method to return the properties. | ||
| return ([ResourceBase] $this).Get() | ||
| } | ||
|
|
||
| # Base method Get() calls this method to get the current state as a Hashtable. | ||
| [System.Collections.Hashtable] GetCurrentState([System.Collections.Hashtable] $properties) | ||
| { | ||
| try | ||
| { | ||
| $null = Install-AdcsOnlineResponder -Credential $this.Credential -WhatIf | ||
|
|
||
| return @{} | ||
| } | ||
| catch | ||
| { | ||
| return @{ | ||
| IsSingleInstance = 'Yes' | ||
| Credential = $this.Credential | ||
| } | ||
| } | ||
| # catch | ||
| # { | ||
| # New-InvalidOperationException -Message $this.localizedData.ErrorGetCurrentState -ErrorRecord $_ | ||
| # } | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [void] Set() | ||
| { | ||
| # Call the base method to enforce the properties. | ||
| ([ResourceBase] $this).Set() | ||
| } | ||
|
|
||
| <# | ||
| Base method Set() call this method with the properties that should be | ||
| enforced and that are not in desired state. | ||
| #> | ||
| hidden [void] Modify([System.Collections.Hashtable] $properties) | ||
| { | ||
| $errorMessage = '' | ||
|
|
||
| if ($properties.ContainsKey('Ensure') -and $properties.Ensure -eq [Ensure]::Absent) | ||
| { | ||
| $errorMessage = (Uninstall-AdcsOnlineResponder -Force).ErrorString | ||
| } | ||
| else | ||
| { | ||
| $errorMessage = (Install-AdcsOnlineResponder -Credential $this.Credential -Force).ErrorString | ||
| } | ||
|
|
||
| if (-not [System.String]::IsNullOrEmpty($errorMessage)) | ||
| { | ||
| New-InvalidOperationException -Message $errorMessage | ||
| } | ||
| } | ||
dan-hughes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [System.Boolean] Test() | ||
| { | ||
| # Call the base method to test all of the properties that should be enforced. | ||
| return ([ResourceBase] $this).Test() | ||
| } | ||
|
|
||
| <# | ||
| Base method Assert() call this method with the properties that was assigned | ||
| a value. | ||
| #> | ||
| hidden [void] AssertProperties([System.Collections.Hashtable] $properties) | ||
| { | ||
| Assert-Module -ModuleName 'ADCSDeployment' | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix inaccurate wording and add required “Requirements” and “Known issues” sections in .DESCRIPTION.
“Certificate Authority” is incorrect here; this resource configures the Online Responder. Also add the required sections per guidelines.
🤖 Prompt for AI Agents