@@ -42,8 +42,9 @@ public class DataLakeStoreTests : HDInsightTestBase
42
42
private Guid AadTenantId = new Guid ( "11111111-1111-1111-1111-111111111111" ) ;
43
43
private string Certificate = "" ;
44
44
private string CertificatePassword = "" ;
45
-
45
+ private byte [ ] CertificateFileContents = { } ;
46
46
private readonly PSCredential _httpCred ;
47
+ private Mock < AzureHDInsightConfig > AzureHDInsightconfigMock ;
47
48
48
49
public DataLakeStoreTests ( )
49
50
{
@@ -54,120 +55,52 @@ public DataLakeStoreTests()
54
55
CommandRuntime = commandRuntimeMock . Object ,
55
56
HDInsightManagementClient = hdinsightManagementMock . Object
56
57
} ;
58
+ AzureHDInsightconfigMock = new Mock < AzureHDInsightConfig > ( ) ;
57
59
}
58
60
59
- [ Fact ( Skip = "Test currently failing. To be fixed in next release." ) ]
61
+ [ Fact ]
60
62
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
61
- public void CanCreateNewHDInsightDataLakeStoreCluster ( )
63
+ public void CanCreateClusterConfigWithDataLakeStoreParameters ( )
62
64
{
63
- cmdlet . ClusterName = ClusterName ;
64
- cmdlet . ResourceGroupName = ResourceGroupName ;
65
- cmdlet . ClusterSizeInNodes = ClusterSize ;
66
- cmdlet . Location = Location ;
67
- cmdlet . HttpCredential = _httpCred ;
68
- cmdlet . DefaultStorageAccountName = StorageName ;
69
- cmdlet . DefaultStorageAccountKey = StorageKey ;
70
- cmdlet . AadTenantId = AadTenantId ;
71
- cmdlet . ObjectId = ObjectId ;
72
- cmdlet . CertificateFilePath = Certificate ;
73
- cmdlet . CertificatePassword = CertificatePassword ;
74
-
75
- var cluster = new Cluster
76
- {
77
- Id = "id" ,
78
- Name = ClusterName ,
79
- Location = Location ,
80
- Properties = new ClusterGetProperties
81
- {
82
- ClusterVersion = "3.2" ,
83
- ClusterState = "Running" ,
84
- ClusterDefinition = new ClusterDefinition
85
- {
86
- ClusterType = ClusterType
87
- } ,
88
- QuotaInfo = new QuotaInfo
89
- {
90
- CoresUsed = 24
91
- } ,
92
- OperatingSystemType = OSType . Windows
93
- }
94
- } ;
95
- var coreConfigs = new Dictionary < string , string >
96
- {
97
- { "fs.defaultFS" , "wasb://dummycsmv2@" + StorageName } ,
98
- {
99
- "fs.azure.account.key." + StorageName ,
100
- StorageKey
101
- }
102
- } ;
103
- var gatewayConfigs = new Dictionary < string , string >
104
- {
105
- { "restAuthCredential.isEnabled" , "true" } ,
106
- { "restAuthCredential.username" , _httpCred . UserName } ,
107
- { "restAuthCredential.password" , _httpCred . Password . ConvertToString ( ) }
108
- } ;
109
- var datalakeStoreConfigs = new Dictionary < string , string >
110
- {
111
- { "clusterIdentity.applicationId" , ObjectId . ToString ( ) } ,
112
- { "clusterIdentity.certificate" , Certificate } ,
113
- { "clusterIdentity.certificatePassword" , CertificatePassword } ,
114
- { "clusterIdentity.aadTenantId" , AadTenantId . ToString ( ) }
115
- } ;
116
- var configurations = new Dictionary < string , Dictionary < string , string > >
65
+ var newclusteridentitycmdlet = new NewAzureHDInsightClusterConfigCommand ( )
117
66
{
118
- { "core-site" , coreConfigs } ,
119
- { "gateway" , gatewayConfigs } ,
120
- { "clusterIdentity" , datalakeStoreConfigs }
67
+ CommandRuntime = commandRuntimeMock . Object ,
68
+ HDInsightManagementClient = hdinsightManagementMock . Object ,
69
+ ObjectId = ObjectId ,
70
+ CertificateFilePath = Certificate ,
71
+ AadTenantId = AadTenantId ,
72
+ CertificatePassword = CertificatePassword
121
73
} ;
122
- var serializedConfig = JsonConvert . SerializeObject ( configurations ) ;
123
- cluster . Properties . ClusterDefinition . Configurations = serializedConfig ;
124
-
125
- var getresponse = new ClusterGetResponse { Cluster = cluster } ;
126
-
127
- hdinsightManagementMock . Setup (
128
- c => c . CreateNewCluster ( ResourceGroupName , ClusterName , It . Is < ClusterCreateParameters > (
129
- parameters =>
130
- parameters . ClusterSizeInNodes == ClusterSize &&
131
- parameters . DefaultStorageAccountName == StorageName &&
132
- parameters . DefaultStorageAccountKey == StorageKey &&
133
- parameters . Location == Location &&
134
- parameters . UserName == _httpCred . UserName &&
135
- parameters . Password == _httpCred . Password . ConvertToString ( ) &&
136
- parameters . ClusterType == ClusterType &&
137
- parameters . OSType == OSType . Windows ) ) )
138
- . Returns ( getresponse )
139
- . Verifiable ( ) ;
140
-
141
- cmdlet . ExecuteCmdlet ( ) ;
142
74
143
- commandRuntimeMock . VerifyAll ( ) ;
144
- commandRuntimeMock . Verify ( f => f . WriteObject ( It . Is < AzureHDInsightCluster > (
145
- clusterout =>
146
- clusterout . ClusterState == "Running" &&
147
- clusterout . ClusterType == ClusterType &&
148
- clusterout . ClusterVersion == "3.2" &&
149
- clusterout . CoresUsed == 24 &&
150
- clusterout . Location == Location &&
151
- clusterout . Name == ClusterName &&
152
- clusterout . OperatingSystemType == OSType . Windows ) ) ,
153
- Times . Once ) ;
75
+ newclusteridentitycmdlet . ExecuteCmdlet ( ) ;
76
+ commandRuntimeMock . Verify (
77
+ f =>
78
+ f . WriteObject (
79
+ It . Is < AzureHDInsightConfig > (
80
+ c =>
81
+ c . AADTenantId == AadTenantId &&
82
+ c . CertificatePassword == CertificatePassword &&
83
+ c . ObjectId == ObjectId &&
84
+ c . CertificateFilePath == Certificate
85
+ ) ) ,
86
+ Times . Once ) ;
154
87
}
155
88
156
89
[ Fact ]
157
90
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
158
- public void CanCreateClusterConfigWithDataLakeStoreParameters ( )
91
+ public void CanCreateDataLakeClusterWithCertificationFileContents ( )
159
92
{
160
- var newclusteridentitycmdlet = new NewAzureHDInsightClusterConfigCommand ( )
93
+ var clusterIdentityCmdlet = new NewAzureHDInsightClusterConfigCommand ( )
161
94
{
162
95
CommandRuntime = commandRuntimeMock . Object ,
163
96
HDInsightManagementClient = hdinsightManagementMock . Object ,
164
- CertificateFilePath = Certificate ,
165
97
ObjectId = ObjectId ,
98
+ CertificateFileContents = CertificateFileContents ,
166
99
AadTenantId = AadTenantId ,
167
100
CertificatePassword = CertificatePassword
168
101
} ;
169
102
170
- newclusteridentitycmdlet . ExecuteCmdlet ( ) ;
103
+ clusterIdentityCmdlet . ExecuteCmdlet ( ) ;
171
104
commandRuntimeMock . Verify (
172
105
f =>
173
106
f . WriteObject (
@@ -176,9 +109,43 @@ public void CanCreateClusterConfigWithDataLakeStoreParameters()
176
109
c . AADTenantId == AadTenantId &&
177
110
c . CertificatePassword == CertificatePassword &&
178
111
c . ObjectId == ObjectId &&
179
- c . CertificateFilePath == Certificate
112
+ c . CertificateFileContents == CertificateFileContents
180
113
) ) ,
181
- Times . Once ) ;
114
+ Times . Once ) ;
115
+ }
116
+
117
+ [ Fact ]
118
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
119
+ public void ShouldThrowIfCertificateOptionsAreNotPassed ( )
120
+ {
121
+ var clusterIdentityCmdlet = new AddAzureHDInsightClusterIdentity ( )
122
+ {
123
+ CommandRuntime = commandRuntimeMock . Object ,
124
+ HDInsightManagementClient = hdinsightManagementMock . Object ,
125
+ ObjectId = ObjectId ,
126
+ AadTenantId = AadTenantId ,
127
+ CertificatePassword = CertificatePassword
128
+ } ;
129
+
130
+ Assert . Throws < ArgumentException > ( ( ) => clusterIdentityCmdlet . ExecuteCmdlet ( ) ) ;
131
+ }
132
+
133
+ [ Fact ]
134
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
135
+ public void ShouldThrowIfBothCertificateOptionsArePassed ( )
136
+ {
137
+ var clusterIdentityCmdlet = new AddAzureHDInsightClusterIdentity ( )
138
+ {
139
+ CommandRuntime = commandRuntimeMock . Object ,
140
+ HDInsightManagementClient = hdinsightManagementMock . Object ,
141
+ ObjectId = ObjectId ,
142
+ AadTenantId = AadTenantId ,
143
+ CertificatePassword = CertificatePassword ,
144
+ CertificateFileContents = CertificateFileContents ,
145
+ CertificateFilePath = Certificate
146
+ } ;
147
+
148
+ Assert . Throws < ArgumentException > ( ( ) => clusterIdentityCmdlet . ExecuteCmdlet ( ) ) ;
182
149
}
183
150
}
184
151
}
0 commit comments