@@ -494,7 +494,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
494
494
495
495
It " Validate Invoke-WebRequest -MaximumRedirection" {
496
496
497
- $uri = Get-WebListenerUrl - Test ' Redirect/ 3'
497
+ $uri = Get-WebListenerUrl - Test ' Redirect' - TestValue ' 3'
498
498
$command = " Invoke-WebRequest -Uri '$uri ' -MaximumRedirection 4"
499
499
500
500
$result = ExecuteWebCommand - command $command
@@ -508,7 +508,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
508
508
509
509
It " Validate Invoke-WebRequest error for -MaximumRedirection" {
510
510
511
- $uri = Get-WebListenerUrl - Test ' Redirect/ 3'
511
+ $uri = Get-WebListenerUrl - Test ' Redirect' - TestValue ' 3'
512
512
$command = " Invoke-WebRequest -Uri '$uri ' -MaximumRedirection 2"
513
513
514
514
$result = ExecuteWebCommand - command $command
@@ -517,7 +517,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
517
517
518
518
It " Invoke-WebRequest supports request that returns page containing UTF-8 data." {
519
519
520
- $uri = Get-WebListenerUrl - Test ' Encoding/ Utf8'
520
+ $uri = Get-WebListenerUrl - Test ' Encoding' - TestValue ' Utf8'
521
521
$command = " Invoke-WebRequest -Uri '$uri '"
522
522
523
523
$result = ExecuteWebCommand - command $command
@@ -529,15 +529,17 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
529
529
530
530
It " Invoke-WebRequest validate timeout option" {
531
531
532
- $command = " Invoke-WebRequest -Uri http://httpbin.org/delay/:5 -TimeoutSec 5"
532
+ $uri = Get-WebListenerUrl - Test ' Delay' - TestValue ' 5'
533
+ $command = " Invoke-WebRequest -Uri '$uri ' -TimeoutSec 5"
533
534
534
535
$result = ExecuteWebCommand - command $command
535
- $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException ,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
536
+ $result.Error.FullyQualifiedErrorId | Should Be " System.Threading.Tasks.TaskCanceledException ,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
536
537
}
537
538
538
539
It " Validate Invoke-WebRequest error with -Proxy and -NoProxy option" {
539
540
540
- $command = " Invoke-WebRequest -Uri http://httpbin.org/delay/:10 -Proxy 'http://localhost:8080' -NoProxy -TimeoutSec 2"
541
+ $uri = Get-WebListenerUrl - Test ' Delay' - TestValue ' 10'
542
+ $command = " Invoke-WebRequest -Uri '$uri ' -Proxy 'http://localhost:8080' -NoProxy -TimeoutSec 2"
541
543
542
544
$result = ExecuteWebCommand - command $command
543
545
$result.Error.FullyQualifiedErrorId | Should Be " AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
@@ -551,10 +553,11 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
551
553
It " Validate Invoke-WebRequest error with -Proxy option set - '<name>'" - TestCases $testCase {
552
554
param ($proxy_address , $name , $protocol )
553
555
554
- $command = " Invoke-WebRequest -Uri '${protocol} ://httpbin.org/delay/:5' -TimeoutSec 5 -Proxy '${proxy_address} '"
556
+ $uri = Get-WebListenerUrl - Test ' Delay' - TestValue ' 5' - Https:$ ($protocol -eq ' https' )
557
+ $command = " Invoke-WebRequest -Uri '$uri ' -TimeoutSec 5 -Proxy '${proxy_address} ' -SkipCertificateCheck"
555
558
556
559
$result = ExecuteWebCommand - command $command
557
- $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException ,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
560
+ $result.Error.FullyQualifiedErrorId | Should Be " System.Threading.Tasks.TaskCanceledException ,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
558
561
}
559
562
560
563
It " Validate Invoke-WebRequest error with environment proxy set - '<name>'" - TestCases $testCase {
@@ -563,10 +566,11 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
563
566
# Configure the environment variable.
564
567
New-Item - Name ${name} - Value ${proxy_address} - ItemType Variable - Path Env: - Force
565
568
566
- $command = " Invoke-WebRequest -Uri '${protocol} ://httpbin.org/delay/:5' -TimeoutSec 5"
569
+ $uri = Get-WebListenerUrl - Test ' Delay' - TestValue ' 5' - Https:$ ($protocol -eq ' https' )
570
+ $command = " Invoke-WebRequest -Uri '$uri ' -TimeoutSec 5 -SkipCertificateCheck"
567
571
568
572
$result = ExecuteWebCommand - command $command
569
- $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException ,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
573
+ $result.Error.FullyQualifiedErrorId | Should Be " System.Threading.Tasks.TaskCanceledException ,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
570
574
}
571
575
572
576
It " Validate Invoke-WebRequest returns User-Agent where -NoProxy with envirionment proxy set - '<name>'" - TestCases $testCase {
@@ -587,14 +591,6 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
587
591
$jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
588
592
}
589
593
590
- It " Invoke-WebRequest validate timeout option" {
591
-
592
- $command = " Invoke-WebRequest -Uri http://httpbin.org/delay/:5 -TimeoutSec 10"
593
-
594
- $result = ExecuteWebCommand - command $command
595
- $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
596
- }
597
-
598
594
# Perform the following operation for Invoke-WebRequest
599
595
# gzip Returns gzip-encoded data.
600
596
# deflate Returns deflate-encoded data.
@@ -1353,7 +1349,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1353
1349
1354
1350
It " Validate Invoke-RestMethod -MaximumRedirection" {
1355
1351
1356
- $uri = Get-WebListenerUrl - Test ' Redirect/ 3'
1352
+ $uri = Get-WebListenerUrl - Test ' Redirect' - TestValue ' 3'
1357
1353
$command = " Invoke-RestMethod -Uri '$uri ' -MaximumRedirection 4"
1358
1354
1359
1355
$result = ExecuteWebCommand - command $command
@@ -1365,7 +1361,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1365
1361
1366
1362
It " Validate Invoke-RestMethod error for -MaximumRedirection" {
1367
1363
1368
- $uri = Get-WebListenerUrl - Test ' Redirect/ 3'
1364
+ $uri = Get-WebListenerUrl - Test ' Redirect' - TestValue ' 3'
1369
1365
$command = " Invoke-RestMethod -Uri '$uri ' -MaximumRedirection 2"
1370
1366
1371
1367
$result = ExecuteWebCommand - command $command
@@ -1374,7 +1370,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1374
1370
1375
1371
It " Invoke-RestMethod supports request that returns page containing UTF-8 data." {
1376
1372
1377
- $uri = Get-WebListenerUrl - Test ' Encoding/ Utf8'
1373
+ $uri = Get-WebListenerUrl - Test ' Encoding' - TestValue ' Utf8'
1378
1374
$command = " Invoke-RestMethod -Uri '$uri '"
1379
1375
1380
1376
$result = ExecuteWebCommand - command $command
@@ -1383,15 +1379,17 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1383
1379
1384
1380
It " Invoke-RestMethod validate timeout option" {
1385
1381
1386
- $command = " Invoke-RestMethod -Uri http://httpbin.org/delay/:5 -TimeoutSec 2"
1382
+ $uri = Get-WebListenerUrl - Test ' Delay' - TestValue ' 5'
1383
+ $command = " Invoke-RestMethod -Uri '$uri ' -TimeoutSec 2"
1387
1384
1388
1385
$result = ExecuteWebCommand - command $command
1389
- $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException ,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
1386
+ $result.Error.FullyQualifiedErrorId | Should Be " System.Threading.Tasks.TaskCanceledException ,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
1390
1387
}
1391
1388
1392
1389
It " Validate Invoke-RestMethod error with -Proxy and -NoProxy option" {
1393
1390
1394
- $command = " Invoke-RestMethod -Uri http://httpbin.org/delay/:10 -Proxy 'http://localhost:8080' -NoProxy -TimeoutSec 2"
1391
+ $uri = Get-WebListenerUrl - Test ' Delay' - TestValue ' 10'
1392
+ $command = " Invoke-RestMethod -Uri '$uri ' -Proxy 'http://localhost:8080' -NoProxy -TimeoutSec 2"
1395
1393
1396
1394
$result = ExecuteWebCommand - command $command
1397
1395
$result.Error.FullyQualifiedErrorId | Should Be " AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
@@ -1417,10 +1415,11 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
1417
1415
# Configure the environment variable.
1418
1416
New-Item - Name ${name} - Value ${proxy_address} - ItemType Variable - Path Env: - Force
1419
1417
1420
- $command = " Invoke-RestMethod -Uri '${protocol} ://httpbin.org/delay/:5' -TimeoutSec 5"
1418
+ $uri = Get-WebListenerUrl - Test ' Delay' - TestValue ' 5' - Https:$ ($protocol -eq ' https' )
1419
+ $command = " Invoke-RestMethod -Uri '$uri ' -TimeoutSec 5 -SkipCertificateCheck"
1421
1420
1422
1421
$result = ExecuteWebCommand - command $command
1423
- $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException ,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
1422
+ $result.Error.FullyQualifiedErrorId | Should Be " System.Threading.Tasks.TaskCanceledException ,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
1424
1423
}
1425
1424
1426
1425
It " Validate Invoke-RestMethod returns User-Agent with option -NoProxy when environment proxy set - '<name>'" - TestCases $testCase {
0 commit comments