16
16
using Microsoft . Azure . Management . HDInsight ;
17
17
using Microsoft . Azure . Management . Internal . Resources ;
18
18
using Microsoft . Azure . Management . OperationalInsights ;
19
+ using Microsoft . Azure . Management . ManagedServiceIdentity ;
20
+ using Microsoft . Azure . Management . KeyVault ;
19
21
using Microsoft . Azure . Management . Storage . Version2017_10_01 ;
20
22
using Microsoft . Azure . ServiceManagement . Common . Models ;
21
23
using Microsoft . Azure . Test . HttpRecorder ;
22
24
using Microsoft . Rest . ClientRuntime . Azure . TestFramework ;
23
25
using Microsoft . WindowsAzure . Commands . ScenarioTest ;
24
26
using Microsoft . WindowsAzure . Commands . Test . Utilities . Common ;
27
+ using Microsoft . Azure . KeyVault ;
25
28
using System ;
26
29
using System . Collections . Generic ;
27
30
using System . Diagnostics ;
@@ -35,13 +38,15 @@ public class TestController : RMTestBase
35
38
private readonly EnvironmentSetupHelper _helper ;
36
39
37
40
public ResourceManagementClient ResourceManagementClient { get ; private set ; }
38
-
39
41
public HDInsightManagementClient HDInsightManagementClient { get ; private set ; }
40
42
public StorageManagementClient StorageManagementClient { get ; private set ; }
41
43
public OperationalInsightsManagementClient OperationalInsightsManagementClient { get ; private set ; }
42
-
44
+ public KeyVaultManagementClient KeyVaultManagementClient { get ; private set ; }
45
+ public KeyVaultClient KeyVaultClient { get ; private set ; }
46
+ public ManagedServiceIdentityClient ManagedServiceIdentityClient { get ; private set ; }
47
+ public static TestHelper TestHelper { get ; private set ; }
43
48
public static TestController NewInstance => new TestController ( ) ;
44
-
49
+
45
50
protected TestController ( )
46
51
{
47
52
_helper = new EnvironmentSetupHelper ( ) ;
@@ -53,8 +58,9 @@ protected void SetupManagementClient(MockContext context)
53
58
HDInsightManagementClient = GetHDInsightManagementClient ( context ) ;
54
59
StorageManagementClient = GetStorageManagementClient ( context ) ;
55
60
OperationalInsightsManagementClient = GetOperationalInsightsManagementClient ( context ) ;
56
-
57
- _helper . SetupManagementClients ( ResourceManagementClient , HDInsightManagementClient , StorageManagementClient , OperationalInsightsManagementClient ) ;
61
+ KeyVaultManagementClient = GetKeyVaultManagementClient ( context ) ;
62
+ ManagedServiceIdentityClient = GetManagedServiceIdentityClient ( context ) ;
63
+ _helper . SetupManagementClients ( ResourceManagementClient , HDInsightManagementClient , StorageManagementClient , OperationalInsightsManagementClient , KeyVaultManagementClient , ManagedServiceIdentityClient ) ;
58
64
}
59
65
60
66
public void RunPowerShellTest ( XunitTracingInterceptor logger , params string [ ] scripts )
@@ -74,7 +80,7 @@ public void RunPowerShellTest(XunitTracingInterceptor logger, params string[] sc
74
80
mockName ) ;
75
81
}
76
82
77
- public void RunPsTestWorkFlow ( Func < string [ ] > scriptBuilder , Action cleanup , string callingClassType , string mockName )
83
+ public void RunPsTestWorkFlow ( Func < string [ ] > scriptBuilder , System . Action cleanup , string callingClassType , string mockName )
78
84
{
79
85
var d = new Dictionary < string , string >
80
86
{
@@ -95,6 +101,8 @@ public void RunPsTestWorkFlow(Func<string[]> scriptBuilder, Action cleanup, stri
95
101
{
96
102
SetupManagementClient ( context ) ;
97
103
_helper . SetupEnvironment ( AzureModule . AzureResourceManager ) ;
104
+ KeyVaultClient = GetKeyVaultClient ( ) ;
105
+ TestHelper = GetTestHelper ( ) ;
98
106
99
107
var callingClassName = callingClassType . Split ( new [ ] { "." } , StringSplitOptions . RemoveEmptyEntries ) . Last ( ) ;
100
108
@@ -104,6 +112,8 @@ public void RunPsTestWorkFlow(Func<string[]> scriptBuilder, Action cleanup, stri
104
112
_helper . RMProfileModule ,
105
113
_helper . GetRMModulePath ( @"AzureRM.HDInsight.psd1" ) ,
106
114
_helper . GetRMModulePath ( "AzureRM.OperationalInsights.psd1" ) ,
115
+ _helper . GetRMModulePath ( "AzureRM.ManagedServiceIdentity.psd1" ) ,
116
+ _helper . RMKeyVaultModule ,
107
117
"AzureRM.Storage.ps1" ,
108
118
"AzureRM.Resources.ps1" ) ;
109
119
try
@@ -140,5 +150,25 @@ private static OperationalInsightsManagementClient GetOperationalInsightsManagem
140
150
{
141
151
return context . GetServiceClient < OperationalInsightsManagementClient > ( TestEnvironmentFactory . GetTestEnvironment ( ) ) ;
142
152
}
153
+
154
+ private static KeyVaultManagementClient GetKeyVaultManagementClient ( MockContext context )
155
+ {
156
+ return context . GetServiceClient < KeyVaultManagementClient > ( TestEnvironmentFactory . GetTestEnvironment ( ) ) ;
157
+ }
158
+
159
+ private static KeyVaultClient GetKeyVaultClient ( )
160
+ {
161
+ return new KeyVaultClient ( TestHelper . GetAccessToken , TestHelper . GetHandlers ( ) ) ;
162
+ }
163
+
164
+ private static ManagedServiceIdentityClient GetManagedServiceIdentityClient ( MockContext context )
165
+ {
166
+ return context . GetServiceClient < ManagedServiceIdentityClient > ( TestEnvironmentFactory . GetTestEnvironment ( ) ) ;
167
+ }
168
+
169
+ private TestHelper GetTestHelper ( )
170
+ {
171
+ return new TestHelper ( KeyVaultManagementClient , KeyVaultClient ) ;
172
+ }
143
173
}
144
174
}
0 commit comments