Skip to content
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

BREAKING: WSManListener: Convert to a Class Resource #106

Open
wants to merge 51 commits into
base: main
Choose a base branch
from

Conversation

dan-hughes
Copy link
Contributor

@dan-hughes dan-hughes commented Sep 18, 2024

Pull Request (PR) description

Convert WSManListener to a class resource
Rename parameter DN to BaseDN

This Pull Request (PR) fixes the following issues

Contributes to #98
Fixes #89

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 98.43750% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98%. Comparing base (4856433) to head (514c668).

Files with missing lines Patch % Lines
source/Classes/020.WSManListener.ps1 98% 1 Missing ⚠️
source/Private/Find-Certificate.ps1 97% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #106   +/-   ##
===================================
  Coverage    98%    98%           
===================================
  Files         3      7    +4     
  Lines       292    198   -94     
===================================
- Hits        288    196   -92     
+ Misses        4      2    -2     
Files with missing lines Coverage Δ
.../DSCResources/DSC_WSManConfig/DSC_WSManConfig.psm1 100% <ø> (ø)
...DSC_WSManServiceConfig/DSC_WSManServiceConfig.psm1 100% <ø> (ø)
source/Private/Get-DefaultPort.ps1 100% <100%> (ø)
source/Private/Get-Listener.ps1 100% <100%> (ø)
source/prefix.ps1 100% <100%> (ø)
source/Classes/020.WSManListener.ps1 98% <98%> (ø)
source/Private/Find-Certificate.ps1 97% <97%> (ø)

@PlagueHO PlagueHO self-assigned this Oct 26, 2024
@dan-hughes dan-hughes marked this pull request as ready for review November 17, 2024 17:37
@dan-hughes
Copy link
Contributor Author

@PlagueHO, finally ready to go.

@dan-hughes
Copy link
Contributor Author

@johlju, is this something you can also look at please?

@johlju
Copy link
Member

johlju commented Jan 4, 2025

Will do, later in the week or weekend. 😊

@johlju johlju requested a review from PlagueHO January 12, 2025 09:18
Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 15 of 28 files at r1, 19 of 20 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dan-hughes and @PlagueHO)


source/Classes/020.WSManListener.ps1 line 232 at r3 (raw file):

                'Issuer'
                'BaseDN'
            )

Shouldn't there also be SubjectFormat and MatchAlternate in this list, they should also not be used when thumbprint or hostname is specified?

Code quote:

            MutuallyExclusiveList1 = @(
                'Issuer'
                'BaseDN'
            )

source/Classes/020.WSManListener.ps1 line 249 at r3 (raw file):

            Transport = $this.Transport
            Address   = $this.Address
        }

In this method we need to validate all properties needed to create an instance actually has a value. We cannot do it in AssertProperties() as that would prevent as enforcing only a specific property. 🤔

Code quote:

        $selectorSet = @{
            Transport = $this.Transport
            Address   = $this.Address
        }

source/Classes/020.WSManListener.ps1 line 269 at r3 (raw file):

                if ([System.String]::IsNullOrEmpty($this.Hostname))
                {
                    $valueSet.HostName = [System.Net.Dns]::GetHostByName($env:COMPUTERNAME).Hostname

Suggest to use Get-ComputerName here instead (from DscResource.Common)

Code quote:

$env:COMPUTERNAME

source/Classes/020.WSManListener.ps1 line 288 at r3 (raw file):

    }

    hidden [void] RemoveInstance()

Do we need to validate here as well, that the required properties to remove an instance is actually set? 🤔

Code quote:

RemoveInstance()

source/Private/Find-Certificate.ps1 line 24 at r3 (raw file):

        The Thumbprint of the certificate to use for the HTTPS WS-Man Listener.
#>
function Find-Certificate

We also have a Find-Certificate in CertificateDsc - it might be possible to concat these inte one public function in DscResource.Common. 🤔 But out of scope for this PR.

Code quote:

Find-Certificate

@johlju
Copy link
Member

johlju commented Jan 12, 2025

Justa few comments. Heads up, there might be some issues with PowerShell Gallery - i trying to release a version before merging this breaking change, but it fails with random errors (re-run 3 times, failing on different module name each time): https://dev.azure.com/dsccommunity/WsManDsc/_build/results?buildId=9921&view=logs&j=d7ffe41d-f206-59ed-99c3-e44ba5bb1f40&t=e2ebcab5-cb94-5995-9070-3fa60620c9c4

@johlju johlju added the waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. label Jan 12, 2025
Copy link
Contributor Author

@dan-hughes dan-hughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @johlju and @PlagueHO)


source/Classes/020.WSManListener.ps1 line 232 at r3 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Shouldn't there also be SubjectFormat and MatchAlternate in this list, they should also not be used when thumbprint or hostname is specified?

I believe you are correct.


source/Classes/020.WSManListener.ps1 line 249 at r3 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

In this method we need to validate all properties needed to create an instance actually has a value. We cannot do it in AssertProperties() as that would prevent as enforcing only a specific property. 🤔

I don't believe so, if the port is not supplied, then it is populated with Get-DefaultPort in Get().GetCurrentState().


source/Classes/020.WSManListener.ps1 line 269 at r3 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Suggest to use Get-ComputerName here instead (from DscResource.Common)

Done.


source/Classes/020.WSManListener.ps1 line 288 at r3 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Do we need to validate here as well, that the required properties to remove an instance is actually set? 🤔

Same as the port above. Using DscResource.Base calling Set() calls Get() which calls GetCurrentState() which resolves those properties if not set or supplied.

I also specifically did not touch the integration tests to remove the moving parts.


source/Private/Find-Certificate.ps1 line 24 at r3 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

We also have a Find-Certificate in CertificateDsc - it might be possible to concat these inte one public function in DscResource.Common. 🤔 But out of scope for this PR.

I'll create issues in the three repos for these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WSManListener parameter DN should be BaseDN
3 participants