1
- using DataPipelineTools . Tests . Common ;
2
- using Microsoft . Extensions . Logging ;
3
- using NUnit . Framework ;
4
- using SqlCollaborative . Azure . DataPipelineTools . Functions . DataLake ;
5
- using System ;
1
+ using System ;
6
2
using System . Collections . Generic ;
7
3
using System . Net ;
8
4
using System . Threading . Tasks ;
5
+ using Microsoft . Extensions . Logging ;
6
+ using NUnit . Framework ;
9
7
using SqlCollaborative . Azure . DataPipelineTools . DataLake . Model ;
8
+ using SqlCollaborative . Azure . DataPipelineTools . Functions . DataLake ;
10
9
11
- namespace DataPipelineTools . Functions . Tests . DataLake . DataLakeFunctions . Integration
10
+ namespace DataPipelineTools . Functions . Tests . Integration . DataLake
12
11
{
13
- [ TestFixture ]
14
- [ Category ( nameof ( TestType . IntegrationTest ) ) ]
15
- [ Parallelizable ( ParallelScope . Children ) ]
16
- public class DataLakeGetItemsIntegrationTests : IntegrationTestBase
12
+ /// <summary>
13
+ /// Base class for integration tests against data lake functions. The test here test the authentication, so are re-usable over
14
+ /// all data lake functions.
15
+ /// </summary>
16
+ public abstract class DataLakeIntegrationTestBase : IntegrationTestBase
17
17
{
18
- protected override string FunctionUri => $ "{ FunctionsAppUrl } /api/DataLake/GetItems";
19
-
20
18
[ SetUp ]
21
19
public void Setup ( )
22
20
{
@@ -35,7 +33,8 @@ public async Task Test_FunctionReturnsError_With_MissingAccountParam()
35
33
{
36
34
var parameters = new Dictionary < string , string >
37
35
{
38
- { DataLakeConfigFactory . ContainerParam , StorageContainerName }
36
+ { DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
37
+ { DataLakeConfigFactory . PathParam , "/" }
39
38
} ;
40
39
var response = await RunQueryFromParameters ( parameters ) ;
41
40
LogContent ( response ) ;
@@ -52,7 +51,8 @@ public async Task Test_FunctionReturnsError_With_MissingContainerParam()
52
51
{
53
52
var parameters = new Dictionary < string , string >
54
53
{
55
- { DataLakeConfigFactory . AccountParam , StorageAccountName }
54
+ { DataLakeConfigFactory . AccountParam , StorageAccountName } ,
55
+ { DataLakeConfigFactory . PathParam , "/" }
56
56
} ;
57
57
var response = await RunQueryFromParameters ( parameters ) ;
58
58
LogContent ( response ) ;
@@ -70,7 +70,8 @@ public async Task Test_FunctionIsRunnable_With_FunctionsServicePrincipalAuth()
70
70
var parameters = new Dictionary < string , string >
71
71
{
72
72
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
73
- { DataLakeConfigFactory . ContainerParam , StorageContainerName }
73
+ { DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
74
+ { DataLakeConfigFactory . PathParam , "/" }
74
75
} ;
75
76
var response = await RunQueryFromParameters ( parameters ) ;
76
77
LogContent ( response ) ;
@@ -90,6 +91,7 @@ public async Task Test_FunctionIsRunnable_With_UserServicePrincipalAuthAndPlainT
90
91
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
91
92
{ DataLakeConfigFactory . ServicePrincipalClientIdParam , ServicePrincipalName } ,
92
93
{ DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey } ,
94
+ { DataLakeConfigFactory . PathParam , "/" }
93
95
} ;
94
96
var response = await RunQueryFromParameters ( parameters ) ;
95
97
LogContent ( response ) ;
@@ -109,7 +111,8 @@ public async Task Test_FunctionIsRunnable_With_UserServicePrincipalAuthAndKeyVau
109
111
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
110
112
{ DataLakeConfigFactory . ServicePrincipalClientIdParam , ServicePrincipalName } ,
111
113
{ DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKeyName } ,
112
- { DataLakeConfigFactory . KeyVaultParam , KeyVaultName }
114
+ { DataLakeConfigFactory . KeyVaultParam , KeyVaultName } ,
115
+ { DataLakeConfigFactory . PathParam , "/" }
113
116
} ;
114
117
var response = await RunQueryFromParameters ( parameters ) ;
115
118
LogContent ( response ) ;
@@ -132,7 +135,8 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndEmpt
132
135
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
133
136
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
134
137
{ DataLakeConfigFactory . ServicePrincipalClientIdParam , clientId } ,
135
- { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey }
138
+ { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey } ,
139
+ { DataLakeConfigFactory . PathParam , "/" }
136
140
} ;
137
141
var response = await RunQueryFromParameters ( parameters ) ;
138
142
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -155,7 +159,8 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndEmpt
155
159
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
156
160
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
157
161
{ DataLakeConfigFactory . ServicePrincipalClientIdParam , ServicePrincipalName } ,
158
- { DataLakeConfigFactory . ServicePrincipalClientSecretParam , clientSecret }
162
+ { DataLakeConfigFactory . ServicePrincipalClientSecretParam , clientSecret } ,
163
+ { DataLakeConfigFactory . PathParam , "/" }
159
164
} ;
160
165
var response = await RunQueryFromParameters ( parameters ) ;
161
166
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -174,7 +179,8 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndMiss
174
179
{
175
180
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
176
181
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
177
- { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey }
182
+ { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey } ,
183
+ { DataLakeConfigFactory . PathParam , "/" }
178
184
} ;
179
185
var response = await RunQueryFromParameters ( parameters ) ;
180
186
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -187,7 +193,8 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndMiss
187
193
{
188
194
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
189
195
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
190
- { DataLakeConfigFactory . ServicePrincipalClientIdParam , ServicePrincipalName }
196
+ { DataLakeConfigFactory . ServicePrincipalClientIdParam , ServicePrincipalName } ,
197
+ { DataLakeConfigFactory . PathParam , "/" }
191
198
} ;
192
199
var response = await RunQueryFromParameters ( parameters ) ;
193
200
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -201,7 +208,8 @@ public async Task Test_FunctionReturnsError_With_InvalidUserServicePrincipalAuth
201
208
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
202
209
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
203
210
{ DataLakeConfigFactory . ServicePrincipalClientIdParam , Guid . NewGuid ( ) . ToString ( ) } ,
204
- { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey }
211
+ { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey } ,
212
+ { DataLakeConfigFactory . PathParam , "/" }
205
213
} ;
206
214
var response = await RunQueryFromParameters ( parameters ) ;
207
215
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -223,7 +231,8 @@ public async Task Test_FunctionIsRunnable_With_SasTokenAuthAndPlainTextKey()
223
231
{
224
232
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
225
233
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
226
- { DataLakeConfigFactory . SasTokenParam , StorageContainerSasToken }
234
+ { DataLakeConfigFactory . SasTokenParam , StorageContainerSasToken } ,
235
+ { DataLakeConfigFactory . PathParam , "/" }
227
236
} ;
228
237
var response = await RunQueryFromParameters ( parameters ) ;
229
238
LogContent ( response ) ;
@@ -242,7 +251,8 @@ public async Task Test_FunctionIsRunnable_With_SasTokenAuthAuthAndKeyVaultKeyNam
242
251
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
243
252
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
244
253
{ DataLakeConfigFactory . SasTokenParam , StorageContainerSasTokenName } ,
245
- { DataLakeConfigFactory . KeyVaultParam , KeyVaultName }
254
+ { DataLakeConfigFactory . KeyVaultParam , KeyVaultName } ,
255
+ { DataLakeConfigFactory . PathParam , "/" }
246
256
} ;
247
257
var response = await RunQueryFromParameters ( parameters ) ;
248
258
LogContent ( response ) ;
@@ -263,7 +273,8 @@ public async Task Test_FunctionReturnsError_With_SasTokenAuthAndEmptySasToken(st
263
273
{
264
274
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
265
275
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
266
- { DataLakeConfigFactory . SasTokenParam , sasToken }
276
+ { DataLakeConfigFactory . SasTokenParam , sasToken } ,
277
+ { DataLakeConfigFactory . PathParam , "/" }
267
278
} ;
268
279
var response = await RunQueryFromParameters ( parameters ) ;
269
280
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -281,7 +292,8 @@ public async Task Test_FunctionReturnsError_With_SasTokenAuthAndInvalidSasToken(
281
292
{
282
293
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
283
294
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
284
- { DataLakeConfigFactory . SasTokenParam , RandomString ( 20 ) }
295
+ { DataLakeConfigFactory . SasTokenParam , RandomString ( 20 ) } ,
296
+ { DataLakeConfigFactory . PathParam , "/" }
285
297
} ;
286
298
var response = await RunQueryFromParameters ( parameters ) ;
287
299
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -302,7 +314,8 @@ public async Task Test_FunctionIsRunnable_With_AccountKeyAuthAndPlainTextKey()
302
314
{
303
315
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
304
316
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
305
- { DataLakeConfigFactory . AccountKeyParam , StorageAccountAccessKey }
317
+ { DataLakeConfigFactory . AccountKeyParam , StorageAccountAccessKey } ,
318
+ { DataLakeConfigFactory . PathParam , "/" }
306
319
} ;
307
320
var response = await RunQueryFromParameters ( parameters ) ;
308
321
LogContent ( response ) ;
@@ -321,7 +334,8 @@ public async Task Test_FunctionIsRunnable_With_AccountKeyAuthAuthAndKeyVaultKeyN
321
334
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
322
335
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
323
336
{ DataLakeConfigFactory . AccountKeyParam , StorageAccountAccessKeyName } ,
324
- { DataLakeConfigFactory . KeyVaultParam , KeyVaultName }
337
+ { DataLakeConfigFactory . KeyVaultParam , KeyVaultName } ,
338
+ { DataLakeConfigFactory . PathParam , "/" }
325
339
} ;
326
340
var response = await RunQueryFromParameters ( parameters ) ;
327
341
LogContent ( response ) ;
@@ -342,7 +356,8 @@ public async Task Test_FunctionReturnsError_With_AccountKeyAuthAndEmptyAccountKe
342
356
{
343
357
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
344
358
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
345
- { DataLakeConfigFactory . AccountKeyParam , accountKey }
359
+ { DataLakeConfigFactory . AccountKeyParam , accountKey } ,
360
+ { DataLakeConfigFactory . PathParam , "/" }
346
361
} ;
347
362
var response = await RunQueryFromParameters ( parameters ) ;
348
363
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -361,7 +376,8 @@ public async Task Test_FunctionReturnsError_With_AccountKeyAuthAndInvalidAccount
361
376
{
362
377
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
363
378
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
364
- { DataLakeConfigFactory . AccountKeyParam , RandomString ( 20 ) }
379
+ { DataLakeConfigFactory . AccountKeyParam , RandomString ( 20 ) } ,
380
+ { DataLakeConfigFactory . PathParam , "/" }
365
381
} ;
366
382
var response = await RunQueryFromParameters ( parameters ) ;
367
383
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -399,7 +415,7 @@ public async Task Test_FunctionReturnsError_When_MultipleAuthTypesUsed(bool useU
399
415
{
400
416
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
401
417
{ DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
402
- // {DataLakeConfigFactory.AccountKeyParam, RandomString(20) }
418
+ { DataLakeConfigFactory . PathParam , "/" }
403
419
} ;
404
420
if ( useUserServicePrincipal )
405
421
{
@@ -450,7 +466,8 @@ public async Task Test_FunctionReturnsError_With_EmptyAccountName(string account
450
466
var parameters = new Dictionary < string , string >
451
467
{
452
468
{ DataLakeConfigFactory . AccountParam , accountName } ,
453
- { DataLakeConfigFactory . ContainerParam , StorageContainerName }
469
+ { DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
470
+ { DataLakeConfigFactory . PathParam , "/" }
454
471
} ;
455
472
var response = await RunQueryFromParameters ( parameters ) ;
456
473
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
@@ -466,7 +483,8 @@ public async Task Test_FunctionReturnsError_With_EmptyContainerName(string conta
466
483
var parameters = new Dictionary < string , string >
467
484
{
468
485
{ DataLakeConfigFactory . AccountParam , StorageAccountName } ,
469
- { DataLakeConfigFactory . ContainerParam , containerName }
486
+ { DataLakeConfigFactory . ContainerParam , containerName } ,
487
+ { DataLakeConfigFactory . PathParam , "/" }
470
488
} ;
471
489
var response = await RunQueryFromParameters ( parameters ) ;
472
490
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
0 commit comments