-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add UNC Path support to WebVirtualDirectory #634
base: main
Are you sure you want to change the base?
Conversation
If the This also means that there is no way to use this to clear credentials. I couldn't think of a clean way to implement this (without breaking backwards compatibility) but I am very welcome to suggestions. |
cd8ec77
to
eb4ee04
Compare
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
Show resolved
Hide resolved
0561556
to
8c29a05
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #634 +/- ##
===================================
Coverage 88% 88%
===================================
Files 15 15
Lines 1925 1952 +27
===================================
+ Hits 1698 1726 +28
+ Misses 227 226 -1
|
The failing checks don't appear to be relevant to anything I have changed. @johlju can you advice? Also the code coverage didn't update after I added an additional test. |
Most likely because there are two
Don't see the additional test actually testing the code that are missed. To get coverage for line 302-306 the mock of |
Thanks for your advice @johlju. I've fixed the changelog and managed to get the code test coverage up to 100% of the new code (and even got some additional test coverage on the existing code) Some tests cover multiple aspects; if you prefer, I can split them into separate tests. |
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 r1, 1 of 2 files at r4, all commit messages.
Reviewable status: 4 of 6 files reviewed, 8 unresolved discussions (waiting on @RWebster-Noble)
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 41 at r4 (raw file):
[Parameter()] [pscredential]
We should change this to full type name [System.Management.Automation.PSCredential]
. Throughout the Test- and Set-function too.
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 60 at r4 (raw file):
$Ensure = 'Present' if ($WebApplication.Length -gt 0)
We should probably change this to if (-not [System.String]:IsNullOrEmpty($WebApplication))
. Or just switch the if and else-block then we can skip the -not
to make it easier to read.
Throughout below in Test- and Set-function.
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 62 at r4 (raw file):
if ($WebApplication.Length -gt 0) { $ItemPath = "IIS:Sites\$Website\$WebApplication\$Name"
We should use camelCase on local variables, so $itemPath
, throughout below. Throughout below in Test- and Set-function.
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 69 at r4 (raw file):
} $userName = (Get-ItemProperty $ItemPath -Name userName).Value
Is the property names using camelCase? Or should it be 'UserName'
?
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 70 at r4 (raw file):
$userName = (Get-ItemProperty $ItemPath -Name userName).Value if ($userName -ne '')
Can we use if (-not [System.String]:IsNullOrEmpty($userName))
here?
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 72 at r4 (raw file):
if ($userName -ne '') { #$password = (Get-ItemProperty $ItemPath -Name password).Value
We should remove this commented code if it not used.
source/DSCResources/DSC_WebVirtualDirectory/en-US/DSC_WebVirtualDirectory.strings.psd1
line 4 at r4 (raw file):
ConvertFrom-StringData -StringData @' VerboseGetTargetResource = Get-TargetResource has been run. VerboseSetTargetPhysicalPath = Updating PhysicalPath and Credential for Web Virtual Directory '{0}'.
The two properties are updated seperatly from each other, so there should probably be two separate localization messages, it would otherwise look like it update both properties every time when it not necessarily does.
source/DSCResources/DSC_WebVirtualDirectory/en-US/DSC_WebVirtualDirectory.strings.psd1
line 7 at r4 (raw file):
VerboseSetTargetCreateVirtualDirectory = Creating new Web Virtual Directory '{0}'. VerboseSetTargetRemoveVirtualDirectory = Removing existing Virtual Directory '{0}'. VerboseTestTargetFalse = Physical path '{0}' and Credential for Web Virtual Directory '{1}' is not in desired state.
The word 'and' should probbakly be 'or' if we should keep this as one message. But it would probably be better that this one is also split into two messages, one for each property being tested. 🤔
aa68dda
to
7a0803d
Compare
7a0803d
to
8817be5
Compare
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 1 of 2 files at r4.
Reviewable status: 3 of 6 files reviewed, 8 unresolved discussions (waiting on @johlju)
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 41 at r4 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
We should change this to full type name
[System.Management.Automation.PSCredential]
. Throughout the Test- and Set-function too.
Done.
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 60 at r4 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
We should probably change this to
if (-not [System.String]:IsNullOrEmpty($WebApplication))
. Or just switch the if and else-block then we can skip the-not
to make it easier to read.Throughout below in Test- and Set-function.
Done.
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 62 at r4 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
We should use camelCase on local variables, so
$itemPath
, throughout below. Throughout below in Test- and Set-function.
This code block was copied from the existing code and I did notice the inconsistent vatable casing.
I have updated it as requested.
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 69 at r4 (raw file):
I thought it look inconsistent too but I initially went with keeping the same casing consistent with output of Get-ItemProperty:
> Get-ItemProperty "IIS:\Sites\Default Web Site\vdir" -Name UserName
...
Name : userName
I just tested it and it's not case sensitive so would you still prefer UserName
(I have this updated it as requested)?
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 70 at r4 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
Can we use
if (-not [System.String]:IsNullOrEmpty($userName))
here?
Done.
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 72 at r4 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
We should remove this commented code if it not used.
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: 3 of 6 files reviewed, 8 unresolved discussions (waiting on @johlju)
source/DSCResources/DSC_WebVirtualDirectory/en-US/DSC_WebVirtualDirectory.strings.psd1
line 4 at r4 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
The two properties are updated seperatly from each other, so there should probably be two separate localization messages, it would otherwise look like it update both properties every time when it not necessarily does.
Done.
source/DSCResources/DSC_WebVirtualDirectory/en-US/DSC_WebVirtualDirectory.strings.psd1
line 7 at r4 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
The word 'and' should probbakly be 'or' if we should keep this as one message. But it would probably be better that this one is also split into two messages, one for each property being tested. 🤔
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.
The tests look good to me. I just glanced them but they seem to cover the changes, and have several aspects in the same tests is OK.
Just a minor thing left.
Reviewed 1 of 2 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @RWebster-Noble)
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 62 at r4 (raw file):
Previously, RWebster-Noble wrote…
This code block was copied from the existing code and I did notice the inconsistent vatable casing.
I have updated it as requested.
Great! Yes, old code might not have been fixed according to style guideline, but good if we don't add more to fix. 🙂
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 69 at r4 (raw file):
Previously, RWebster-Noble wrote…
I thought it look inconsistent too but I initially went with keeping the same casing consistent with output of Get-ItemProperty:
> Get-ItemProperty "IIS:\Sites\Default Web Site\vdir" -Name UserName ... Name : userName
I just tested it and it's not case sensitive so would you still prefer
UserName
(I have this updated it as requested)?
Since the the property returned is using camelCase I good with either. Keep as-is or change it as you prefer 🙂
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 160 at r5 (raw file):
{ Write-Verbose -Message ($script:localizedData.VerboseSetTargetCreateVirtualDirectory -f $Name) if ([bool]([System.Uri]$PhysicalPath).IsUnc)
Can we change to if ([System.Boolean] ([System.Uri] $PhysicalPath).IsUnc)
. Full type name and space after both type names.
But I think we could instead do if ($true -eq ([System.Uri] $PhysicalPath).IsUnc)
to forced it to evaluate against a boolean. 🤔 Either way is good for me. Not sure either is better or worse. 🤔
Btw. Did not know about the IsUnc
property, learned something new 🙂
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: all files reviewed, 1 unresolved discussion (waiting on @johlju)
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 160 at r5 (raw file):
I took that code from PR #428
I did think it was a bit strange but thought that there was a reason the original author wrote it like that but turns out that ([System.Uri] $PhysicalPath).IsUnc
is already a System.Boolean
> (([System.Uri] "\\a").IsUnc).GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Boolean System.ValueType
Given that wouldn't it be fine to simplify that to just to if (([System.Uri]$PhysicalPath).IsUnc)
?
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: 5 of 6 files reviewed, 1 unresolved discussion (waiting on @RWebster-Noble)
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 160 at r5 (raw file):
Previously, RWebster-Noble wrote…
I took that code from PR #428
I did think it was a bit strange but thought that there was a reason the original author wrote it like that but turns out that
([System.Uri] $PhysicalPath).IsUnc
is already aSystem.Boolean
> (([System.Uri] "\\a").IsUnc).GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Boolean System.ValueType
Given that wouldn't it be fine to simplify that to just to
if (([System.Uri]$PhysicalPath).IsUnc)
?
I think it was converted to boolean because the property is not set to $false
but $null
when the URI is not an UNC path. But the way you written it, it should work to since it will only enter the if-block if the property IsUnc
has a value other than $null
or $false
.
But add a space after the type name,, e.g
if (([System.Uri] $PhysicalPath).IsUnc)
0f78024
to
65f8bed
Compare
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: 5 of 6 files reviewed, 1 unresolved discussion (waiting on @johlju)
source/DSCResources/DSC_WebVirtualDirectory/DSC_WebVirtualDirectory.psm1
line 160 at r5 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
I think it was converted to boolean because the property is not set to
$false
but$null
when the URI is not an UNC path. But the way you written it, it should work to since it will only enter the if-block if the propertyIsUnc
has a value other than$null
or$false
.But add a space after the type name,, e.g
if (([System.Uri] $PhysicalPath).IsUnc)
Done.
Pull Request (PR) description
If you tried to configure a WebVirtualDirectory with a UNC PhysicalPath you would get the error
Parameter 'PhysicalPath' should point to existing path.
This fixes this error and also introduces a Credential parameter for IIS to use to access the path.
Parts of this code is based on #428
This Pull Request (PR) fixes the following issues
Fixes #94
Task list
Entry should say what was changed and how that affects users (if applicable), and
reference the issue being resolved (if applicable).
help.
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)