Change UserAgent App WindowsPowerShell -> PowerShell (#4914)

* Change UserAgent App WindowsPowerShell -> PowerShell

* [Feature] Run Feature tests

* [feature] Address PR Feedback with more precise assertion

* [feature] Address PR Feedback and add PSUserAgent Test

* [feature] add tag to describe block

* [feature] Remove describe block Add pattern to User-Agent specific tests

* [feature] Address PF Feedback

Remove all assertions for User-Agent that are not specifically about the User-Agent header.

* [feature] Match -> MatchExactly
This commit is contained in:
Mark Kraus 2017-09-27 09:44:20 -05:00 committed by Aditya Patwardhan
parent 7c64c0ff25
commit a8e8b1f8e4
2 changed files with 4 additions and 15 deletions

View file

@ -113,7 +113,7 @@ namespace Microsoft.PowerShell.Commands
get
{
string app = string.Format(CultureInfo.InvariantCulture,
"WindowsPowerShell/{0}", PSVersionInfo.PSVersion);
"PowerShell/{0}", PSVersionInfo.PSVersion);
return (app);
}
}

View file

@ -463,7 +463,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
# Validate response content
$jsonContent = $result.Output.Content | ConvertFrom-Json
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
$jsonContent.headers.'User-Agent' | Should MatchExactly '(?<!Windows)PowerShell\/\d+\.\d+\.\d+.*'
}
It "Invoke-WebRequest returns headers dictionary" {
@ -477,7 +477,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
# Validate response content
$jsonContent = $result.Output.Content | ConvertFrom-Json
$jsonContent.headers.Host | Should Be $Uri.Authority
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
}
It "Validate Invoke-WebRequest -DisableKeepAlive" {
@ -503,7 +502,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
# Validate response content
$jsonContent = $result.Output.Content | ConvertFrom-Json
$jsonContent.headers.Host | Should Match $uri.Authority
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
}
It "Validate Invoke-WebRequest error for -MaximumRedirection" {
@ -588,7 +586,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
# Validate response content
$jsonContent = $result.Output.Content | ConvertFrom-Json
$jsonContent.headers.Host | Should Be $uri.Authority
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
}
# Perform the following operation for Invoke-WebRequest
@ -654,7 +651,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
# Validate response content
$jsonContent = $result.Output.Content | ConvertFrom-Json
$jsonContent.url | Should Match $uri
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
# For a GET request, there is no data property to validate.
if ($method -ne "GET")
@ -716,7 +712,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
$result = ExecuteRequestWithOutFile -cmdletName "Invoke-WebRequest" -uri $uri
$jsonContent = $result.Output | ConvertFrom-Json
$jsonContent.headers.Host | Should Be $uri.Authority
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
}
It "Validate Invoke-WebRequest handles missing Content-Type in response header" {
@ -1318,7 +1313,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
$result = ExecuteWebCommand -command $command
# Validate response
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
$result.Output.headers.'User-Agent' | Should MatchExactly '(?<!Windows)PowerShell\/\d+\.\d+\.\d+.*'
}
It "Invoke-RestMethod returns headers dictionary" {
@ -1330,7 +1325,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
# Validate response
$result.Output.headers.Host | Should Be $Uri.Authority
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
}
It "Validate Invoke-RestMethod -DisableKeepAlive" {
@ -1343,7 +1337,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
# Validate response
$result.Output.headers.Host | Should Be $uri.Authority
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
$result.Output.Headers.Connection | Should Be "Close"
}
@ -1356,7 +1349,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
# Validate response
$result.Output.headers.Host | Should Match $uri.Authority
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
}
It "Validate Invoke-RestMethod error for -MaximumRedirection" {
@ -1434,7 +1426,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
$result = ExecuteWebCommand -command $command
# Validate response
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
$result.Output.headers.'User-Agent' | Should MatchExactly '(?<!Windows)PowerShell\/\d+\.\d+\.\d+.*'
}
# Perform the following operation for Invoke-RestMethod
@ -1496,7 +1488,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
# Validate response
$result.Output.url | Should Match $uri
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
# For a GET request, there is no data property to validate.
if ($method -ne "GET")
@ -1524,7 +1515,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
# Validate response
$result.Output.url | Should Match $uri
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
$result.Output.Headers.Connection | Should Be "Close"
}
@ -1559,7 +1549,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
$result = ExecuteRequestWithOutFile -cmdletName "Invoke-RestMethod" -uri $uri
$jsonContent = $result.Output | ConvertFrom-Json
$jsonContent.headers.Host | Should Be $uri.Authority
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
}
It "Validate Invoke-RestMethod handles missing Content-Type in response header" {