-
Notifications
You must be signed in to change notification settings - Fork 134
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
xDSCWebservice: FIX Firewall Exception #614
Conversation
@mhendric can you give a hint why this meta test is failing??? I already rebased my branch to at <ScriptBlock>, C:\projects\xpsdesiredstateconfiguration\DscResource.Tests\Meta.Tests.ps1: line 499
499: $requiredPssaRulesOutput | Should -Be $null Strangely enough the test is passed with my other PR #613 |
It looks like it failed because the new function you added, Test-PullServerFirewallConfiguration, returns a type of Boolean, but does not have an OutputType specified in the param header.
|
@mhendric thanks for the quick answer! I added the OutputType declaration. One additional question: I execute the defined Unit tests for xDSCWebService like so: Invoke-Pester .\Tests\Unit\MSFT_xDSCWebService.Tests.ps1 How do I execute the meta test, so that I won't push PRs that don't adhere to the defined coding rules in the future? |
I think you just call DscResource.Tests\Meta.Tests.ps1. |
Codecov Report
@@ Coverage Diff @@
## dev #614 +/- ##
===================================
- Coverage 73% 73% -1%
===================================
Files 27 28 +1
Lines 4132 4164 +32
Branches 4 5 +1
===================================
+ Hits 3043 3066 +23
- Misses 1085 1093 +8
- Partials 4 5 +1 |
…firewall code will now honor more than one port binding
…rces\MSFT_xDSCWebService\MSFT_xDSCWebService.psm1
…Integration.tests.ps1
…tegration.tests.ps1
…ts\Integration\MSFT_xDSCWebService.Integration.tests.ps1
… while removing a pullserver instance. Adjusted the unit tests accordingly
Hi @tmeckel , I can review this one for you. However, can you try to get a clean build through first? I'd like to see if the Unit and Integration tests are passing too. Looks like this is failing on Meta tests again (mostly due to lines longer than 80 chars, or trailing whitespace in README.MD). 1879 |
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.
Reviewed 8 of 14 files at r1.
Reviewable status: 8 of 14 files reviewed, 17 unresolved discussions (waiting on @tmeckel)
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 2 at r1 (raw file):
$script:FireWallRuleDisplayName
Variable name should use camel case: https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#variable-names-use-camel-case
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 8 at r1 (raw file):
.PARAMETER firewallPort
Parameter name doesn't match actual parameter. Throughout file.
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 22 at r1 (raw file):
$script:netsh = "$env:windir\system32\netsh.exe"
Can this be moved outside of a Function, to the script itself, so you don't have to keep re-declaring it?
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 27 at r1 (raw file):
# remove all existing rules with that displayName
First comment character should be capitalized
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 31 at r1 (raw file):
& $script:netsh advfirewall firewall add rule name=DSCPullServer_IIS_Port dir=in action=allow protocol=TCP localport=$Port | Out-Null
@PlagueHO may ask you to assign the results of this to a $null variable rather than piping to | Out-Null. I personally don't care though :).
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 65 at r1 (raw file):
Where-Object DisplayName -eq "$ruleName"
Need a FilterScript and ScriptBlock in here.
DSCResources/MSFT_xDSCWebService/MSFT_xDSCWebService.psm1, line 2 at r1 (raw file):
Import-Module -Name (Join-Path $PSScriptRoot 'PSWSIISEndpoint.psm1') -Verbose:$false Import-Module -Name (Join-Path $PSScriptRoot 'UseSecurityBestPractices.psm1') -Verbose:$false Import-Module -NAme (Join-Path $PSScriptRoot 'Firewall.psm1') -Verbose:$false
Need Named Parameters on these Join-Path's (Path, ChildPath). Also, -NAme in the last one has bad casing.
DSCResources/MSFT_xDSCWebService/MSFT_xDSCWebService.psm1, line 378 at r1 (raw file):
| ForEach-Object {
Need a Named Parameter here (-Process?)
DSCResources/MSFT_xDSCWebService/MSFT_xDSCWebService.psm1, line 386 at r1 (raw file):
ForEach-Object { Remove-PullServerFirewallConfiguration -Port $_ }
Needs Named Parameter
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 14 at r1 (raw file):
Import-Module -Name WebAdministration -ErrorAction:Stop -Force
What do you think about testing for the Windows Feature that would install this module, and installing it if it's missing? You could use the Install-WindowsFeatureAndVerify test helper function.
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 121 at r1 (raw file):
("Should exist a WebSite called $WebsiteName")
I don't think any of these It labels need to be in parenthesis...
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 128 at r1 (raw file):
$website.state
Should .state be capitalized?
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 168 at r1 (raw file):
$cnt
Can you make this a little more descriptive? Like $expectedRuleCount or something?
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 467 at r1 (raw file):
function Stop-Website {}
Looks like you have one too many line breaks here.
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 1016 at r1 (raw file):
Quoted 4 lines of code…
function Get-Website {} function Get-WebBinding {} function Stop-Website {}
Probably don't need a line break in the middle of these.
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 1037 at r1 (raw file):
Quoted 4 lines of code…
function Get-Website {} function Get-WebBinding {} function Stop-Website {}
Probably don't need a line break in the middle of these.
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 1089 at r1 (raw file):
Quoted 4 lines of code…
function Get-Website {} function Get-WebBinding {} function Stop-Website {}
Probably don't need a line break in the middle of these... throughout file
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.
Fixed the meta tests.
Reviewable status: 8 of 14 files reviewed, 17 unresolved discussions (waiting on @mhendric)
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 2 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
$script:FireWallRuleDisplayName
Variable name should use camel case: https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#variable-names-use-camel-case
Done.
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 8 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
.PARAMETER firewallPort
Parameter name doesn't match actual parameter. Throughout file.
Done.
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 22 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
$script:netsh = "$env:windir\system32\netsh.exe"
Can this be moved outside of a Function, to the script itself, so you don't have to keep re-declaring it?
Moved it to a script global definition:
New-Variable -Name netsh -Value "$env:windir\system32\netsh.exe" -Option ReadOnly -Scope Script -Force
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 27 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
# remove all existing rules with that displayName
First comment character should be capitalized
Done.
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 31 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
& $script:netsh advfirewall firewall add rule name=DSCPullServer_IIS_Port dir=in action=allow protocol=TCP localport=$Port | Out-Null
@PlagueHO may ask you to assign the results of this to a $null variable rather than piping to | Out-Null. I personally don't care though :).
Using the famous $null
assignment now :-D
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 65 at r1 (raw file):
DisplayName -eq "$ruleName"
According to the Powershell Cmdlet manual this is perfectly valid because this will spare you to use the dot-notation with the current pipeline object$_.DisplayName
DSCResources/MSFT_xDSCWebService/MSFT_xDSCWebService.psm1, line 2 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
Import-Module -Name (Join-Path $PSScriptRoot 'PSWSIISEndpoint.psm1') -Verbose:$false Import-Module -Name (Join-Path $PSScriptRoot 'UseSecurityBestPractices.psm1') -Verbose:$false Import-Module -NAme (Join-Path $PSScriptRoot 'Firewall.psm1') -Verbose:$false
Need Named Parameters on these Join-Path's (Path, ChildPath). Also, -NAme in the last one has bad casing.
Done.
DSCResources/MSFT_xDSCWebService/MSFT_xDSCWebService.psm1, line 378 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
| ForEach-Object {
Need a Named Parameter here (-Process?)
Done.
DSCResources/MSFT_xDSCWebService/MSFT_xDSCWebService.psm1, line 386 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
ForEach-Object { Remove-PullServerFirewallConfiguration -Port $_ }
Needs Named Parameter
Done.
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 14 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
Import-Module -Name WebAdministration -ErrorAction:Stop -Force
What do you think about testing for the Windows Feature that would install this module, and installing it if it's missing? You could use the Install-WindowsFeatureAndVerify test helper function.
Great idea. Added the following
if (-not (Install-WindowsFeatureAndVerify -Name Web-Mgmt-Tools))
{
Write-Error -Message 'Failed to verify for required Windows Feature. Unable to continue ...' -ErrorAction:Stop
}
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 121 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
("Should exist a WebSite called $WebsiteName")
I don't think any of these It labels need to be in parenthesis...
I adopted this from the Meta.Tests.ps1 and thus I thought it's a good idea :-D
It ('Markdown file ''{0}'' should not have Byte Order Mark (BOM)' -f $filePathOutputName) {
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 128 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
$website.state
Should .state be capitalized?
Surprinsingly not. The properties of a website object are lowercase even not camel cased.
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 168 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
$cnt
Can you make this a little more descriptive? Like $expectedRuleCount or something?
Renamed this to $expectedRuleCount
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 467 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
function Stop-Website {}
Looks like you have one too many line breaks here.
Done.
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 1016 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
function Get-Website {} function Get-WebBinding {} function Stop-Website {}
Probably don't need a line break in the middle of these.
Done.
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 1037 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
function Get-Website {} function Get-WebBinding {} function Stop-Website {}
Probably don't need a line break in the middle of these.
Done.
Tests/Unit/MSFT_xDSCWebService.Tests.ps1, line 1089 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
function Get-Website {} function Get-WebBinding {} function Stop-Website {}
Probably don't need a line break in the middle of these... throughout file
Done.
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.
Reviewable status: 8 of 14 files reviewed, 17 unresolved discussions (waiting on @mhendric)
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 121 at r1 (raw file):
Previously, tmeckel (Thomas Meckel) wrote…
I adopted this from the Meta.Tests.ps1 and thus I thought it's a good idea :-D
It ('Markdown file ''{0}'' should not have Byte Order Mark (BOM)' -f $filePathOutputName) {
Okay I've to admit in this example the parenthesis are required because they use the -f (Format) operator and not inline string variable expansion. So yeah perhaps you're right that the parenthesis aren't required in my case.
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.
Hey @tmeckel, sorry for taking so long on this review. It's been a busy last couple weeks.
Reviewable status: 8 of 14 files reviewed, 5 unresolved discussions (waiting on @mhendric and @tmeckel)
CHANGELOG.md, line 19 at r2 (raw file):
[issue #536]
Can you make this a full URL like in the entry directly above, and also put it at the end of the entry instead of mid entry?
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 27 at r1 (raw file):
Previously, tmeckel (Thomas Meckel) wrote…
Done.
This doesn't appear to be done.
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 31 at r1 (raw file):
Previously, tmeckel (Thomas Meckel) wrote…
Using the famous
$null
assignment now :-D
This doesn't appear to be done.
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 65 at r1 (raw file):
Previously, tmeckel (Thomas Meckel) wrote…
DisplayName -eq "$ruleName"
According to the Powershell Cmdlet manual this is perfectly valid because this will spare you to use the dot-notation with the current pipeline object$_.DisplayName
Yeah, it's absolutely valid syntax. I just don't think it aligns with the DSC style guidelines, which suggest using named parameters. What do you think?
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 168 at r1 (raw file):
Previously, tmeckel (Thomas Meckel) wrote…
Renamed this to
$expectedRuleCount
Thanks. Looks like you have an extra, unnecessary space before the = signs in assignments to this variable though. Can you correct those?
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.
No problem ... we all have important things to do aside this project here!
Reviewable status: 7 of 14 files reviewed, 5 unresolved discussions (waiting on @mhendric)
CHANGELOG.md, line 19 at r2 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
[issue #536]
Can you make this a full URL like in the entry directly above, and also put it at the end of the entry instead of mid entry?
Done.
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 27 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
This doesn't appear to be done.
Finally :-D
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 31 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
This doesn't appear to be done.
Obviously not ... but now ...
DSCResources/MSFT_xDSCWebService/Firewall.psm1, line 65 at r1 (raw file):
Obviously not ... but now ...
I added the required parameters, whereas I've to admit that this is much too verbose for me. But this is my personal taste. If the style guide demands it ... here we go.
Tests/Integration/MSFT_xDSCWebService.Integration.tests.ps1, line 168 at r1 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
Thanks. Looks like you have an extra, unnecessary space before the = signs in assignments to this variable though. Can you correct those?
Done.
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.
Reviewed 3 of 6 files at r2, 4 of 4 files at r3.
Reviewable status: complete! all files reviewed, all discussions resolved
Hey @tmeckel , this all looks good to me. Just to confirm, are you done working on this? If so I'll get this merged. |
Hey @mhendric thanks for the review! Highly appreciated. I'm done working on this, so go ahead with the merge. When you've done with it I can rebase my other PR #613 and prepare it for review as well. |
xDscWebService: FIX The IIS apppool account and credentials cannot be set and fixing some bugs from PR #614
Pull Request (PR) description
This PR contains a fix for issue #536 where a (unwanted) firewall exception is automatically created during the deployment of a Pull Server.
This Pull Request (PR) fixes the following issues
Task list
This PR is currently marked as draft because work isn't finished yet. The following task list will be updated.
CHANGELOG.md. Entry should say what was changed, and how that affects
users (if applicable).
and comment-based help.
appropriate.
DSC Resource Testing Guidelines.
DSC Resource Testing Guidelines.
DSC Resource Style Guidelines and Best Practices
This change is