@@ -15,7 +15,7 @@ namespace DataPipelineTools.Functions.Tests.DataLake.DataLakeFunctions.Integrati
1515 [ Parallelizable ( ParallelScope . Children ) ]
1616 public class DataLakeGetItemsIntegrationTests : IntegrationTestBase
1717 {
18- protected override string FunctionUri => $ "{ FunctionsAppUrl } /api/DataLakeGetItems ";
18+ protected override string FunctionUri => $ "{ FunctionsAppUrl } /api/DataLake/GetItems ";
1919
2020 [ SetUp ]
2121 public void Setup ( )
@@ -30,6 +30,39 @@ public void Setup()
3030
3131
3232
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+ }
3366
3467 [ Test ]
3568 public async Task Test_FunctionIsRunnable_With_FunctionsServicePrincipalAuth ( )
@@ -48,11 +81,6 @@ public async Task Test_FunctionIsRunnable_With_FunctionsServicePrincipalAuth()
4881 Assert . AreEqual ( AuthType . FunctionsServicePrincipal , ( AuthType ) results . authType ) ;
4982 }
5083
51-
52-
53-
54-
55-
5684 [ Test ]
5785 public async Task Test_FunctionIsRunnable_With_UserServicePrincipalAuthAndPlainTextKey ( )
5886 {
@@ -108,6 +136,11 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndEmpt
108136 } ;
109137 var response = await RunQueryFromParameters ( parameters ) ;
110138 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 ( ) ) ;
111144 }
112145
113146 [ Test ]
@@ -126,6 +159,11 @@ public async Task Test_FunctionReturnsError_With_UserServicePrincipalAuthAndEmpt
126159 } ;
127160 var response = await RunQueryFromParameters ( parameters ) ;
128161 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 ( ) ) ;
129167 }
130168
131169
@@ -229,6 +267,11 @@ public async Task Test_FunctionReturnsError_With_SasTokenAuthAndEmptySasToken(st
229267 } ;
230268 var response = await RunQueryFromParameters ( parameters ) ;
231269 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 ( ) ) ;
232275 }
233276
234277 [ Test ]
@@ -303,6 +346,11 @@ public async Task Test_FunctionReturnsError_With_AccountKeyAuthAndEmptyAccountKe
303346 } ;
304347 var response = await RunQueryFromParameters ( parameters ) ;
305348 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 ( ) ) ;
306354 }
307355
308356
@@ -367,6 +415,9 @@ public async Task Test_FunctionReturnsError_When_MultipleAuthTypesUsed(bool useU
367415 var response = await RunQueryFromParameters ( parameters ) ;
368416 Assert . AreEqual ( expectedResponse , response . StatusCode ) ;
369417
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+
370421 // If the response was ok, check the correct auth type got used
371422 if ( response . StatusCode == HttpStatusCode . OK )
372423 {
@@ -378,10 +429,14 @@ public async Task Test_FunctionReturnsError_When_MultipleAuthTypesUsed(bool useU
378429 else if ( useAccountKey )
379430 expectedAuthType = AuthType . AccountKey ;
380431
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+
383433 Assert . AreEqual ( expectedAuthType , ( AuthType ) results . authType ) ;
384434 }
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+ }
385440 }
386441
387442
0 commit comments