1- using System ;
2- using System . Net ;
3- using System . Net . Http ;
4- using System . Threading . Tasks ;
5- using System . Web ;
61using DataPipelineTools . Tests . Common ;
72using Microsoft . Extensions . Logging ;
83using NUnit . Framework ;
4+ using SqlCollaborative . Azure . DataPipelineTools . Functions . DataLake ;
5+ using System ;
6+ using System . Collections . Generic ;
7+ using System . Net ;
8+ using System . Threading . Tasks ;
9+ using SqlCollaborative . Azure . DataPipelineTools . DataLake . Model ;
910
1011namespace DataPipelineTools . Functions . Tests . DataLake . DataLakeFunctions . Integration
1112{
1213 [ TestFixture ]
1314 [ Category ( nameof ( TestType . IntegrationTest ) ) ]
15+ [ Parallelizable ( ParallelScope . Children ) ]
1416 public class DataLakeGetItemsIntegrationTests : IntegrationTestBase
1517 {
1618 protected override string FunctionUri => $ "{ FunctionsAppUrl } /api/DataLakeGetItems";
@@ -25,33 +27,60 @@ public void Setup()
2527 }
2628
2729 [ Test ]
28- public async Task Test_FunctionIsRunnable ( )
30+ public async Task Test_FunctionIsRunnable_With_FunctionsServicePrincipalAuth ( )
2931 {
30- using ( var client = new HttpClient ( ) )
32+ var parameters = new Dictionary < string , string >
3133 {
32- var queryParams = HttpUtility . ParseQueryString ( string . Empty ) ;
33- queryParams [ "account" ] = this . StorageAccountName ;
34- queryParams [ "container" ] = this . StorageContainerName ;
34+ { DataLakeConfigFactory . AccountParam , StorageAccountName } ,
35+ { DataLakeConfigFactory . ContainerParam , StorageContainerName }
36+ } ;
37+ var response = await RunQueryFromParameters ( parameters ) ;
38+ LogContent ( response ) ;
39+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
3540
36- if ( ! IsEmulatorRunning )
37- queryParams [ "code" ] = this . FunctionsAppKey ;
41+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
42+ dynamic results = GetResultsObject ( response ) ;
43+ Assert . AreEqual ( AuthType . FunctionsServicePrincipal , ( AuthType ) results . authType ) ;
44+ }
3845
39- var urlBuilder = new UriBuilder ( FunctionUri )
40- {
41- Query = queryParams . ToString ( ) ?? string . Empty
42- } ;
43- var queryUrl = urlBuilder . ToString ( ) ;
46+ [ Test ]
47+ public async Task Test_FunctionIsRunnable_With_UserServicePrincipalAuthAndPlainTextKey ( )
48+ {
49+ var parameters = new Dictionary < string , string >
50+ {
51+ { DataLakeConfigFactory . AccountParam , StorageAccountName } ,
52+ { DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
53+ { DataLakeConfigFactory . ServicePrincipalClientIdParam , ServicePrincipalName } ,
54+ { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKey } ,
55+ } ;
56+ var response = await RunQueryFromParameters ( parameters ) ;
57+ LogContent ( response ) ;
58+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
4459
45- if ( ! IsRunningOnCIServer )
46- Logger . LogInformation ( $ "Query URL: { queryUrl } ") ;
47-
48- var result = await client . GetAsync ( queryUrl ) ;
49- var content = result . Content . ReadAsStringAsync ( ) . Result ;
60+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
61+ dynamic results = GetResultsObject ( response ) ;
62+ Assert . AreEqual ( AuthType . UserServicePrincipal , ( AuthType ) results . authType ) ;
63+ }
5064
51- Logger . LogInformation ( $ "Content: { content } ") ;
65+ [ Test ]
66+ public async Task Test_FunctionIsRunnable_With_UserServicePrincipalAuthAndKeyVaultKeyName ( )
67+ {
68+ var parameters = new Dictionary < string , string >
69+ {
70+ { DataLakeConfigFactory . AccountParam , StorageAccountName } ,
71+ { DataLakeConfigFactory . ContainerParam , StorageContainerName } ,
72+ { DataLakeConfigFactory . ServicePrincipalClientIdParam , ServicePrincipalName } ,
73+ { DataLakeConfigFactory . ServicePrincipalClientSecretParam , ServicePrincipalSecretKeyName } ,
74+ { DataLakeConfigFactory . KeyVaultParam , KeyVaultName }
75+ } ;
76+ var response = await RunQueryFromParameters ( parameters ) ;
77+ LogContent ( response ) ;
78+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
5279
53- Assert . AreEqual ( HttpStatusCode . OK , result . StatusCode ) ;
54- }
80+ // Check response details. Its important to cast the actual or we test against JToken from the dynamic results
81+ dynamic results = GetResultsObject ( response ) ;
82+ Assert . AreEqual ( AuthType . UserServicePrincipal , ( AuthType ) results . authType ) ;
5583 }
84+
5685 }
5786}
0 commit comments