-
Notifications
You must be signed in to change notification settings - Fork 88
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
Trim the line before splitting parts in HostsFile #527
base: main
Are you sure you want to change the base?
Conversation
The build pipeline is failing because the pipeline files haven't been updated in sometime and using a Linux build agent (which fails). I'll update the pipeline to the latest version so that you can rebase. |
@PlagueHO If you point me to an example, I can probably help. |
Updated pipeline files has been merged thanks to @PlagueHO. This PR can be rebased. |
Sorry @cdhunt - the pipeline fix was already waiting for review (#529). But there will be other DSC resource repos that need similar updates... so if you're inclined and have the time, we're always happy to have help doing the chores 😀 I've completed:
PR needs review:
Still need to complete:
@johlju - I'll probably sit down and do some of these tonight. Will raise issues and assign them to myself as I go. |
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #527 +/- ##
===================================
Coverage 97% 97%
===================================
Files 28 28
Lines 2078 2078
===================================
Hits 2028 2028
Misses 50 50
|
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.
Thanks for submitting @cdhunt.
Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @cdhunt)
CHANGELOG.md
line 13 at r2 (raw file):
- Renamed NetworkingDSc to NetworkingDsc in CHANGELOG.md - fixes [Issue #513](https://github.com/dsccommunity/NetworkingDsc/issues/513). - HostsFile - Fix bad return data when line contains leading spaces - fixes [Issue #526](https://github.com/dsccommunity/NetworkingDsc/issues/526)
Nit: end with full stop :D
tests/Unit/DSC_HostsFile.Tests.ps1
line 303 at r2 (raw file):
Context 'When a host entry has leading spaces' {
Nit: can remove blank line :)
tests/Unit/DSC_HostsFile.Tests.ps1
line 324 at r2 (raw file):
(Get-TargetResource @testParams).Ensure | Should -Be 'Present' } }
What would happen if there was whitepace at the beginning of the Hostname parameter passed in the config? Edgecase definitely. E.g.
HostsFile Bad {
HostName = ' whitespace.com'
IPAddress = '192.168.1.1'
}
Would this result in a flapping config? As Get-TargetResource
would return the trimmed value, but the parameter would still have untrimmed whitespace. Maybe add a test to check this?
E.g.
$testParams = @{
HostName = ' www.leadingwhitespace.com'
IPAddress = '127.0.0.1'
Verbose = $true
}
What do you think the desired/expected behavior would be? Should it support intentional whitespace or enforce an exact format? You could use |
@PlagueHO Can you rerun the failed integration test job? |
I helped with that. |
I've added additional tests which I believe cover at least one edge case and better cover the scenario I'm trying to fix. |
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.
Nice! Thank you for adding that integration test.
Reviewed 1 of 3 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @cdhunt)
tests/Unit/DSC_HostsFile.Tests.ps1
line 327 at r4 (raw file):
$testParams = @{ HostName = 'www.contoso.com' IPAddress = '192.168.0.156'
What I was really thinking here, was if you created another unit test where the IPAddress = ' 192.168.0.156'
and the current hosts was:
'# A mocked example of a host file - this line is a comment',
'',
'127.0.0.1 localhost',
'127.0.0.1 www.anotherexample.com',
" 192.168.0.156 $($testParams.HostName)",
'127.0.0.5 anotherexample.com',
''
Would the Test-TargetResource return True?
In theory this should because it's in state.
tests/Unit/DSC_HostsFile.Tests.ps1
line 348 at r4 (raw file):
It 'Should return false from the test method' { Test-TargetResource @testParams | Should -Be $false
Sorry, missed this - can change to Should -BeFalse
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.
Hi @cdhunt - just realised this one is still open. Can you check the last comments and we can merge I think.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @cdhunt)
Pull Request (PR) description
Trim the line before splitting parts in
Get-HostEntry
.This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
and comment-based help.
This change is