99using System . Net . Http ;
1010using System . Threading ;
1111using System . Threading . Tasks ;
12+ using Castle . Core . Logging ;
1213using Microsoft . Azure . WebJobs . Script . Diagnostics ;
1314using Microsoft . Azure . WebJobs . Script . WebHost ;
1415using Microsoft . Azure . WebJobs . Script . WebHost . Management ;
@@ -355,7 +356,7 @@ public async Task ValidateContext_InvalidZipUrl_WebsiteUseZip_ReturnsError()
355356 {
356357 var environmentSettings = new Dictionary < string , string > ( )
357358 {
358- { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http://invalid.com /invalid/dne" }
359+ { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http://invalid.test /invalid/dne" }
359360 } ;
360361
361362 var environment = new TestEnvironment ( ) ;
@@ -438,7 +439,7 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_Only()
438439 {
439440 var environment = new Dictionary < string , string > ( )
440441 {
441- { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http ://microsoft.com " }
442+ { EnvironmentSettingNames . AzureWebsiteZipDeployment , "https ://valid-zip.test " }
442443 } ;
443444 var assignmentContext = new HostAssignmentContext
444445 {
@@ -448,7 +449,19 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_Only()
448449 IsWarmupRequest = false
449450 } ;
450451
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 ) ;
452465 Assert . Null ( error ) ;
453466
454467 string [ ] expectedOutputLines =
@@ -538,8 +551,8 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_With_ScmPackageDefi
538551 {
539552 var environment = new Dictionary < string , string > ( )
540553 {
541- { EnvironmentSettingNames . AzureWebsiteZipDeployment , "http ://microsoft.com " } ,
542- { EnvironmentSettingNames . ScmRunFromPackage , "http ://microsoft.com " }
554+ { EnvironmentSettingNames . AzureWebsiteZipDeployment , "https ://valid.test " } ,
555+ { EnvironmentSettingNames . ScmRunFromPackage , "https ://valid.test " }
543556 } ;
544557 var assignmentContext = new HostAssignmentContext
545558 {
@@ -549,7 +562,19 @@ public async Task ValidateContext_Succeeds_For_WebsiteUseZip_With_ScmPackageDefi
549562 IsWarmupRequest = false
550563 } ;
551564
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 ) ;
553578 Assert . Null ( error ) ;
554579
555580 string [ ] expectedOutputLines =
0 commit comments