Skip to content

DnsClientNrptGlobal-DnsClientNrptRule: New resources #533

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

Merged
merged 36 commits into from
Apr 14, 2025

Conversation

webalexeu
Copy link
Contributor

@webalexeu webalexeu commented Mar 10, 2025

Pull Request (PR) description

This PR is to add 2 new resources DnsClientNrptGlobal & DnsClientNrptRule to manage NRPT
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn593632(v=ws.11)

This Pull Request (PR) fixes the following issues

Task list

  • Rules are identified by rule Name but Name is not a property supported by the create cmdlet. As workaround, the rule name is set by renaming the registry key. Can you please advise on this ?
  • 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

@webalexeu webalexeu marked this pull request as ready for review March 11, 2025 15:58
@johlju johlju requested a review from PlagueHO March 15, 2025 21:04
@johlju johlju added the needs review The pull request needs a code review. label Mar 15, 2025
@PlagueHO
Copy link
Member

Hi @webalexeu - thanks for submitting this. I'm away travelling but will attempt to review over the next few days.

Regarding the question about setting the rule names:
I see: so Add-DnsClientNrptRule doesn't support a name parameter and by default adds new rules using a GUID. The Set-DnsClientNrptRule doesn't support renaming and there is no rename* cmdlet.

I don't see any other work around here either unfortunately.

My only concern is that the reason that the name parameter is not supported is that it must be a GUID and changing it to another string breaks something somewhere (e.g., some code in Windows Networking always tries to cast this to GUID) - but this isn't likely as surely the prop would then be called id or guid (I'd hope).

So, I suggest go with what you've done and if we encounter problems then we can rethink and implement a breaking change.

Any other community members, please comment.

Also, I notice the pipelines are currently failing:
I think this is because recent build tool updates might require an empty file prefix.ps1 to be in the root of the source folder. I could be wrong though (@johlju )?

@johlju
Copy link
Member

johlju commented Mar 16, 2025

@PlagueHO the pipeline is being fixed in PR #532 as @dan-hughes reminded me yesterday in Discord. 🙂 I will review that today so this one can run the pipeline.

@johlju
Copy link
Member

johlju commented Mar 16, 2025

I merged the PR that converted the tests to Pester 5, so the tests in this PR need to be converted to. Suggest looking at the other tests and use them as a template. Thank you.

@webalexeu
Copy link
Contributor Author

Hi @webalexeu - thanks for submitting this. I'm away travelling but will attempt to review over the next few days.

Regarding the question about setting the rule names:
I see: so Add-DnsClientNrptRule doesn't support a name parameter and by default adds new rules using a GUID. The Set-DnsClientNrptRule doesn't support renaming and there is no rename* cmdlet.

I don't see any other work around here either unfortunately.

My only concern is that the reason that the name parameter is not supported is that it must be a GUID and changing it to another string breaks something somewhere (e.g., some code in Windows Networking always tries to cast this to GUID) - but this isn't likely as surely the prop would then be called id or guid (I'd hope).

So, I suggest go with what you've done and if we encounter problems then we can rethink and implement a breaking change.

Any other community members, please comment.

Also, I notice the pipelines are currently failing:
I think this is because recent build tool updates might require an empty file prefix.ps1 to be in the root of the source folder. I could be wrong though (@johlju )?

Thanks for your feedback. So far I didn't find any awkward behavior with the renaming but that's indeed a concern. I think it's more problematic when it's managed by GPO because there is a link made over there but it's not our case here

@webalexeu
Copy link
Contributor Author

webalexeu commented Mar 16, 2025

I merged the PR that converted the tests to Pester 5, so the tests in this PR need to be converted to. Suggest looking at the other tests and use them as a template. Thank you.

Thank you. I will update my PR with updated tests accordingly

@PlagueHO
Copy link
Member

Thank you @webalexeu and @johlju - let me know and I'll contunue the review

Copy link

codecov bot commented Mar 17, 2025

Codecov Report

Attention: Patch coverage is 97.40260% with 4 lines in your changes missing coverage. Please review.

Project coverage is 97%. Comparing base (c165bcc) to head (951dcaf).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 96% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #533    +/-   ##
====================================
- Coverage    97%    97%    -1%     
====================================
  Files        27     29     +2     
  Lines      1886   2040   +154     
