-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix for PSDrive creation with a UNC path with a trailing backslash or forward slash when combined with -Persist #8305
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7f0c05c
Fix for issue 8242
kvprasoon 1788e66
codefactor fix
kvprasoon 2415fa9
Changes as per review comments
kvprasoon dbddef2
added tests for #8305
kvprasoon 7155f5b
Correcting WindowsRequireAdmin to RequireAdminOnWindows
kvprasoon 9977732
Changes as per review comment
kvprasoon 9cf4236
Changes as per review comments by adding a new line.
kvprasoon 29b5fed
trigger ci again
kvprasoon 4c4159b
Adding New-PSDrive.tests as per review comments.
kvprasoon e997466
removing typo and adding new line at EoF as per review comments.
kvprasoon 3a5b481
Adding missed OS Check
kvprasoon d47081f
rearranged parameters and get unused drive names as per review comments
kvprasoon 8998e80
Merging from Master
kvprasoon 795a750
Merging from master
kvprasoon b4c70aa
Corrrecting Typo in Name parameter
kvprasoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
test/powershell/Modules/Microsoft.PowerShell.Management/New-PSDrive.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| Describe "Tests for New-PSDrive cmdlet." -Tag "CI","RequireAdminOnWindows" { | ||
| Context "Validate New-PSDrive Cmdlet with -Persist switch." { | ||
| BeforeEach { | ||
| $UsedDrives = Get-PSDrive | Select-Object -ExpandProperty Name | ||
| $PSDriveName = 'D'..'Z' | Where-Object -FilterScript {$_ -notin $UsedDrives} | Get-Random | ||
| $RemoteShare = "\\$env:COMPUTERNAME\$($env:SystemDrive.replace(':','$\'))" | ||
| } | ||
|
|
||
| AfterEach { | ||
| Remove-PSDrive -Name $PSDriveName -Force -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| It "Should not throw exception for persistent PSDrive creation." -Skip:(-not $IsWindows) { | ||
| { New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root $RemoteShare -Persist -ErrorAction Stop } | Should -Not -Throw | ||
| } | ||
|
|
||
| it "Should throw exception if root is not a remote share." -Skip:(-not $IsWindows) { | ||
| { New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root "TestDrive:\" -Persist -ErrorAction Stop } | Should -Throw -ErrorId 'DriveRootNotNetworkPath' | ||
| } | ||
|
|
||
| it "Should throw exception if PSDrive is not a drive letter supported by operating system." -Skip:(-not $IsWindows) { | ||
| $PSDriveName = 'AB' | ||
| { New-PSDrive -Name $PSDriveName -PSProvider FileSystem -Root $RemoteShare -Persist -ErrorAction Stop } | Should -Throw -ErrorId 'DriveNameNotSupportedForPersistence' | ||
| } | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
test/powershell/Modules/Microsoft.PowerShell.Management/PSDrive.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.