6
6
using System . Linq ;
7
7
using Microsoft . Azure . WebJobs . Script . Config ;
8
8
using Microsoft . Extensions . DependencyInjection ;
9
- using NuGet . Configuration ;
10
9
using Xunit ;
11
10
using static Microsoft . Azure . WebJobs . Script . EnvironmentSettingNames ;
12
11
@@ -24,22 +23,21 @@ public void CreateTokenValidationParameters_HasExpectedAudience(bool isPlacehold
24
23
var podName = "RandomPodName" ;
25
24
var containerName = "RandomContainerName" ;
26
25
var siteName = "RandomSiteName" ;
27
- ScriptSettingsManager . Instance . SetSetting ( AzureWebsiteName , siteName ) ;
28
- ScriptSettingsManager . Instance . SetSetting ( WebsitePodName , podName ) ;
29
- ScriptSettingsManager . Instance . SetSetting ( ContainerName , string . Empty ) ;
30
26
31
27
var expectedWithSiteName = new string [ ]
32
28
{
33
- string . Format ( ScriptConstants . SiteAzureFunctionsUriFormat , ScriptSettingsManager . Instance . GetSetting ( AzureWebsiteName ) ) ,
34
- string . Format ( ScriptConstants . SiteUriFormat , ScriptSettingsManager . Instance . GetSetting ( AzureWebsiteName ) )
29
+ string . Format ( ScriptConstants . SiteAzureFunctionsUriFormat , siteName ) ,
30
+ string . Format ( ScriptConstants . SiteUriFormat , siteName )
35
31
} ;
36
- var expectedWithPodName = new string [ ]
32
+ var expectedWithPodName = new string [ ] { podName } ;
33
+ var expectedWithContainerName = Array . Empty < string > ( ) ;
34
+
35
+ var testData = new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase )
37
36
{
38
- ScriptSettingsManager . Instance . GetSetting ( WebsitePodName )
37
+ [ AzureWebsiteName ] = siteName ,
38
+ [ WebsitePodName ] = podName ,
39
+ [ ContainerName ] = string . Empty
39
40
} ;
40
- var expectedWithContainerName = new string [ ] { } ;
41
-
42
- var testData = new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase ) ;
43
41
44
42
if ( isPlaceholderModeEnabled )
45
43
{
@@ -54,17 +52,13 @@ public void CreateTokenValidationParameters_HasExpectedAudience(bool isPlacehold
54
52
}
55
53
else
56
54
{
57
- ScriptSettingsManager . Instance . SetSetting ( ContainerName , containerName ) ;
58
- expectedWithContainerName = new string [ ]
59
- {
60
- ScriptSettingsManager . Instance . GetSetting ( ContainerName )
61
- } ;
55
+ expectedWithContainerName = new string [ ] { containerName } ;
62
56
testData [ AzureWebsiteInstanceId ] = string . Empty ;
63
57
testData [ ContainerName ] = containerName ;
64
58
}
65
59
66
60
testData [ ContainerEncryptionKey ] = Convert . ToBase64String ( TestHelpers . GenerateKeyBytes ( ) ) ;
67
- using ( new TestScopedEnvironmentVariable ( testData ) )
61
+ using ( new TestScopedSettings ( ScriptSettingsManager . Instance , testData ) )
68
62
{
69
63
var tokenValidationParameters = ScriptJwtBearerExtensions . CreateTokenValidationParameters ( ) ;
70
64
var audiences = tokenValidationParameters . ValidAudiences . ToList ( ) ;
0 commit comments