Skip to content

Commit f97a904

Browse files
authored
Merge pull request #6252 from idear1203/add_ps_support_for_catalog_acls
[ADLA] - Adding PS support for Catalog ACLs (v1)
2 parents 5fbc38b + 11a215c commit f97a904

File tree

51 files changed

+34491
-31350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+34491
-31350
lines changed

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics.Test/Commands.DataLakeAnalytics.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Management.DataLake.Analytics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6666
<SpecificVersion>False</SpecificVersion>
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataLake.Analytics.3.1.2-preview\lib\net452\Microsoft.Azure.Management.DataLake.Analytics.dll</HintPath>
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataLake.Analytics.3.3.0-preview\lib\net452\Microsoft.Azure.Management.DataLake.Analytics.dll</HintPath>
6868
<Private>True</Private>
6969
</Reference>
7070
<Reference Include="Microsoft.Azure.Management.DataLake.Store">

src/ResourceManager/DataLakeAnalytics/Commands.DataLakeAnalytics.Test/ScenarioTests/AdlaAliasTests.ps1

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,207 @@ function Test-DataLakeAnalyticsCatalog
12151215
# verify that the second secret cannot be retrieved
12161216
Assert-Throws {Get-AdlCatalogItem -AccountName $accountName -ItemType Secret -Path "$databaseName.$secretName2"}
12171217

