9
9
using System . Net . Http ;
10
10
using System . Threading ;
11
11
using System . Threading . Tasks ;
12
+ using Castle . Core . Logging ;
12
13
using Microsoft . Azure . WebJobs . Script . Diagnostics ;
13
14
using Microsoft . Azure . WebJobs . Script . WebHost ;
14
15
using Microsoft . Azure . WebJobs . Script . WebHost . Management ;
@@ -355,7 +356,7 @@ public async Task ValidateContext_InvalidZipUrl_WebsiteUseZip_ReturnsError()
355
356
{
356
357
var environmentSettings = new Dictionary < string , string > ( )
357
358
{
358
- { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http://invalid.com /invalid/dne" }
359
+ { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http://invalid.test /invalid/dne" }
359
360
} ;
360
361
361
362
var environment = new TestEnvironment ( ) ;
@@ -438,7 +439,7 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_Only()
438
439
{
439
440
var environment = new Dictionary < string , string > ( )
440
441
{
441
- { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http ://microsoft.com " }
442
+ { EnvironmentSettingNames . AzureWebsiteZipDeployment , "https ://valid-zip.test " }
442
443
} ;
443
444
var assignmentContext = new HostAssignmentContext
444
445
{
@@ -448,7 +449,19 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_Only()
448
449
IsWarmupRequest = false
449
450
} ;
450
451
451
- string error = await _instanceManager . ValidateContext ( assignmentContext ) ;
452
+ var handlerMock = new Mock < HttpMessageHandler > ( ) ;
453
+ handlerMock . Protected ( ) . Setup < Task < HttpResponseMessage > > ( "SendAsync" ,
454
+ ItExpr . IsAny < HttpRequestMessage > ( ) ,
455
+ ItExpr . IsAny < CancellationToken > ( ) ) . ReturnsAsync ( new HttpResponseMessage
456
+ {
457
+ StatusCode = HttpStatusCode . OK ,
458
+ } ) ;
459
+
460
+ var instanceManager = new AtlasInstanceManager ( _optionsFactory , TestHelpers . CreateHttpClientFactory ( handlerMock . Object ) ,
461
+ _scriptWebEnvironment , _environment , _loggerFactory . CreateLogger < AtlasInstanceManager > ( ) ,
462
+ new TestMetricsLogger ( ) , null , _runFromPackageHandler , _packageDownloadHandler . Object ) ;
463
+
464
+ string error = await instanceManager . ValidateContext ( assignmentContext ) ;
452
465
Assert . Null ( error ) ;
453
466
454
467
string [ ] expectedOutputLines =
@@ -538,8 +551,8 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_With_ScmPackageDefi
538
551
{
539
552
var environment = new Dictionary < string , string > ( )
540
553
{
541
- { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http ://microsoft.com " } ,
542
- { EnvironmentSettingNames . ScmRunFromPackage , "http ://microsoft.com " }
554
+ { EnvironmentSettingNames . AzureWebsiteZipDeployment , "https ://valid.test " } ,
555
+ { EnvironmentSettingNames . ScmRunFromPackage , "https ://valid.test " }
543
556
} ;
544
557
var assignmentContext = new HostAssignmentContext
545
558
{
@@ -549,7 +562,19 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_With_ScmPackageDefi
549
562
IsWarmupRequest = false
550
563
} ;
551
564
552
- string error = await _instanceManager . ValidateContext ( assignmentContext ) ;
565
+ var handlerMock = new Mock < HttpMessageHandler > ( ) ;
566
+ handlerMock . Protected ( ) . Setup < Task < HttpResponseMessage > > ( "SendAsync" ,
567
+ ItExpr . IsAny < HttpRequestMessage > ( ) ,
568
+ ItExpr . IsAny < CancellationToken > ( ) ) . ReturnsAsync ( new HttpResponseMessage
569
+ {
570
+ StatusCode = HttpStatusCode . OK ,
571
+ } ) ;
572
+
573
+ var instanceManager = new AtlasInstanceManager ( _optionsFactory , TestHelpers . CreateHttpClientFactory ( handlerMock . Object ) ,
574
+ _scriptWebEnvironment , _environment , _loggerFactory . CreateLogger < AtlasInstanceManager > ( ) ,
575
+ new TestMetricsLogger ( ) , null , _runFromPackageHandler , _packageDownloadHandler . Object ) ;
576
+
577
+ string error = await instanceManager . ValidateContext ( assignmentContext ) ;
553
578
Assert . Null ( error ) ;
554
579
555
580
string [ ] expectedOutputLines =
0 commit comments