@@ -463,7 +463,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
463
463
464
464
# Validate response content
465
465
$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+.* '
467
467
}
468
468
469
469
It " Invoke-WebRequest returns headers dictionary" {
@@ -477,7 +477,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
477
477
# Validate response content
478
478
$jsonContent = $result.Output.Content | ConvertFrom-Json
479
479
$jsonContent.headers.Host | Should Be $Uri.Authority
480
- $jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
481
480
}
482
481
483
482
It " Validate Invoke-WebRequest -DisableKeepAlive" {
@@ -503,7 +502,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
503
502
# Validate response content
504
503
$jsonContent = $result.Output.Content | ConvertFrom-Json
505
504
$jsonContent.headers.Host | Should Match $uri.Authority
506
- $jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
507
505
}
508
506
509
507
It " Validate Invoke-WebRequest error for -MaximumRedirection" {
@@ -588,7 +586,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
588
586
# Validate response content
589
587
$jsonContent = $result.Output.Content | ConvertFrom-Json
590
588
$jsonContent.headers.Host | Should Be $uri.Authority
591
- $jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
592
589
}
593
590
594
591
# Perform the following operation for Invoke-WebRequest
@@ -654,7 +651,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
654
651
# Validate response content
655
652
$jsonContent = $result.Output.Content | ConvertFrom-Json
656
653
$jsonContent.url | Should Match $uri
657
- $jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
658
654
659
655
# For a GET request, there is no data property to validate.
660
656
if ($method -ne " GET" )
@@ -716,7 +712,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
716
712
$result = ExecuteRequestWithOutFile - cmdletName " Invoke-WebRequest" - uri $uri
717
713
$jsonContent = $result.Output | ConvertFrom-Json
718
714
$jsonContent.headers.Host | Should Be $uri.Authority
719
- $jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
720
715
}
721
716
722
717
It " Validate Invoke-WebRequest handles missing Content-Type in response header" {
@@ -1318,7 +1313,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1318
1313
$result = ExecuteWebCommand - command $command
1319
1314
1320
1315
# Validate response
1321
- $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell "
1316
+ $result.Output.headers .' User-Agent' | Should MatchExactly ' (?<!Windows)PowerShell\/\d+\.\d+\.\d+.* '
1322
1317
}
1323
1318
1324
1319
It " Invoke-RestMethod returns headers dictionary" {
@@ -1330,7 +1325,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1330
1325
1331
1326
# Validate response
1332
1327
$result.Output.headers.Host | Should Be $Uri.Authority
1333
- $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell"
1334
1328
}
1335
1329
1336
1330
It " Validate Invoke-RestMethod -DisableKeepAlive" {
@@ -1343,7 +1337,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1343
1337
1344
1338
# Validate response
1345
1339
$result.Output.headers.Host | Should Be $uri.Authority
1346
- $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell"
1347
1340
$result.Output.Headers.Connection | Should Be " Close"
1348
1341
}
1349
1342
@@ -1356,7 +1349,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1356
1349
1357
1350
# Validate response
1358
1351
$result.Output.headers.Host | Should Match $uri.Authority
1359
- $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell"
1360
1352
}
1361
1353
1362
1354
It " Validate Invoke-RestMethod error for -MaximumRedirection" {
@@ -1434,7 +1426,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1434
1426
$result = ExecuteWebCommand - command $command
1435
1427
1436
1428
# Validate response
1437
- $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell "
1429
+ $result.Output.headers .' User-Agent' | Should MatchExactly ' (?<!Windows)PowerShell\/\d+\.\d+\.\d+.* '
1438
1430
}
1439
1431
1440
1432
# Perform the following operation for Invoke-RestMethod
@@ -1496,7 +1488,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1496
1488
1497
1489
# Validate response
1498
1490
$result.Output.url | Should Match $uri
1499
- $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell"
1500
1491
1501
1492
# For a GET request, there is no data property to validate.
1502
1493
if ($method -ne " GET" )
@@ -1524,7 +1515,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1524
1515
1525
1516
# Validate response
1526
1517
$result.Output.url | Should Match $uri
1527
- $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell"
1528
1518
$result.Output.Headers.Connection | Should Be " Close"
1529
1519
}
1530
1520
@@ -1559,7 +1549,6 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1559
1549
$result = ExecuteRequestWithOutFile - cmdletName " Invoke-RestMethod" - uri $uri
1560
1550
$jsonContent = $result.Output | ConvertFrom-Json
1561
1551
$jsonContent.headers.Host | Should Be $uri.Authority
1562
- $jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
1563
1552
}
1564
1553
1565
1554
It " Validate Invoke-RestMethod handles missing Content-Type in response header" {
0 commit comments