Skip to content

Commit

Permalink
Fixes for piping and display for ACLs
Browse files Browse the repository at this point in the history
Update Microsoft.Azure.Commands.DataLakeStore.dll-help.xml (#3)

Test updates and remove local packages

Fix and re-run tests for ADLS

More intentional with the not yet implemented APIs

remove extraneous restore.config
  • Loading branch information
begoldsm committed Sep 3, 2016
1 parent 2444c9b commit af57b2e
Show file tree
Hide file tree
Showing 21 changed files with 1,977 additions and 979 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.DataLake.Store, Version=0.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataLake.Store.0.12.4-preview\lib\net45\Microsoft.Azure.Management.DataLake.Store.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataLake.Store.0.12.5-preview\lib\net45\Microsoft.Azure.Management.DataLake.Store.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

namespace Microsoft.Azure.Commands.DataLakeAnalytics
{
[Cmdlet(VerbsCommon.New, "AzureRmDataLakeAnalyticsCatalogCredential"), OutputType(typeof(USqlCredential))]
[Alias("New-AdlCatalogCredential")]
// TODO: Uncomment this in the next release when credential CRUD is supported.
//[Cmdlet(VerbsCommon.New, "AzureRmDataLakeAnalyticsCatalogCredential"), OutputType(typeof(USqlCredential))]
//[Alias("New-AdlCatalogCredential")]
public class NewAzureDataLakeAnalyticsCatalogCredential : DataLakeAnalyticsCmdletBase
{
internal const string BaseParameterSetName = "Specify full URI";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

namespace Microsoft.Azure.Commands.DataLakeAnalytics
{
[Cmdlet(VerbsCommon.Remove, "AzureRmDataLakeAnalyticsCatalogCredential", SupportsShouldProcess = true), OutputType(typeof(bool))]
[Alias("Remove-AdlCatalogCredential")]
// TODO: Uncomment this in the next release when credential CRUD is supported.
//[Cmdlet(VerbsCommon.Remove, "AzureRmDataLakeAnalyticsCatalogCredential", SupportsShouldProcess = true), OutputType(typeof(bool))]
//[Alias("Remove-AdlCatalogCredential")]
public class RemoveAzureDataLakeAnalyticsCredential : DataLakeAnalyticsCmdletBase
{
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

namespace Microsoft.Azure.Commands.DataLakeAnalytics
{
[Cmdlet(VerbsCommon.Set, "AzureRmDataLakeAnalyticsCatalogCredential"), OutputType(typeof(USqlCredential))]
[Alias("Set-AdlCatalogCredential")]
// TODO: Uncomment this in the next release when credential CRUD is supported.
//[Cmdlet(VerbsCommon.Set, "AzureRmDataLakeAnalyticsCatalogCredential"), OutputType(typeof(USqlCredential))]
//[Alias("Set-AdlCatalogCredential")]
public class SetAzureDataLakeAnalyticsCatalogCredential : DataLakeAnalyticsCmdletBase
{
internal const string BaseParameterSetName = "Specify full URI";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,18 +465,25 @@ public bool TestCatalogItem(string accountName, CatalogPathInstance path,
public void CreateCredential(string accountName, string databaseName,
string credentialName, string userId, string password, string hostUri)
{
/*
* TODO: Uncomment this in the next release when credential CRUD is supported.
_catalogClient.Catalog.CreateCredential(accountName, databaseName, credentialName,
new DataLakeAnalyticsCatalogCredentialCreateParameters
{
Password = password,
Uri = hostUri,
UserId = userId
});
*/

throw new NotImplementedException();
}

public void UpdateCredentialPassword(string accountName, string databaseName,
string credentialName, string userId, string password, string newPassword, string hostUri)
{
/*
* TODO: Uncomment this in the next release when credential CRUD is supported.
_catalogClient.Catalog.UpdateCredential(accountName, databaseName, credentialName,
new DataLakeAnalyticsCatalogCredentialUpdateParameters
{
Expand All @@ -485,15 +492,22 @@ public void UpdateCredentialPassword(string accountName, string databaseName,
Uri = hostUri,
UserId = userId
});
*/
throw new NotImplementedException();
}

public void DeleteCredential(string accountName, string databaseName, string credentialName, string password = null)
{
/*
* TODO: Uncomment this in the next release when credential CRUD is supported.
_catalogClient.Catalog.DeleteCredential(accountName,
databaseName,
credentialName,
string.IsNullOrEmpty(password) ? null : new DataLakeAnalyticsCatalogCredentialDeleteParameters(password));
*/
throw new NotImplementedException();
}


public IList<CatalogItem> GetCatalogItem(string accountName, CatalogPathInstance path,
DataLakeAnalyticsEnums.CatalogItemType itemType)
Expand Down Expand Up @@ -554,9 +568,7 @@ public IList<CatalogItem> GetCatalogItem(string accountName, CatalogPathInstance
case DataLakeAnalyticsEnums.CatalogItemType.Credential:
if (isList)
{
throw new InvalidOperationException(Properties.Resources.InvalidUSqlSecretRequest);
// TODO: re-enable when list credentials is supported.
// toReturn.AddRange(GetCredentials(accountName, path.DatabaseName));
toReturn.AddRange(GetCredentials(accountName, path.DatabaseName));
}
else
{
Expand Down Expand Up @@ -745,8 +757,6 @@ private USqlCredential GetCredential(string accountName,
credName);
}

/*
* TODO: re-enable support when list credentials is available.
private IList<USqlCredential> GetCredentials(string accountName,
string databaseName)
{
Expand All @@ -761,7 +771,6 @@ private IList<USqlCredential> GetCredentials(string accountName,

return toReturn;
}
*/

private USqlSchema GetSchema(string accountName, string databaseName,
string schemaName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,40 +318,62 @@ function Test-DataLakeStoreFileSystemPermissions
# Set and get all the permissions
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-NotNull $result "Did not get any result from ACL get"
Assert-True {$result.UserAces.count -ge 0} "UserAces is negative or null"
$currentCount = $result.UserAces.Count
$result.UserAces.Add($aceUserId, "rwx")
Assert-True {$result.Count -ge 0} "UserAces is negative or null"
$currentCount = $result.Count
$result.Add("user:$aceUserId`:rwx")
$toRemove = $result[$result.Count -1]
Assert-AreEqual $aceUserId $toRemove.Id
Set-AdlStoreItemAcl -Account $accountName -path "/" -Acl $result
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.UserACes.Count
$result.UserAces.Remove($aceUserId)
Assert-AreEqual $($currentCount+1) $result.Count
$found = $false
for($i = 0; $i -lt $result.Count; $i++)
{
if($result[$i].Id -like $aceUserId)
{
$found = $true
$result.RemoveAt($i)
break
}
}

Assert-True { $found } "Failed to remove the element: $($toRemove.Entry)"
# remove the account
Set-AdlStoreItemAcl -Account $accountName -path "/" -Acl $result
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $currentCount $result.UserAces.Count
Assert-AreEqual $currentCount $result.Count

# Set and get a specific permission with friendly sets
Set-AdlStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId -Permissions All
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.UserAces.Count
Assert-AreEqual $($currentCount+1) $result.Count
# remove a specific permission with friendly remove
Remove-AdlStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $currentCount $result.UserAces.Count
Assert-AreEqual $currentCount $result.Count
# set and get a specific permission with the ACE string
Set-AdlStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:rwx", $aceUserId))
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.UserAces.Count
Assert-AreEqual $($currentCount+1) $result.Count
# remove a specific permission with the ACE string
Remove-AdlStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:---", $aceUserId))
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $currentCount $result.UserAces.Count
Assert-AreEqual $currentCount $result.Count

# verify that removal of full acl and default acl fail
# NOTE: commenting these tests out as these cmdlets have been temporarily removed until
# They are actually supported. This avoids confusion for our customers who might try to use them.
# Assert-Throws {Remove-AdlStoreItemAcl -Account $accountName -Path "/" -Force }
# Assert-Throws {Remove-AdlStoreItemAcl -Account $accountName -Path "/" -Force -Default }
Remove-AdlStoreItemAcl -Account $accountName -Path "/" -Force -Default
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual 4 $result.Count
Remove-AdlStoreItemAcl -Account $accountName -Path "/" -Force
$result = Get-AdlStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual 3 $result.Count

# validate permissions
$permission = Get-AdlStoreItemPermission -Account $accountName -path "/"
Assert-AreEqual 770 $permission
Set-AdlStoreItemPermission -Account $accountName -path "/" -Permission 777 | Out-Null
$permission = Get-AdlStoreItemPermission -Account $accountName -path "/"
Assert-AreEqual 777 $permission

# Delete Data Lake account
Assert-True {Remove-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Force -PassThru} "Remove Account failed."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,43 +315,64 @@ function Test-DataLakeStoreFileSystemPermissions
# define the permissions to add/remove
$aceUserId = "027c28d5-c91d-49f0-98c5-d10134b169b3"

# Set and get all the permissions
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-NotNull $result "Did not get any result from ACL get"
Assert-True {$result.Count -ge 0} "UserAces is negative or null"
$currentCount = $result.Count
$result.Add($aceUserId, "rwx")
$result.Add("user:$aceUserId`:rwx")
$toRemove = $result[$result.Count -1]
Assert-AreEqual $aceUserId $toRemove.Id
Set-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/" -Acl $result
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.Length
$result.UserAces.Remove($aceUserId)
Assert-AreEqual $($currentCount+1) $result.Count
$found = $false
for($i = 0; $i -lt $result.Count; $i++)
{
if($result[$i].Id -like $aceUserId)
{
$found = $true
$result.RemoveAt($i)
break
}
}

Assert-True { $found } "Failed to remove the element: $($toRemove.Entry)"
# remove the account
Set-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/" -Acl $result
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $currentCount $result.UserAces.Count
Assert-AreEqual $currentCount $result.Count

# Set and get a specific permission with friendly sets
Set-AzureRmDataLakeStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId -Permissions All
Set-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId -Permissions All
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.UserAces.Count
Assert-AreEqual $($currentCount+1) $result.Count
# remove a specific permission with friendly remove
Remove-AzureRmDataLakeStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId
Remove-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $currentCount $result.UserAces.Count
Assert-AreEqual $currentCount $result.Count
# set and get a specific permission with the ACE string
Set-AzureRmDataLakeStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:rwx", $aceUserId))
Set-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:rwx", $aceUserId))
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.UserAces.Count
Assert-AreEqual $($currentCount+1) $result.Count
# remove a specific permission with the ACE string
Remove-AzureRmDataLakeStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:---", $aceUserId))
Remove-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:---", $aceUserId))
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual $currentCount $result.UserAces.Count
Assert-AreEqual $currentCount $result.Count

# verify that removal of full acl and default acl fail
# NOTE: commenting these tests out as these cmdlets have been temporarily removed until
# They are actually supported. This avoids confusion for our customers who might try to use them.
# Assert-Throws {Remove-AzureRmDataLakeStoreItemAcl -Account $accountName -Path "/" -Force }
# Assert-Throws {Remove-AzureRmDataLakeStoreItemAcl -Account $accountName -Path "/" -Force -Default }
Remove-AzureRMDataLakeStoreItemAcl -Account $accountName -Path "/" -Force -Default
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual 4 $result.Count
Remove-AzureRMDataLakeStoreItemAcl -Account $accountName -Path "/" -Force
$result = Get-AzureRMDataLakeStoreItemAcl -Account $accountName -path "/"
Assert-AreEqual 3 $result.Count

# validate permissions
$permission = Get-AzureRMDataLakeStoreItemPermission -Account $accountName -path "/"
Assert-AreEqual 770 $permission
Set-AzureRMDataLakeStoreItemPermission -Account $accountName -path "/" -Permission 777 | Out-Null
$permission = Get-AzureRMDataLakeStoreItemPermission -Account $accountName -path "/"
Assert-AreEqual 777 $permission

# Delete Data Lake account
Assert-True {Remove-AzureRmDataLakeStoreAccount -ResourceGroupName $resourceGroupName -Name $accountName -Force -PassThru} "Remove Account failed."
Expand Down
Loading

0 comments on commit af57b2e

Please sign in to comment.