16
16
using Microsoft . Azure . Commands . Common . Authentication . Abstractions ;
17
17
using Microsoft . Azure . Commands . Common . Authentication . Models ;
18
18
using Microsoft . Azure . Commands . Common . Authentication . Properties ;
19
- using Microsoft . Azure . Commands . ScenarioTest ;
20
19
using Microsoft . Azure . Commands . TestFx . Mocks ;
21
20
using Microsoft . Azure . ServiceManagement . Common . Models ;
22
21
using Microsoft . Rest . ClientRuntime . Azure . TestFramework ;
@@ -39,9 +38,9 @@ namespace Microsoft.Azure.Commands.TestFx
39
38
{
40
39
public class EnvironmentSetupHelper
41
40
{
42
- private const string TestFxEnvironmentName = "__testfx -environment" ;
41
+ private const string TestFxEnvironmentName = "testfx -environment" ;
43
42
44
- private const string TestFxSubscriptionName = "__testfx -subscription" ;
43
+ private const string TestFxSubscriptionName = "testfx -subscription" ;
45
44
46
45
private static string PackageDirectoryFromCommon { get ; } = GetConfigDirectory ( ) ;
47
46
@@ -78,17 +77,17 @@ public EnvironmentSetupHelper()
78
77
LogIfNotNull ( $ "Insights Module path: { module } ") ;
79
78
RMInsightsModule = module ;
80
79
module = GetModuleManifest ( RmDirectory , "Az.Storage" ) ;
81
- LogIfNotNull ( $ "Storage Management Module path: { module } ") ;
80
+ LogIfNotNull ( $ "Storage Module path: { module } ") ;
82
81
RMStorageModule = module ;
83
- module = GetModuleManifest ( StorageDirectory , "Azure.Storage" ) ;
84
- LogIfNotNull ( $ "Storage Data Plane Module path: { module } ") ;
85
- RMStorageDataPlaneModule = module ;
86
82
module = GetModuleManifest ( RmDirectory , "Az.OperationalInsights" ) ;
87
- LogIfNotNull ( $ "Storage Data Plane Module path: { module } ") ;
83
+ LogIfNotNull ( $ "OperationalInsights Module path: { module } ") ;
88
84
RMOperationalInsightsModule = module ;
89
85
module = GetModuleManifest ( RmDirectory , "Az.Network" ) ;
90
86
LogIfNotNull ( $ "Network Module path: { module } ") ;
91
87
RMNetworkModule = module ;
88
+ module = GetModuleManifest ( RmDirectory , "Az.KeyVault" ) ;
89
+ LogIfNotNull ( $ "KeyVault Module path: { module } ") ;
90
+ RMKeyVaultModule = module ;
92
91
module = GetModuleManifest ( RmDirectory , "Az.EventHub" ) ;
93
92
LogIfNotNull ( $ "EventHub Module path: { module } ") ;
94
93
RMEventHubModule = module ;
@@ -102,33 +101,8 @@ public EnvironmentSetupHelper()
102
101
LogIfNotNull ( $ "Stack Resources Module path: { module } ") ;
103
102
StackRMResourceModule = module ;
104
103
module = GetModuleManifest ( StackRmDirectory , "Az.Storage" ) ;
105
- LogIfNotNull ( $ "Stack Storage Management Plane Module path: { module } ") ;
104
+ LogIfNotNull ( $ "Stack Storage Module path: { module } ") ;
106
105
StackRMStorageModule = module ;
107
- module = GetModuleManifest ( StackStorageDirectory , "Azure.Storage" ) ;
108
- LogIfNotNull ( $ "Stack Storage Data Plane Module path: { module } ") ;
109
- StackRMStorageDataPlaneModule = module ;
110
- module = GetModuleManifest ( RmDirectory , "Az.KeyVault" ) ;
111
- LogIfNotNull ( $ "KeyVault Module path: { module } ") ;
112
- RMKeyVaultModule = module ;
113
-
114
- TestExecutionHelpers . SetUpSessionAndProfile ( ) ;
115
- IDataStore datastore = new MemoryDataStore ( ) ;
116
- if ( AzureSession . Instance . DataStore != null && ( AzureSession . Instance . DataStore is MemoryDataStore ) )
117
- {
118
- datastore = AzureSession . Instance . DataStore ;
119
- }
120
-
121
- AzureSession . Instance . DataStore = datastore ;
122
- var rmprofile = new AzureRmProfile ( Path . Combine ( AzureSession . Instance . ProfileDirectory , AzureSession . Instance . ProfileFile ) ) ;
123
- rmprofile . EnvironmentTable . Add ( "foo" , new AzureEnvironment ( AzureEnvironment . PublicEnvironments . Values . FirstOrDefault ( ) ) ) ;
124
- rmprofile . DefaultContext = new AzureContext ( new AzureSubscription ( ) , new AzureAccount ( ) , rmprofile . EnvironmentTable [ "foo" ] , new AzureTenant ( ) ) ;
125
- rmprofile . DefaultContext . Subscription . SetEnvironment ( "foo" ) ;
126
- if ( AzureRmProfileProvider . Instance . Profile == null )
127
- {
128
- AzureRmProfileProvider . Instance . Profile = rmprofile ;
129
- }
130
-
131
- AzureSession . Instance . DataStore = datastore ;
132
106
133
107
if ( File . Exists ( Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) , Resources . AzureDirectoryName , "testcredentials.json" ) ) )
134
108
{
@@ -150,8 +124,6 @@ public EnvironmentSetupHelper()
150
124
151
125
public string RMMonitorModule { get ; private set ; }
152
126
153
- public string RMStorageDataPlaneModule { get ; private set ; }
154
-
155
127
public string RMNetworkModule { get ; private set ; }
156
128
157
129
public string StackRMProfileModule { get ; private set ; }
@@ -160,8 +132,6 @@ public EnvironmentSetupHelper()
160
132
161
133
public string StackRMStorageModule { get ; private set ; }
162
134
163
- public string StackRMStorageDataPlaneModule { get ; private set ; }
164
-
165
135
public string RMKeyVaultModule { get ; private set ; }
166
136
167
137
private void LogIfNotNull ( string message )
@@ -393,15 +363,19 @@ public void SetupAzureEnvironmentFromEnvironmentVariables(AzureModule mode)
393
363
ResourceManagerUrl = currentEnvironment . Endpoints . ResourceManagementUri . AbsoluteUri ,
394
364
ServiceManagementUrl = currentEnvironment . Endpoints . ServiceManagementUri . AbsoluteUri ,
395
365
GalleryUrl = currentEnvironment . Endpoints . GalleryUri ? . AbsoluteUri ,
396
- AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = currentEnvironment . Endpoints . DataLakeAnalyticsJobAndCatalogServiceUri . OriginalString . Replace ( "https://" , "" ) , // because it is just a sufix
397
- AzureDataLakeStoreFileSystemEndpointSuffix = currentEnvironment . Endpoints . DataLakeStoreServiceUri . OriginalString . Replace ( "https://" , "" ) , // because it is just a sufix
366
+ AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix = currentEnvironment . Endpoints . DataLakeAnalyticsJobAndCatalogServiceUri . OriginalString . Replace ( "https://" , "" ) ,
367
+ AzureDataLakeStoreFileSystemEndpointSuffix = currentEnvironment . Endpoints . DataLakeStoreServiceUri . OriginalString . Replace ( "https://" , "" ) ,
398
368
StorageEndpointSuffix = AzureEnvironmentConstants . AzureStorageEndpointSuffix ,
399
369
AzureKeyVaultDnsSuffix = AzureEnvironmentConstants . AzureKeyVaultDnsSuffix ,
400
370
AzureKeyVaultServiceEndpointResourceId = AzureEnvironmentConstants . AzureKeyVaultServiceEndpointResourceId
401
371
} ;
402
372
testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . MicrosoftGraphUrl , currentEnvironment . Endpoints . GraphUri . AbsoluteUri ) ;
403
- testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . OperationalInsightsEndpoint , "https://api.loganalytics.io/v1" ) ;
404
- testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . OperationalInsightsEndpointResourceId , "https://api.loganalytics.io" ) ;
373
+ testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . AzureAttestationServiceEndpointSuffix , AzureEnvironmentConstants . AzureAttestationServiceEndpointSuffix ) ;
374
+ testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . AzureAttestationServiceEndpointResourceId , AzureEnvironmentConstants . AzureAttestationServiceEndpointResourceId ) ;
375
+ testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . AzureSynapseAnalyticsEndpointSuffix , AzureEnvironmentConstants . AzureSynapseAnalyticsEndpointSuffix ) ;
376
+ testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . AzureSynapseAnalyticsEndpointResourceId , AzureEnvironmentConstants . AzureSynapseAnalyticsEndpointResourceId ) ;
377
+ testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . OperationalInsightsEndpoint , AzureEnvironmentConstants . AzureOperationalInsightsEndpoint ) ;
378
+ testEnvironment . ExtendedProperties . SetProperty ( AzureEnvironment . ExtendedEndpoint . OperationalInsightsEndpointResourceId , AzureEnvironmentConstants . AzureOperationalInsightsEndpointResourceId ) ;
405
379
if ( ! AzureRmProfileProvider . Instance . GetProfile < AzureRmProfile > ( ) . EnvironmentTable . ContainsKey ( TestFxEnvironmentName ) )
406
380
{
407
381
AzureRmProfileProvider . Instance . GetProfile < AzureRmProfile > ( ) . EnvironmentTable [ TestFxEnvironmentName ] = testEnvironment ;
@@ -441,12 +415,13 @@ public void SetupAzureEnvironmentFromEnvironmentVariables(AzureModule mode)
441
415
testAccount . SetSubscriptions ( currentEnvironment . SubscriptionId ) ;
442
416
testAccount . SetTenants ( currentEnvironment . TenantId ) ;
443
417
418
+ AzureRmProfileProvider . Instance . Profile = new AzureRmProfile ( Path . Combine ( AzureSession . Instance . ProfileDirectory , AzureSession . Instance . ProfileFile ) ) ;
444
419
AzureRmProfileProvider . Instance . Profile . DefaultContext = new AzureContext ( testSubscription , testAccount , testEnvironment , testTenant ) ;
445
420
}
446
421
447
422
private void SetAuthenticationFactory ( TestEnvironment environment )
448
423
{
449
- if ( environment . TokenInfo . ContainsKey ( TokenAudience . Management ) )
424
+ if ( environment . IsRunningMocked )
450
425
{
451
426
var httpMessage = new HttpRequestMessage ( ) ;
452
427
environment . TokenInfo [ TokenAudience . Management ]
0 commit comments