1218+
# prepare to grant/revoke ACLs
1219+
$userPrincipalId = "027c28d5-c91d-49f0-98c5-d10134b169b3"
1220+
$groupPrincipalId = "58d2027c-d19c-0f94-5c89-1b43101d3b96"
1221+
1222+
# get the initial number of ACL by db
1223+
$aclByDbList = Get-AdlCatalogItemAclEntry -AccountName $accountName -ItemType Database -Path $databaseName
1224+
$aclByDbInitialCount = $aclByDbList.count
1225+
1226+
# get the initial number of ACL by catalog
1227+
$aclList = Get-AdlCatalogItemAclEntry -AccountName $accountName
1228+
$aclInitialCount = $aclList.count
1229+
1230+
# grant ACL entry for user to the db
1231+
$aclByDbList = Set-AdlCatalogItemAclEntry -AccountName $accountName -User -Id $userPrincipalId -ItemType Database -Path $databaseName -Permissions Read
1232+
1233+
Assert-AreEqual $($aclByDbInitialCount+1) $aclByDbList.count
1234+
$found = $false
1235+
foreach($acl in $aclByDbList)
1236+
{
1237+
if($acl.Id -eq $userPrincipalId)
1238+
{
1239+
# confirm the ACE's information
1240+
Assert-AreEqual User $acl.Type
1241+
Assert-AreEqual $userPrincipalId $acl.Id
1242+
Assert-AreEqual Read $acl.Permissions
1243+
$found = $true
1244+
break
1245+
}
1246+
}
1247+
1248+
Assert-True {$found} "Could not find the entry for $userPrincipalId in the ACL list of $databaseName"
1249+
1250+
# revoke ACE for user from the db
1251+
Assert-True {Remove-AdlCatalogItemAclEntry -AccountName $accountName -User -Id $userPrincipalId -ItemType Database -Path $databaseName -PassThru} "Remove ACE failed."
1252+
1253+
$aclByDbList = Get-AdlCatalogItemAclEntry -AccountName $accountName -ItemType Database -Path $databaseName
1254+
Assert-AreEqual $aclByDbInitialCount $aclByDbList.count
1255+
1256+
# grant ACL entry for group to the db
1257+
$aclByDbList = Set-AdlCatalogItemAclEntry -AccountName $accountName -Group -Id $groupPrincipalId -ItemType Database -Path $databaseName -Permissions Read
1258+
1259+
Assert-AreEqual $($aclByDbInitialCount+1) $aclByDbList.count
1260+
$found = $false
1261+
foreach($acl in $aclByDbList)
1262+
{
1263+
if($acl.Id -eq $groupPrincipalId)
1264+
{
1265+
# confirm the ACE's information
1266+
Assert-AreEqual Group $acl.Type
1267+
Assert-AreEqual $groupPrincipalId $acl.Id
1268+
Assert-AreEqual Read $acl.Permissions
1269+
$found = $true
1270+
break
1271+
}
1272+
}
1273+
1274+
Assert-True {$found} "Could not find the entry for $groupPrincipalId in the ACL list of $databaseName"
1275+
1276+
# revoke ACE for group from the db
1277+
Assert-True {Remove-AdlCatalogItemAclEntry -AccountName $accountName -Group -Id $groupPrincipalId -ItemType Database -Path $databaseName -PassThru} "Remove ACE failed."
1278+
1279+
$aclByDbList = Get-AdlCatalogItemAclEntry -AccountName $accountName -ItemType Database -Path $databaseName
1280+
Assert-AreEqual $aclByDbInitialCount $aclByDbList.count
1281+
1282+
# set ACL entry for other
1283+
$aclByDbList = Set-AdlCatalogItemAclEntry -AccountName $accountName -Other -ItemType Database -Path $databaseName -Permissions None
1284+
Assert-AreEqual $aclByDbInitialCount $aclByDbList.count
1285+
$found = $false
1286+
foreach($acl in $aclByDbList)
1287+
{
1288+
if($acl.Type -eq "Other")
1289+
{
1290+
# confirm the ACE's information
1291+
Assert-AreEqual None $acl.Permissions
1292+
$found = $true
1293+
break
1294+
}
1295+
}
1296+
1297+
Assert-True {$found} "Could not find the entry for Other in the ACL list of $databaseName"
1298+
1299+
$aclByDbList = Set-AdlCatalogItemAclEntry -AccountName $accountName -Other -ItemType Database -Path $databaseName -Permissions Read
1300+
Assert-AreEqual $aclByDbInitialCount $aclByDbList.count
1301+
$found = $false
1302+
foreach($acl in $aclByDbList)
1303+
{
1304+
if($acl.Type -eq "Other")
1305+
{
1306+
# confirm the ACE's information
1307+
Assert-AreEqual Read $acl.Permissions
1308+
$found = $true
1309+
break
1310+
}
1311+
}
1312+
1313+
Assert-True {$found} "Could not find the entry for Other in the ACL list of $databaseName"
1314+
1315+
# set owner permission to the db
1316+
$prevDbOwnerAcl = Get-AdlCatalogItemAclEntry -AccountName $accountName -UserOwner -ItemType Database -Path $databaseName
1317+
Assert-AreNotEqual None $prevDbOwnerAcl.Permissions
1318+
$currentDbOwnerAcl = Set-AdlCatalogItemAclEntry -AccountName $accountName -UserOwner -ItemType Database -Path $databaseName -Permissions None
1319+
Assert-AreEqual None $currentDbOwnerAcl.Permissions
1320+
$prevDbGroupAcl = Get-AdlCatalogItemAclEntry -AccountName $accountName -GroupOwner -ItemType Database -Path $databaseName
1321+
Assert-AreNotEqual None $prevDbGroupAcl.Permissions
1322+
$currentDbGroupAcl = Set-AdlCatalogItemAclEntry -AccountName $accountName -GroupOwner -ItemType Database -Path $databaseName -Permissions None
1323+
Assert-AreEqual None $currentDbGroupAcl.Permissions
1324+
1325+
# grant ACE for user to the catalog
1326+
$aclList = Set-AdlCatalogItemAclEntry -AccountName $accountName -User -Id $userPrincipalId -Permissions Read
1327+
Assert-AreEqual $($aclInitialCount+1) $aclList.count
1328+
$found = $false
1329+
foreach($acl in $aclList)
1330+
{
1331+
if($acl.Id -eq $userPrincipalId)
1332+
{
1333+
# confirm the ACE's information
1334+
Assert-AreEqual User $acl.Type
1335+
Assert-AreEqual $userPrincipalId $acl.Id
1336+
Assert-AreEqual Read $acl.Permissions
1337+
$found = $true
1338+
break
1339+
}
1340+
}
1341+
1342+
Assert-True {$found} "Could not find the entry for $userPrincipalId in the Catalog ACL list"
1343+
1344+
# revoke ACE for user from the catalog
1345+
Assert-True {Remove-AdlCatalogItemAclEntry -AccountName $accountName -User -Id $userPrincipalId -PassThru} "Remove ACE failed."
1346+
1347+
$aclList = Get-AdlCatalogItemAclEntry -AccountName $accountName
1348+
Assert-AreEqual $aclInitialCount $aclList.count
1349+
1350+
# grant ACL entry for group to the catalog
1351+
$aclList = Set-AdlCatalogItemAclEntry -AccountName $accountName -Group -Id $groupPrincipalId -Permissions Read
1352+
1353+
Assert-AreEqual $($aclInitialCount+1) $aclList.count
1354+
$found = $false
1355+
foreach($acl in $aclList)
1356+
{
1357+
if($acl.Id -eq $groupPrincipalId)
1358+
{
1359+
# confirm the ACE's information
1360+
Assert-AreEqual Group $acl.Type
1361+
Assert-AreEqual $groupPrincipalId $acl.Id
1362+
Assert-AreEqual Read $acl.Permissions
1363+
$found = $true
1364+
break
1365+
}
1366+
}
1367+
1368+
Assert-True {$found} "Could not find the entry for $groupPrincipalId in the Catalog ACL list"
1369+
1370+
# revoke ACE for group from the catalog
1371+
Assert-True {Remove-AdlCatalogItemAclEntry -AccountName $accountName -Group -Id $groupPrincipalId -PassThru} "Remove ACE failed."
1372+
1373+
$aclList = Get-AdlCatalogItemAclEntry -AccountName $accountName
1374+
Assert-AreEqual $aclInitialCount $aclList.count
1375+
1376+
# set ACL entry for other
1377+
$aclList = Set-AdlCatalogItemAclEntry -AccountName $accountName -Other -Permissions None
1378+
Assert-AreEqual $aclInitialCount $aclList.count
1379+
$found = $false
1380+
foreach($acl in $aclList)
1381+
{
1382+
if($acl.Type -eq "Other")
1383+
{
1384+
# confirm the ACE's information
1385+
Assert-AreEqual None $acl.Permissions
1386+
$found = $true
1387+
break
1388+
}
1389+
}
1390+
1391+
Assert-True {$found} "Could not find the entry for Other in the Catalog ACL list"
1392+
1393+
$aclList = Set-AdlCatalogItemAclEntry -AccountName $accountName -Other -Permissions Read
1394+
Assert-AreEqual $aclInitialCount $aclList.count
1395+
$found = $false
1396+
foreach($acl in $aclList)
1397+
{
1398+
if($acl.Type -eq "Other")
1399+
{
1400+
# confirm the ACE's information
1401+
Assert-AreEqual Read $acl.Permissions
1402+
$found = $true
1403+
break
1404+
}
1405+
}
1406+
1407+
Assert-True {$found} "Could not find the entry for Other in the Catalog ACL list"
1408+
1409+
# set owner permission to the catalog
1410+
$prevCatalogOwnerAcl = Get-AdlCatalogItemAclEntry -AccountName $accountName -UserOwner
1411+
Assert-AreNotEqual None $prevCatalogOwnerAcl.Permissions
1412+
$currentCatalogOwnerAcl = Set-AdlCatalogItemAclEntry -AccountName $accountName -UserOwner -Permissions None
1413+
Assert-AreEqual None $currentCatalogOwnerAcl.Permissions
1414+
$prevCatalogGroupAcl = Get-AdlCatalogItemAclEntry -AccountName $accountName -GroupOwner
1415+
Assert-AreNotEqual None $prevCatalogGroupAcl.Permissions
1416+
$currentCatalogGroupAcl = Set-AdlCatalogItemAclEntry -AccountName $accountName -GroupOwner -Permissions None
1417+
Assert-AreEqual None $currentCatalogGroupAcl.Permissions
1418+
12181419
# Delete the DataLakeAnalytics account
12191420
Assert-True {Remove-AdlAnalyticsAccount -ResourceGroupName $resourceGroupName -Name $accountName -Force -PassThru} "Remove Account failed."
12201421

0 commit comments

Comments
 (0)