From 85e62403209b57a91308e0d244f3bc3ab01b12e5 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Fri, 27 Jan 2023 18:34:32 +0100
Subject: [PATCH 1/9] fix bug
---
.../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
index beb9ad93e7e..7e449183392 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
@@ -373,6 +373,7 @@ public virtual string CustomMethod
/// Gets or sets the OutFile property.
///
[Parameter]
+ [ValidateNotNullOrEmpty]
public virtual string OutFile { get; set; }
///
From 519fa5762eb8a2296f6e885417c062e8d8b0a9ff Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Sat, 28 Jan 2023 22:29:25 +0100
Subject: [PATCH 2/9] Add tests if -Outfile is Null Or Empty
---
.../WebCmdlets.Tests.ps1 | 35 +++++++++++++++----
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index 285be044eb4..ea73b2adda7 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -704,6 +704,20 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$jsonContent.headers.Host | Should -Be $uri.Authority
}
+ It "Invoke-WebRequest should fail if -OutFile is empty" {
+ $uri = Get-WebListenerUrl -Test 'Get'
+ $command = "Invoke-WebRequest -Uri '$uri' -OutFile ''"
+ $result = ExecuteWebCommand -command $command
+ $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ }
+
+ It "Invoke-WebRequest should fail if -OutFile is null" {
+ $uri = Get-WebListenerUrl -Test 'Get'
+ $command = "Invoke-WebRequest -Uri '$uri' -OutFile $null"
+ $result = ExecuteWebCommand -command $command
+ $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ }
+
It "Validate Invoke-WebRequest handles missing Content-Type in response header" {
#Validate that exception is not thrown when response headers are missing Content-Type.
$uri = Get-WebListenerUrl -Test 'ResponseHeaders' -Query @{'Content-Type' = ''}
@@ -893,7 +907,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Content.Headers."Authorization" | Should -BeExactly "test"
}
-
+
It "Validates Invoke-WebRequest with -PreserveAuthorizationOnRedirect respects -MaximumRedirection on redirect: " -TestCases $redirectTests {
param($redirectType, $redirectedMethod)
$uri = Get-WebListenerUrl -Test 'Redirect' -TestValue '3' -Query @{type = $redirectType}
@@ -1851,11 +1865,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
Remove-Item -Force -ErrorAction 'SilentlyContinue' -Path $outFile
}
- It "Invoke-WebRequest -Resume requires -OutFile" {
- { Invoke-WebRequest -Resume -Uri $resumeUri -ErrorAction Stop } |
- Should -Throw -ErrorId 'WebCmdletOutFileMissingException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand'
- }
-
It "Invoke-WebRequest -Resume Downloads the whole file when the file does not exist" {
$response = Invoke-WebRequest -Uri $resumeUri -OutFile $outFile -Resume -PassThru
@@ -2390,6 +2399,20 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
$jsonContent.headers.Host | Should -Be $uri.Authority
}
+ It "Invoke-RestMethod should fail if -OutFile is empty" {
+ $uri = Get-WebListenerUrl -Test 'Get'
+ $command = "Invoke-RestMethod -Uri '$uri' -OutFile ''"
+ $result = ExecuteWebCommand -command $command
+ $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
+ }
+
+ It "Invoke-RestMethod should fail if -OutFile is null" {
+ $uri = Get-WebListenerUrl -Test 'Get'
+ $command = "Invoke-RestMethod -Uri '$uri' -OutFile $null"
+ $result = ExecuteWebCommand -command $command
+ $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
+ }
+
It "Validate Invoke-RestMethod handles missing Content-Type in response header" {
#Validate that exception is not thrown when response headers are missing Content-Type.
$uri = Get-WebListenerUrl -Test 'ResponseHeaders' -Query @{'Content-Type' = ''}
From c8d1c89a722fdaa1b717506a61fb0604292979c4 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Sat, 28 Jan 2023 22:40:47 +0100
Subject: [PATCH 3/9] removed wrong line
---
.../Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index ea73b2adda7..7c8322dbd76 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -1865,6 +1865,11 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
Remove-Item -Force -ErrorAction 'SilentlyContinue' -Path $outFile
}
+ It "Invoke-WebRequest -Resume requires -OutFile" {
+ { Invoke-WebRequest -Resume -Uri $resumeUri -ErrorAction Stop } |
+ Should -Throw -ErrorId 'WebCmdletOutFileMissingException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand'
+ }
+
It "Invoke-WebRequest -Resume Downloads the whole file when the file does not exist" {
$response = Invoke-WebRequest -Uri $resumeUri -OutFile $outFile -Resume -PassThru
From 6f0170187929acc1866e0e81a551ebde7ba6f9cb Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Sun, 29 Jan 2023 09:56:54 +0100
Subject: [PATCH 4/9] fix texts
---
.../Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index 7c8322dbd76..5ed4818697f 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -715,7 +715,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$uri = Get-WebListenerUrl -Test 'Get'
$command = "Invoke-WebRequest -Uri '$uri' -OutFile $null"
$result = ExecuteWebCommand -command $command
- $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ $result.Error.FullyQualifiedErrorId | Should -Be "MissingArgument,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
}
It "Validate Invoke-WebRequest handles missing Content-Type in response header" {
@@ -2415,7 +2415,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
$uri = Get-WebListenerUrl -Test 'Get'
$command = "Invoke-RestMethod -Uri '$uri' -OutFile $null"
$result = ExecuteWebCommand -command $command
- $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
+ $result.Error.FullyQualifiedErrorId | Should -Be "MissingArgument,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
}
It "Validate Invoke-RestMethod handles missing Content-Type in response header" {
From 58103c414fc8f9cb527b1a7cc0ac16ce4d137bfb Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Sun, 29 Jan 2023 12:39:16 +0100
Subject: [PATCH 5/9] better tests
---
.../WebCmdlets.Tests.ps1 | 20 ++++++++-----------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index 5ed4818697f..7344c654224 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -706,16 +706,14 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
It "Invoke-WebRequest should fail if -OutFile is empty" {
$uri = Get-WebListenerUrl -Test 'Get'
- $command = "Invoke-WebRequest -Uri '$uri' -OutFile ''"
- $result = ExecuteWebCommand -command $command
- $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ { Invoke-WebRequest -Uri $uri -OutFile ''} | Should -Throw -ErrorId $errorId
}
It "Invoke-WebRequest should fail if -OutFile is null" {
$uri = Get-WebListenerUrl -Test 'Get'
- $command = "Invoke-WebRequest -Uri '$uri' -OutFile $null"
- $result = ExecuteWebCommand -command $command
- $result.Error.FullyQualifiedErrorId | Should -Be "MissingArgument,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ { Invoke-WebRequest -Uri $uri -OutFile $null} | Should -Throw -ErrorId $errorId
}
It "Validate Invoke-WebRequest handles missing Content-Type in response header" {
@@ -2406,16 +2404,14 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
It "Invoke-RestMethod should fail if -OutFile is empty" {
$uri = Get-WebListenerUrl -Test 'Get'
- $command = "Invoke-RestMethod -Uri '$uri' -OutFile ''"
- $result = ExecuteWebCommand -command $command
- $result.Error.FullyQualifiedErrorId | Should -Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
+ $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
+ { Invoke-RestMethod -Uri $uri -OutFile ''} | Should -Throw -ErrorId $errorId
}
It "Invoke-RestMethod should fail if -OutFile is null" {
$uri = Get-WebListenerUrl -Test 'Get'
- $command = "Invoke-RestMethod -Uri '$uri' -OutFile $null"
- $result = ExecuteWebCommand -command $command
- $result.Error.FullyQualifiedErrorId | Should -Be "MissingArgument,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
+ $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
+ { Invoke-RestMethod -Uri $uri -OutFile $null} | Should -Throw -ErrorId $errorId
}
It "Validate Invoke-RestMethod handles missing Content-Type in response header" {
From bd16ef550417afa163837685be84682575eced71 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Sun, 29 Jan 2023 14:47:35 +0100
Subject: [PATCH 6/9] do the same for -InFile
---
.../Common/WebRequestPSCmdlet.Common.cs | 1 +
.../WebCmdlets.Tests.ps1 | 18 +++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
index 7e449183392..7744e894de9 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
@@ -358,6 +358,7 @@ public virtual string CustomMethod
/// Gets or sets the InFile property.
///
[Parameter]
+ [ValidateNotNullOrEmpty]
public virtual string InFile { get; set; }
///
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index 7344c654224..50f91bdb6ac 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -3653,10 +3653,16 @@ Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Featu
$uri = Get-WebListenerUrl -Test 'Post'
$testCases = @(
#region INVOKE-WEBREQUEST
+ @{
+ Name = 'Validate error for Invoke-WebRequest -InFile null'
+ ScriptBlock = {Invoke-WebRequest -Uri $uri -Method Post -InFile $null}
+ ExpectedFullyQualifiedErrorId = 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand'
+ }
+
@{
Name = 'Validate error for Invoke-WebRequest -InFile ""'
ScriptBlock = {Invoke-WebRequest -Uri $uri -Method Post -InFile ""}
- ExpectedFullyQualifiedErrorId = 'WebCmdletInFileNotFilePathException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand'
+ ExpectedFullyQualifiedErrorId = 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand'
}
@{
@@ -3673,14 +3679,20 @@ Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Featu
#endregion
#region INVOKE-RESTMETHOD
+ @{
+ Name = "Validate error for Invoke-RestMethod -InFile null"
+ ScriptBlock = {Invoke-RestMethod -Uri $uri -Method Post -InFile $null}
+ ExpectedFullyQualifiedErrorId = 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand'
+ }
+
@{
Name = "Validate error for Invoke-RestMethod -InFile ''"
ScriptBlock = {Invoke-RestMethod -Uri $uri -Method Post -InFile ''}
- ExpectedFullyQualifiedErrorId = 'WebCmdletInFileNotFilePathException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand'
+ ExpectedFullyQualifiedErrorId = 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand'
}
@{
- Name = "Validate error for Invoke-RestMethod -InFile "
+ Name = "Validate error for Invoke-RestMethod -InFile"
ScriptBlock = {Invoke-RestMethod -Uri $uri -Method Post -InFile}
ExpectedFullyQualifiedErrorId = 'MissingArgument,Microsoft.PowerShell.Commands.InvokeRestMethodCommand'
}
From 7f26770034c7e5f07f6af25be5ea84a0eb7821cd Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Mon, 30 Jan 2023 13:53:08 +0100
Subject: [PATCH 7/9] tests with -TestCases
---
.../WebCmdlets.Tests.ps1 | 30 ++++++++-----------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index 50f91bdb6ac..f956f124d3b 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -704,16 +704,14 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$jsonContent.headers.Host | Should -Be $uri.Authority
}
- It "Invoke-WebRequest should fail if -OutFile is empty" {
- $uri = Get-WebListenerUrl -Test 'Get'
- $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
- { Invoke-WebRequest -Uri $uri -OutFile ''} | Should -Throw -ErrorId $errorId
- }
-
- It "Invoke-WebRequest should fail if -OutFile is null" {
+ It "Invoke-WebRequest should fail if -OutFile is ." -TestCases @(
+ @{ Name = "empty"; Value = [string]::Empty }
+ @{ Name = "null"; Value = $null }
+ ) {
+ param ($value)
$uri = Get-WebListenerUrl -Test 'Get'
$errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
- { Invoke-WebRequest -Uri $uri -OutFile $null} | Should -Throw -ErrorId $errorId
+ { Invoke-WebRequest -Uri $uri -OutFile $value} | Should -Throw -ErrorId $errorId
}
It "Validate Invoke-WebRequest handles missing Content-Type in response header" {
@@ -2402,16 +2400,14 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
$jsonContent.headers.Host | Should -Be $uri.Authority
}
- It "Invoke-RestMethod should fail if -OutFile is empty" {
- $uri = Get-WebListenerUrl -Test 'Get'
- $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
- { Invoke-RestMethod -Uri $uri -OutFile ''} | Should -Throw -ErrorId $errorId
- }
-
- It "Invoke-RestMethod should fail if -OutFile is null" {
+ It "Invoke-RestMethod should fail if -OutFile is ." -TestCases @(
+ @{ Name = "empty"; Value = [string]::Empty }
+ @{ Name = "null"; Value = $null }
+ ) {
+ param ($value)
$uri = Get-WebListenerUrl -Test 'Get'
- $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
- { Invoke-RestMethod -Uri $uri -OutFile $null} | Should -Throw -ErrorId $errorId
+ $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ { Invoke-RestMethod -Uri $uri -OutFile $value} | Should -Throw -ErrorId $errorId
}
It "Validate Invoke-RestMethod handles missing Content-Type in response header" {
From 4e930c0a0d8a146b1aa32098ee79de327802b4cd Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Mon, 30 Jan 2023 14:11:10 +0100
Subject: [PATCH 8/9] fix
---
.../Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index f956f124d3b..4d7afad13e7 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -2406,7 +2406,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
) {
param ($value)
$uri = Get-WebListenerUrl -Test 'Get'
- $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
+ $errorId = "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
{ Invoke-RestMethod -Uri $uri -OutFile $value} | Should -Throw -ErrorId $errorId
}
From a0fd478fd1613b5123545542566cb6b6dd2e27f9 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Tue, 31 Jan 2023 11:56:17 +0100
Subject: [PATCH 9/9] Add test for -InFile folder
---
.../WebCmdlets.Tests.ps1 | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
index 4d7afad13e7..43363edb6eb 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
@@ -3668,10 +3668,16 @@ Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Featu
}
@{
- Name = "Validate error for Invoke-WebRequest -InFile $TestDrive\content.txt"
- ScriptBlock = {Invoke-WebRequest -Uri $uri -Method Post -InFile $TestDrive\content.txt}
+ Name = "Validate error for Invoke-WebRequest -InFile $TestDrive\content.txt"
+ ScriptBlock = {Invoke-WebRequest -Uri $uri -Method Post -InFile $TestDrive\content.txt}
ExpectedFullyQualifiedErrorId = 'PathNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand'
}
+
+ @{
+ Name = "Validate error for Invoke-WebRequest -InFile $TestDrive"
+ ScriptBlock = {Invoke-WebRequest -Uri $uri -Method Post -InFile $TestDrive}
+ ExpectedFullyQualifiedErrorId = 'WebCmdletInFileNotFilePathException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand'
+ }
#endregion
#region INVOKE-RESTMETHOD
@@ -3694,10 +3700,16 @@ Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Featu
}
@{
- Name = "Validate error for Invoke-RestMethod -InFile $TestDrive\content.txt"
+ Name = "Validate error for Invoke-RestMethod -InFile $TestDrive\content.txt"
ScriptBlock = {Invoke-RestMethod -Uri $uri -Method Post -InFile $TestDrive\content.txt}
ExpectedFullyQualifiedErrorId = 'PathNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand'
}
+
+ @{
+ Name = "Validate error for Invoke-RestMethod -InFile $TestDrive"
+ ScriptBlock = {Invoke-RestMethod -Uri $uri -Method Post -InFile $TestDrive}
+ ExpectedFullyQualifiedErrorId = 'WebCmdletInFileNotFilePathException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand'
+ }
#endregion
)
}