Skip to content

Commit a8e8b1f

Browse files
markekrausadityapatwardhan
authored andcommitted
Change UserAgent App WindowsPowerShell -> PowerShell (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
1 parent 7c64c0f commit a8e8b1f

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ internal static string App
113113
get
114114
{
115115
string app = string.Format(CultureInfo.InvariantCulture,
116-
"WindowsPowerShell/{0}", PSVersionInfo.PSVersion);
116+
"PowerShell/{0}", PSVersionInfo.PSVersion);
117117
return (app);
118118
}
119119
}

test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
463463

464464
# Validate response content
465465
$jsonContent = $result.Output.Content | ConvertFrom-Json
466-
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
466+
$jsonContent.headers.'User-Agent' | Should MatchExactly '(?<!Windows)PowerShell\/\d+\.\d+\.\d+.*'
467467
}
468468

469469
It "Invoke-WebRequest returns headers dictionary" {
@@ -477,7 +477,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
477477
# Validate response content
478478
$jsonContent = $result.Output.Content | ConvertFrom-Json
479479
$jsonContent.headers.Host | Should Be $Uri.Authority
480-
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
481480
}
482481

483482
It "Validate Invoke-WebRequest -DisableKeepAlive" {
@@ -503,7 +502,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
503502
# Validate response content
504503
$jsonContent = $result.Output.Content | ConvertFrom-Json
505504
$jsonContent.headers.Host | Should Match $uri.Authority
506-
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
507505
}
508506

509507
It "Validate Invoke-WebRequest error for -MaximumRedirection" {
@@ -588,7 +586,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
588586
# Validate response content
589587
$jsonContent = $result.Output.Content | ConvertFrom-Json
590588
$jsonContent.headers.Host | Should Be $uri.Authority
591-
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
592589
}
593590

594591
# Perform the following operation for Invoke-WebRequest
@@ -654,7 +651,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
654651
# Validate response content
655652
$jsonContent = $result.Output.Content | ConvertFrom-Json
656653
$jsonContent.url | Should Match $uri
657-
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
658654

659655
# For a GET request, there is no data property to validate.
660656
if ($method -ne "GET")
@@ -716,7 +712,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
716712
$result = ExecuteRequestWithOutFile -cmdletName "Invoke-WebRequest" -uri $uri
717713
$jsonContent = $result.Output | ConvertFrom-Json
718714
$jsonContent.headers.Host | Should Be $uri.Authority
719-
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
720715
}
721716

722717
It "Validate Invoke-WebRequest handles missing Content-Type in response header" {
@@ -1318,7 +1313,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
13181313
$result = ExecuteWebCommand -command $command
13191314

13201315
# Validate response
1321-
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
1316+
$result.Output.headers.'User-Agent' | Should MatchExactly '(?<!Windows)PowerShell\/\d+\.\d+\.\d+.*'
13221317
}
13231318

13241319
It "Invoke-RestMethod returns headers dictionary" {
@@ -1330,7 +1325,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
13301325

13311326
# Validate response
13321327
$result.Output.headers.Host | Should Be $Uri.Authority
1333-
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
13341328
}
13351329

13361330
It "Validate Invoke-RestMethod -DisableKeepAlive" {
@@ -1343,7 +1337,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
13431337

13441338
# Validate response
13451339
$result.Output.headers.Host | Should Be $uri.Authority
1346-
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
13471340
$result.Output.Headers.Connection | Should Be "Close"
13481341
}
13491342

@@ -1356,7 +1349,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
13561349

13571350
# Validate response
13581351
$result.Output.headers.Host | Should Match $uri.Authority
1359-
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
13601352
}
13611353

13621354
It "Validate Invoke-RestMethod error for -MaximumRedirection" {
@@ -1434,7 +1426,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
14341426
$result = ExecuteWebCommand -command $command
14351427

14361428
# Validate response
1437-
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
1429+
$result.Output.headers.'User-Agent' | Should MatchExactly '(?<!Windows)PowerShell\/\d+\.\d+\.\d+.*'
14381430
}
14391431

14401432
# Perform the following operation for Invoke-RestMethod
@@ -1496,7 +1488,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
14961488

14971489
# Validate response
14981490
$result.Output.url | Should Match $uri
1499-
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
15001491

15011492
# For a GET request, there is no data property to validate.
15021493
if ($method -ne "GET")
@@ -1524,7 +1515,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
15241515

15251516
# Validate response
15261517
$result.Output.url | Should Match $uri
1527-
$result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell"
15281518
$result.Output.Headers.Connection | Should Be "Close"
15291519
}
15301520

@@ -1559,7 +1549,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
15591549
$result = ExecuteRequestWithOutFile -cmdletName "Invoke-RestMethod" -uri $uri
15601550
$jsonContent = $result.Output | ConvertFrom-Json
15611551
$jsonContent.headers.Host | Should Be $uri.Authority
1562-
$jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell"
15631552
}
15641553

15651554
It "Validate Invoke-RestMethod handles missing Content-Type in response header" {

0 commit comments

Comments
 (0)