====================================
+ Hits       1846   1996   +150     
- Misses       40     44     +4     
Files with missing lines Coverage Δ
...C_DnsClientNrptGlobal/DSC_DnsClientNrptGlobal.psm1 100% <100%> (ø)
...s/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 96% <96%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@webalexeu
Copy link
Contributor Author

Thank you @webalexeu and @johlju - let me know and I'll contunue the review

@PlagueHO Tests have been updated, you can proceed with the review

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

Thanks @webalexeu - I have completed first part of review (I only had an hour, so didn't have time to get through the NRPT rules and tests yet). But nothing but a few minor nit's in NRPT global. I'll complete tonight (hopefully).

Reviewed 6 of 22 files at r1, 1 of 2 files at r2, 2 of 9 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: 10 of 22 files reviewed, 6 unresolved discussions


CHANGELOG.md line 11 at r5 (raw file):

- Added the following resources:
  - **DnsClientNrptGlobal**: Configure the global Name Resolution Policy Table (NRPT) settings.

Nit: can you include DNS Client in the description of this new resource as well? And same for DnsClientNrptRule.


source/Examples/Resources/DnsClientNrptGlobal/1-DnsClientNrptGlobal_Config.ps1 line 22 at r5 (raw file):

<#
    .DESCRIPTION
    Configure the NRPT global configuration.

For clarity (as this gets published to PSGallery as a script) can you also define the settings that are set (e.g. Disable DA for all Networks, Disable NRPT query policy etc)


source/DSCResources/DSC_DnsClientNrptGlobal/DSC_DnsClientNrptGlobal.psm1 line 93 at r5 (raw file):

        [Parameter()]
        [ValidateSet("EnableOnNetworkID", "EnableAlways", "Disable", "DisableDA")]

[Nit: Can change to single quotes around strings.](Nit: Can change to single quotes around ValidateSet strings - and throughout.)


source/DSCResources/DSC_DnsClientNrptGlobal/DSC_DnsClientNrptGlobal.psm1 line 99 at r5 (raw file):

        [Parameter()]
        [System.String]
        [ValidateSet("Disable", "QueryIPv6Only", "QueryBoth")]

[Nit: Can change to single quotes around strings.](Nit: Can change to single quotes around ValidateSet strings - and throughout.)


source/DSCResources/DSC_DnsClientNrptGlobal/DSC_DnsClientNrptGlobal.psm1 line 104 at r5 (raw file):

        [Parameter()]
        [System.String]
        [ValidateSet("Disable", "FallbackSecure", "FallbackUnsecure", "FallbackPrivate")]

Nit: Can change to single quotes around ValidateSet strings - and throughout.


README.md line 35 at r5 (raw file):

- **DefaultGatewayAddress**: Sets a node's default gateway address.
- **DnsClientGlobalSetting**: Configure DNS client global settings.
- **DnsClientNrptGlobal**: Configure the global Name Resolution Policy Table (NRPT) settings.

Nit: can you include DNS Client in the description of this new resource as well? And same for DnsClientNrptRule.

Copy link
Contributor Author

@webalexeu webalexeu left a comment

Choose a reason for hiding this comment

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

Updated in last commit
Thanks for the review

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

Thanks @webalexeu - can you use Reviewable and mark any corrections as done? I'll continue the review as soon as I'm able (as I'm travelling at the moment).

Reviewable status: 6 of 22 files reviewed, 6 unresolved discussions (waiting on @webalexeu)

Copy link
Contributor Author

@webalexeu webalexeu 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: 6 of 22 files reviewed, 3 unresolved discussions (waiting on @PlagueHO)


source/DSCResources/DSC_DnsClientNrptGlobal/DSC_DnsClientNrptGlobal.psm1 line 93 at r5 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

[Nit: Can change to single quotes around strings.](Nit: Can change to single quotes around ValidateSet strings - and throughout.)

Done.


source/Examples/Resources/DnsClientNrptGlobal/1-DnsClientNrptGlobal_Config.ps1 line 22 at r5 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

For clarity (as this gets published to PSGallery as a script) can you also define the settings that are set (e.g. Disable DA for all Networks, Disable NRPT query policy etc)

Done.

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

I've done a bit more work on the review (jsut a couple of files left to go), but run out of time again.

Reviewed 3 of 22 files at r1, 1 of 2 files at r2, 3 of 9 files at r4, 7 of 7 files at r6, all commit messages.
Reviewable status: 20 of 22 files reviewed, 21 unresolved discussions (waiting on @webalexeu)


source/Examples/Resources/DnsClientNrptGlobal/1-DnsClientNrptGlobal_Config.ps1 line 22 at r5 (raw file):

Previously, webalexeu (Alexandre JARDON) wrote…

Done.

Ah, what I meant was in the .DESCRIPTION, include details about what the example config actually sets (it just improves the searchability of the example). Also nit, DNS should be all caps.

E.g.

Configure DNS Client NRPT global configuration and set DirectAccess to 'EnableAlways', QueryPolicy to 'QueryBoth'... etc

source/Examples/Resources/DnsClientNrptRule/2-DnsClientNrptRule_DNSSEC_Config.ps1 line 22 at r6 (raw file):

<#
    .DESCRIPTION
        Sets a Dns Client NRPT rule to enable DNSSEC queries for a specific namespace.

Nit: All caps for DNS


source/Examples/Resources/DnsClientNrptRule/2-DnsClientNrptRule_DNSSEC_Config.ps1 line 23 at r6 (raw file):

    .DESCRIPTION
        Sets a Dns Client NRPT rule to enable DNSSEC queries for a specific namespace.
    .PARAMETER Name

These params not needed (or should be added to param() block)


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.schema.mof line 4 at r6 (raw file):

class DSC_DnsClientNrptRule : OMI_BaseResource
{
    [Key, Description("Specifies the NRPT rule name.")] string Name;

Can you add DNS Client to the description (e.g., Specifies the DNS Client NRPT rule name) (for searchability).

And throughout the resource files?


source/DSCResources/DSC_DnsClientNrptRule/README.MD line 3 at r6 (raw file):

# Description

This resource is used to control NRPT rules for a node.

Can you add DNS Client to the description?


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 15 at r6 (raw file):

<#
    .SYNOPSIS
        Returns the current state of a NRPT Rule.

Nit: include DNS Client in the synopsis.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 55 at r6 (raw file):

        $returnValue += @{
            Ensure                    = 'Present'
            Comment                   = [System.String] $NrptRule.Comment

Is the explicit casting on each of these required? I suspect it might not be needed (I could be wrong though).


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 189 at r6 (raw file):

        [System.String]
        $DAProxyType,
    

Nit: can remove whitespace.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 265 at r6 (raw file):

            # Remove Name parameter as Add-DnsClientNrptRule cmdlet doesn't support it
            $null = $PSBoundParameters.Remove("Name")
            # The NrptRule does not exit - create it (PassThru to get the name of the rule created)

Can you implement a new function Add-NrptRule that also does the registry key update to set the name?

This should make it more testable.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 269 at r6 (raw file):

            -PassThru `
            -ErrorAction Stop).Name
            

Nit: Can remove whitespace?


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 271 at r6 (raw file):

            
            # If rule has been created, rename it by registry as Name cannot be provided in Add-DnsClientNrptRule cmdlet
            if ($NrptRuleName -match "^\{[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}\}$")

It looks like this is validating if the NrptRuleName is a Regex - in which case, you might be able to use [Guid]::Parse($NrptRuleName) and move it into a function Test-IsGuid - this is just to improve readability and maintainability.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 274 at r6 (raw file):

            {
                # Rename the registry key
                Rename-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DnsPolicyConfig\$($NrptRuleName)" -NewName $Name

Could we move this registry string into a $script scope variable at the beginning of the file?


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 276 at r6 (raw file):

                Rename-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DnsPolicyConfig\$($NrptRuleName)" -NewName $Name
            }
                

Nit: Can remove whitespace?


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 524 at r6 (raw file):

<#
    .SYNOPSIS
        This function looks up NRPT Rule using the parameters and returns

nit: Could clarify that this function looks up the NRPT rule using the name parameter (to be more specific).


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 542 at r6 (raw file):

    try
    {
        $NrptRule = Get-DnsClientNrptRule `

Local vars should start with lower case. Can you change this to lower case $nrptRule


source/Examples/Resources/DnsClientNrptRule/3-DnsClientNrptRule_Punycode_Config.ps1 line 22 at r6 (raw file):

<#
    .DESCRIPTION
        Sets a Dns Client NRPT rule to send Punycode DNS queries using a conditional dns forwarder for a specific namespace.

Nit: All caps for DNS


source/Examples/Resources/DnsClientNrptRule/3-DnsClientNrptRule_Punycode_Config.ps1 line 23 at r6 (raw file):

    .DESCRIPTION
        Sets a Dns Client NRPT rule to send Punycode DNS queries using a conditional dns forwarder for a specific namespace.
    .PARAMETER Name

These params not needed (or should be added to param() block)


source/Examples/Resources/DnsClientNrptRule/1-DnsClientNrptRule_Server_Config.ps1 line 22 at r6 (raw file):

<#
    .DESCRIPTION
        Sets a Dns Client NRPT rule to configure a conditional dns forwarder for a specific namespace.

Nit: All caps for DNS


source/Examples/Resources/DnsClientNrptRule/1-DnsClientNrptRule_Server_Config.ps1 line 23 at r6 (raw file):

    .DESCRIPTION
        Sets a Dns Client NRPT rule to configure a conditional dns forwarder for a specific namespace.
    .PARAMETER Name

These params not needed (or should be added to param() block)


source/Examples/Resources/DnsClientNrptGlobal/1-DnsClientNrptGlobal_Config.ps1 line 23 at r6 (raw file):

    .DESCRIPTION
        Configure Dns Client NRPT global configuration.
    .PARAMETER EnableDAForAllNetworks

These parameters can be used for the example, but would require being added to the param() block. But we don't typically bother with this (see SqlServerDsc/source/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 at main · dsccommunity/SqlServerDsc)


source/DSCResources/DSC_DnsClientNrptRule/en-US/DSC_DnsClientNrptRule.strings.psd1 line 4 at r6 (raw file):

ConvertFrom-StringData @'
    GettingNrptRuleMessage = Getting '{0}' NRPT rule.

Can you add DNS Client to these strings as well?

Copy link
Contributor Author

@webalexeu webalexeu 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: 10 of 22 files reviewed, 13 unresolved discussions (waiting on @PlagueHO)


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 55 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Is the explicit casting on each of these required? I suspect it might not be needed (I could be wrong though).

I was thinking it is better to do it. I took example on other resources doing the same. Let me know what is the best path to follow


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 265 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you implement a new function Add-NrptRule that also does the registry key update to set the name?

This should make it more testable.

Done.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 271 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

It looks like this is validating if the NrptRuleName is a Regex - in which case, you might be able to use [Guid]::Parse($NrptRuleName) and move it into a function Test-IsGuid - this is just to improve readability and maintainability.

Done.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 274 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Could we move this registry string into a $script scope variable at the beginning of the file?

Done.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 542 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Local vars should start with lower case. Can you change this to lower case $nrptRule

Done.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.schema.mof line 4 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you add DNS Client to the description (e.g., Specifies the DNS Client NRPT rule name) (for searchability).

And throughout the resource files?

Done.


source/DSCResources/DSC_DnsClientNrptRule/README.MD line 3 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you add DNS Client to the description?

Done.


source/DSCResources/DSC_DnsClientNrptRule/en-US/DSC_DnsClientNrptRule.strings.psd1 line 4 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you add DNS Client to these strings as well?

Done.


source/Examples/Resources/DnsClientNrptGlobal/1-DnsClientNrptGlobal_Config.ps1 line 22 at r5 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Ah, what I meant was in the .DESCRIPTION, include details about what the example config actually sets (it just improves the searchability of the example). Also nit, DNS should be all caps.

E.g.

Configure DNS Client NRPT global configuration and set DirectAccess to 'EnableAlways', QueryPolicy to 'QueryBoth'... etc

Done.


source/Examples/Resources/DnsClientNrptGlobal/1-DnsClientNrptGlobal_Config.ps1 line 23 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

These parameters can be used for the example, but would require being added to the param() block. But we don't typically bother with this (see SqlServerDsc/source/Examples/Resources/SqlDatabase/1-CreateDatabase.ps1 at main · dsccommunity/SqlServerDsc)

Done.


source/Examples/Resources/DnsClientNrptRule/1-DnsClientNrptRule_Server_Config.ps1 line 23 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

These params not needed (or should be added to param() block)

Done.


source/Examples/Resources/DnsClientNrptRule/2-DnsClientNrptRule_DNSSEC_Config.ps1 line 23 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

These params not needed (or should be added to param() block)

Done.


source/Examples/Resources/DnsClientNrptRule/3-DnsClientNrptRule_Punycode_Config.ps1 line 23 at r6 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

These params not needed (or should be added to param() block)

Done.

Copy link
Contributor Author

@webalexeu webalexeu left a comment

Choose a reason for hiding this comment

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

Changes has been performed as requested

Reviewable status: 10 of 22 files reviewed, 13 unresolved discussions (waiting on @PlagueHO)

Copy link
Contributor Author

@webalexeu webalexeu left a comment

Choose a reason for hiding this comment

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

All comments have been addressed

@webalexeu webalexeu requested a review from PlagueHO March 26, 2025 13:14
@PlagueHO
Copy link
Member

Hi @webalexeu - not sure why the NetBios integration tests have started failing now. I'm still in transit, so will try and find out when I have some more time.

Copy link
Contributor Author

@webalexeu webalexeu left a comment

Choose a reason for hiding this comment

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

Hello @PlagueHO ,
I see that thests are green now
Thank you for your time

Reviewable status: 10 of 22 files reviewed, 13 unresolved discussions (waiting on @PlagueHO)

@webalexeu
Copy link
Contributor Author

Hello @PlagueHO ?
Do you think you will have some time to have a look?
Thank you again for your time

@PlagueHO
Copy link
Member

PlagueHO commented Apr 4, 2025

Hi @webalexeu, I'm in transit at the moment but back on the ground in 24 hours. Will try to finish Sunday (NZT) depending on jetlag. Sorry for delay

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 4 files at r3, 9 of 10 files at r7, 1 of 1 files at r8, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @webalexeu)


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 55 at r6 (raw file):

Previously, webalexeu (Alexandre JARDON) wrote…

I was thinking it is better to do it. I took example on other resources doing the same. Let me know what is the best path to follow

Ah right - I used to implement it this way (with explicit cast). But stopped for more recent resources. Happy to leave it.


tests/Unit/DSC_DnsClientNrptGlobal.Tests.ps1 line 99 at r8 (raw file):

    }

    Context 'DNS Client NRPT Global Settings all parameters are the same' {

nit non-blocking: FYI, could reduce test code duplication by using an array of parameters and looping through them. But happy to leave as-is.


tests/Unit/DSC_DnsClientNrptRule.Tests.ps1 line 124 at r8 (raw file):

}

Describe 'DSC_DnsClientNrptRule\Set-TargetResource' -Tag 'Set' {

The unit tests are only validating that the Set works for Namespace and NameServers parameters - not all the parameters - we should test all the parameters can be set (and tested). One way to reduce the amount of code required to implement this is to use an array/foreach over the array (e.g. NetworkingDsc/tests/Unit/DSC_Firewall.Tests.ps1 at main · dsccommunity/NetworkingDsc)


tests/Unit/DSC_DnsClientNrptRule.Tests.ps1 line 149 at r8 (raw file):

        }
    }
    Context 'NRPT Rule does not exist but should' {

Add blank line before


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 552 at r8 (raw file):

<#
    .SYNOPSIS
        This function create a DNS Client NRPT Rule using the parameters

Can you also include a note on why this function exists (e.g., because the built-in function doesn't support setting a name).

Suggestion:

This function creates a DNS Client NRPT Rule.

source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 689 at r8 (raw file):

    # The NrptRule does not exit - create it (PassThru to get the name of the rule created)
    $NrptRuleName=(Add-DnsClientNrptRule @PSBoundParameters -PassThru).Name

Can you put spaces around the =

Suggestion:

$NrptRuleName = (Add-DnsClientNrptRule @PSBoundParameters -PassThru).Name

source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 716 at r8 (raw file):

        $InputValue
    )
    try 

nit: can trim this line?

Copy link
Contributor Author

@webalexeu webalexeu left a comment

Choose a reason for hiding this comment

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

Partially corrected. Still need to review the testing part

Reviewable status: 19 of 22 files reviewed, 5 unresolved discussions (waiting on @PlagueHO)


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 552 at r8 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you also include a note on why this function exists (e.g., because the built-in function doesn't support setting a name).

Done.


source/DSCResources/DSC_DnsClientNrptRule/DSC_DnsClientNrptRule.psm1 line 689 at r8 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you put spaces around the =

Done.


tests/Unit/DSC_DnsClientNrptRule.Tests.ps1 line 149 at r8 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Add blank line before

Done.

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

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

:lgtm:

Thank you again for this contribution!

Reviewed 3 of 3 files at r9, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @webalexeu)

Copy link
Member

@PlagueHO PlagueHO 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @webalexeu)

@PlagueHO PlagueHO merged commit 3cacd0c into dsccommunity:main Apr 14, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review The pull request needs a code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Resource] DNSClientNRPTRule
3 participants