@@ -15,7 +15,7 @@ namespace DataPipelineTools.Functions.Tests.DataLake.DataLakeFunctions.Integrati
15
15
[ Parallelizable ( ParallelScope . Children ) ]
16
16
public class DataLakeGetItemsIntegrationTests : IntegrationTestBase
17
17
{
18
- protected override string FunctionUri => $ "{ FunctionsAppUrl } /api/DataLakeGetItems ";
18
+ protected override string FunctionUri => $ "{ FunctionsAppUrl } /api/DataLake/GetItems ";
19
19
20
20
[ SetUp ]
21
21
public void Setup ( )
@@ -30,6 +30,39 @@ public void Setup()
30
30
31
31
32
32
33
+ [ Test ]
34
+ public async Task Test_FunctionReturnsError_With_MissingAccountParam ( )
35
+ {
36
+ var parameters = new Dictionary < string , string >
37
+ {
38
+ { DataLakeConfigFactory . ContainerParam , StorageContainerName }
39
+ } ;
40
+ var response = await RunQueryFromParameters ( parameters ) ;
41
+ LogContent ( response ) ;
42
+ Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
43
+
44
+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
45
+ dynamic results = GetResultsObject ( response ) ;
46
+ Assert . IsNotNull ( results . error ) ;
47
+ Assert . AreEqual ( DataLakeConfigFactory . ErrorMessage . AccountParamIsMandatory , results . error . ToString ( ) ) ;
48
+ }
49
+
50
+ [ Test ]
51
+ public async Task Test_FunctionReturnsError_With_MissingContainerParam ( )
52
+ {
53
+ var parameters = new Dictionary < string , string >
54
+ {
55
+ { DataLakeConfigFactory . AccountParam , StorageAccountName }
56
+ } ;
57
+ var response = await RunQueryFromParameters ( parameters ) ;
58
+ LogContent ( response ) ;
59
+ Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
60
+
61
+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
62
+ dynamic results = GetResultsObject ( response ) ;
63
+ Assert . IsNotNull ( results . error ) ;
64
+ Assert . AreEqual ( DataLakeConfigFactory . ErrorMessage . ContainerParamIsMandatory , results . error . ToString ( ) ) ;
65
+ }
33
66
34
67
[ Test ]
35
68
public async Task Test_FunctionIsRunnable_With_FunctionsServicePrincipalAuth ( )
@@ -48,11 +81,6 @@ public async Task Test_FunctionIsRunnable_With_FunctionsServicePrincipalAuth()
48
81
Assert . AreEqual ( AuthType . FunctionsServicePrincipal , ( AuthType ) results . authType ) ;
49
82
}
50
83
51
-
52
-
53
-
54
-
55
-
56
84
[ Test ]
57
85
public async Task Test_FunctionIsRunnable_With_UserServicePrincipalAuthAndPlainTextKey ( )
58
86
{
@@ -108,6 +136,11 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndEmpt
108
136
} ;
109
137
var response = await RunQueryFromParameters ( parameters ) ;
110
138
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
139
+
140
+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
141
+ dynamic results = GetResultsObject ( response ) ;
142
+ Assert . IsNotNull ( results . error ) ;
143
+ Assert . AreEqual ( DataLakeConfigFactory . ErrorMessage . UserDefinedServicePrincipalParamsMissing , results . error . ToString ( ) ) ;
111
144
}
112
145
113
146
[ Test ]
@@ -126,6 +159,11 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndEmpt
126
159
} ;
127
160
var response = await RunQueryFromParameters ( parameters ) ;
128
161
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
162
+
163
+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
164
+ dynamic results = GetResultsObject ( response ) ;
165
+ Assert . IsNotNull ( results . error ) ;
166
+ Assert . AreEqual ( DataLakeConfigFactory . ErrorMessage . UserDefinedServicePrincipalParamsMissing , results . error . ToString ( ) ) ;
129
167
}
130
168
131
169
@@ -229,6 +267,11 @@ public async Task Test_FunctionReturnsError_With_SasTokenAuthAndEmptySasToken(st
229
267
} ;
230
268
var response = await RunQueryFromParameters ( parameters ) ;
231
269
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
270
+
271
+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
272
+ dynamic results = GetResultsObject ( response ) ;
273
+ Assert . IsNotNull ( results . error ) ;
274
+ Assert . AreEqual ( DataLakeConfigFactory . ErrorMessage . SasTokenParamMustHaveValue , results . error . ToString ( ) ) ;
232
275
}
233
276
234
277
[ Test ]
@@ -303,6 +346,11 @@ public async Task Test_FunctionReturnsError_With_AccountKeyAuthAndEmptyAccountKe
303
346
} ;
304
347
var response = await RunQueryFromParameters ( parameters ) ;
305
348
Assert . AreEqual ( HttpStatusCode . BadRequest , response . StatusCode ) ;
349
+
350
+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
351
+ dynamic results = GetResultsObject ( response ) ;
352
+ Assert . IsNotNull ( results . error ) ;
353
+ Assert . AreEqual ( DataLakeConfigFactory . ErrorMessage . AccountKeyParamMustHaveValue , results . error . ToString ( ) ) ;
306
354
}
307
355
308
356
@@ -367,6 +415,9 @@ public async Task Test_FunctionReturnsError_When_MultipleAuthTypesUsed(bool useU
367
415
var response = await RunQueryFromParameters ( parameters ) ;
368
416
Assert . AreEqual ( expectedResponse , response . StatusCode ) ;
369
417
418
+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
419
+ dynamic results = GetResultsObject ( response ) ;
420
+
370
421
// If the response was ok, check the correct auth type got used
371
422
if ( response . StatusCode == HttpStatusCode . OK )
372
423
{
@@ -378,10 +429,14 @@ public async Task Test_FunctionReturnsError_When_MultipleAuthTypesUsed(bool useU
378
429
else if ( useAccountKey )
379
430
expectedAuthType = AuthType . AccountKey ;
380
431
381
- // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
382
- dynamic results = GetResultsObject ( response ) ;
432
+
383
433
Assert . AreEqual ( expectedAuthType , ( AuthType ) results . authType ) ;
384
434
}
435
+ // If it was a bad request, check the error message is set correctly
436
+ else if ( response . StatusCode == HttpStatusCode . BadRequest )
437
+ {
438
+ Assert . AreEqual ( DataLakeConfigFactory . ErrorMessage . MultipleAuthTypesUsed , results . error . ToString ( ) ) ;
439
+ }
385
440
}
386
441
387
442
0 commit comments