Skip to content

Commit

Permalink
[Storage] Update test and help
Browse files Browse the repository at this point in the history
  • Loading branch information
blueww committed Feb 19, 2021
1 parent d36d118 commit ab1b3ce
Show file tree
Hide file tree
Showing 27 changed files with 3,305 additions and 903 deletions.
9 changes: 9 additions & 0 deletions src/Storage/Storage.Management.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ function Get-ProviderLocation_Canary($provider)
"eastus2euap"
}

<#
.SYNOPSIS
Gets the Canary location for a provider
#>
function Get-ProviderLocation_Canary2($provider)
{
"centraluseuap"
}


<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,12 @@ public void TestNewSetAStorageAccount_RoutingPreference()
{
TestRunner.RunTestScript("Test-NewSetAzStorageAccount_RoutingPreference");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewSetAzureStorageAccountAllowSharedKeyAccess()
{
TestRunner.RunTestScript("Test-NewSetAzureStorageAccountAllowSharedKeyAccess");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1058,12 +1058,22 @@ function Test-StorageAccountManagementPolicy

# create Rule2
$action2 = Add-AzStorageAccountManagementPolicyAction -BaseBlobAction Delete -daysAfterModificationGreaterThan 100
$filter2 = New-AzStorageAccountManagementPolicyFilter
$filter2 = New-AzStorageAccountManagementPolicyFilter -BlobType appendBlob,blockBlob
$rule2 = New-AzStorageAccountManagementPolicyRule -Name Test2 -Action $action2 -Filter $filter2 -Disabled

# create Rule3
$action3 = Add-AzStorageAccountManagementPolicyAction -BlobVersionAction Delete -DaysAfterCreationGreaterThan 30
$action3 = Add-AzStorageAccountManagementPolicyAction -InputObject $action3 -BlobVersionAction TierToCool -DaysAfterCreationGreaterThan 40
$action3 = Add-AzStorageAccountManagementPolicyAction -InputObject $action3 -BlobVersionAction TierToArchive -DaysAfterCreationGreaterThan 50
$action3 = Add-AzStorageAccountManagementPolicyAction -InputObject $action3 -SnapshotAction TierToCool -daysAfterCreationGreaterThan 60
$action3 = Add-AzStorageAccountManagementPolicyAction -InputObject $action3 -SnapshotAction TierToArchive -daysAfterCreationGreaterThan 60
$action3 = Add-AzStorageAccountManagementPolicyAction -InputObject $action3 -SnapshotAction Delete -daysAfterCreationGreaterThan 80
$filter3 = New-AzStorageAccountManagementPolicyFilter
$rule3 = New-AzStorageAccountManagementPolicyRule -Name Test3 -Action $action3 -Filter $filter3

# Set policy
$policy = Set-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $stoname -Rule $rule1, $rule2
Assert-AreEqual 2 $policy.Rules.Count
$policy = Set-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $stoname -Rule $rule1, $rule2,$rule3
Assert-AreEqual 3 $policy.Rules.Count
Assert-AreEqual $rule1.Enabled $policy.Rules[0].Enabled
Assert-AreEqual $rule1.Name $policy.Rules[0].Name
Assert-AreEqual $rule1.Definition.Actions.BaseBlob.Delete.DaysAfterModificationGreaterThan $policy.Rules[0].Definition.Actions.BaseBlob.Delete.DaysAfterModificationGreaterThan
Expand All @@ -1081,10 +1091,22 @@ function Test-StorageAccountManagementPolicy
Assert-AreEqual $rule2.Definition.Actions.BaseBlob.TierToCool $policy.Rules[1].Definition.Actions.BaseBlob.TierToCool
Assert-AreEqual $rule2.Definition.Actions.Snapshot $policy.Rules[1].Definition.Actions.Snapshot
Assert-AreEqual $rule2.Definition.Filters.BlobTypes[0] $policy.Rules[1].Definition.Filters.BlobTypes[0]
Assert-AreEqual $rule2.Definition.Filters.BlobTypes[1] $policy.Rules[1].Definition.Filters.BlobTypes[1]
Assert-AreEqual $rule2.Definition.Filters.PrefixMatch $policy.Rules[1].Definition.Filters.PrefixMatch
Assert-AreEqual $rule3.Enabled $policy.Rules[2].Enabled
Assert-AreEqual $rule3.Name $policy.Rules[2].Name
Assert-AreEqual $rule3.Definition.Actions.BaseBlob $policy.Rules[2].Definition.Actions.BaseBlob
Assert-AreEqual $rule3.Definition.Actions.Snapshot.Delete.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.Delete.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Snapshot.TierToCool.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.TierToCool.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Snapshot.TierToArchive.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.TierToArchive.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.Delete.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.Delete.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.TierToCool.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.TierToCool.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.TierToArchive.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.TierToArchive.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Filters.BlobTypes[0] $policy.Rules[2].Definition.Filters.BlobTypes[0]
Assert-AreEqual $rule3.Definition.Filters.PrefixMatch $policy.Rules[2].Definition.Filters.PrefixMatch

$policy = Get-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual 2 $policy.Rules.Count
Assert-AreEqual 3 $policy.Rules.Count
Assert-AreEqual $rule1.Enabled $policy.Rules[0].Enabled
Assert-AreEqual $rule1.Name $policy.Rules[0].Name
Assert-AreEqual $rule1.Definition.Actions.BaseBlob.Delete.DaysAfterModificationGreaterThan $policy.Rules[0].Definition.Actions.BaseBlob.Delete.DaysAfterModificationGreaterThan
Expand All @@ -1102,14 +1124,26 @@ function Test-StorageAccountManagementPolicy
Assert-AreEqual $rule2.Definition.Actions.BaseBlob.TierToCool $policy.Rules[1].Definition.Actions.BaseBlob.TierToCool
Assert-AreEqual $rule2.Definition.Actions.Snapshot $policy.Rules[1].Definition.Actions.Snapshot
Assert-AreEqual $rule2.Definition.Filters.BlobTypes[0] $policy.Rules[1].Definition.Filters.BlobTypes[0]
Assert-AreEqual $rule2.Definition.Filters.BlobTypes[1] $policy.Rules[1].Definition.Filters.BlobTypes[1]
Assert-AreEqual $rule2.Definition.Filters.PrefixMatch $policy.Rules[1].Definition.Filters.PrefixMatch
Assert-AreEqual $rule3.Enabled $policy.Rules[2].Enabled
Assert-AreEqual $rule3.Name $policy.Rules[2].Name
Assert-AreEqual $rule3.Definition.Actions.BaseBlob $policy.Rules[2].Definition.Actions.BaseBlob
Assert-AreEqual $rule3.Definition.Actions.Snapshot.Delete.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.Delete.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Snapshot.TierToCool.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.TierToCool.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Snapshot.TierToArchive.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.TierToArchive.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.Delete.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.Delete.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.TierToCool.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.TierToCool.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.TierToArchive.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.TierToArchive.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Filters.BlobTypes[0] $policy.Rules[2].Definition.Filters.BlobTypes[0]
Assert-AreEqual $rule3.Definition.Filters.PrefixMatch $policy.Rules[2].Definition.Filters.PrefixMatch

Remove-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $stoname

$policy| Set-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $stoname

$policy = Get-AzStorageAccountManagementPolicy -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual 2 $policy.Rules.Count
Assert-AreEqual 3 $policy.Rules.Count
Assert-AreEqual $rule1.Enabled $policy.Rules[0].Enabled
Assert-AreEqual $rule1.Name $policy.Rules[0].Name
Assert-AreEqual $rule1.Definition.Actions.BaseBlob.Delete.DaysAfterModificationGreaterThan $policy.Rules[0].Definition.Actions.BaseBlob.Delete.DaysAfterModificationGreaterThan
Expand All @@ -1127,7 +1161,19 @@ function Test-StorageAccountManagementPolicy
Assert-AreEqual $rule2.Definition.Actions.BaseBlob.TierToCool $policy.Rules[1].Definition.Actions.BaseBlob.TierToCool
Assert-AreEqual $rule2.Definition.Actions.Snapshot $policy.Rules[1].Definition.Actions.Snapshot
Assert-AreEqual $rule2.Definition.Filters.BlobTypes[0] $policy.Rules[1].Definition.Filters.BlobTypes[0]
Assert-AreEqual $rule2.Definition.Filters.BlobTypes[1] $policy.Rules[1].Definition.Filters.BlobTypes[1]
Assert-AreEqual $rule2.Definition.Filters.PrefixMatch $policy.Rules[1].Definition.Filters.PrefixMatch
Assert-AreEqual $rule3.Enabled $policy.Rules[2].Enabled
Assert-AreEqual $rule3.Name $policy.Rules[2].Name
Assert-AreEqual $rule3.Definition.Actions.BaseBlob $policy.Rules[2].Definition.Actions.BaseBlob
Assert-AreEqual $rule3.Definition.Actions.Snapshot.Delete.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.Delete.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Snapshot.TierToCool.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.TierToCool.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Snapshot.TierToArchive.DaysAfterCreationGreaterThan $policy.Rules[2].Definition.Actions.Snapshot.TierToArchive.DaysAfterCreationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.Delete.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.Delete.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.TierToCool.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.TierToCool.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Actions.Version.TierToArchive.DaysAfterModificationGreaterThan $policy.Rules[2].Definition.Actions.Version.TierToArchive.DaysAfterModificationGreaterThan
Assert-AreEqual $rule3.Definition.Filters.BlobTypes[0] $policy.Rules[2].Definition.Filters.BlobTypes[0]
Assert-AreEqual $rule3.Definition.Filters.PrefixMatch $policy.Rules[2].Definition.Filters.PrefixMatch

$policy| Remove-AzStorageAccountManagementPolicy

Expand Down Expand Up @@ -1329,6 +1375,55 @@ function Test-NewSetAzureStorageAccount_RAGZRS
}
}

<#
.SYNOPSIS
Test Test-NewSetAzureStorageAccount_AllowSharedKeyAccess
.DESCRIPTION
SmokeTest
#>
function Test-NewSetAzureStorageAccountAllowSharedKeyAccess
{
# Setup
$rgname = Get-StorageManagementTestResourceName;

try
{
# Test
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
$loc = Get-ProviderLocation_Canary ResourceManagement;
$kind = 'StorageV2'

New-AzResourceGroup -Name $rgname -Location $loc;
Write-Output ("Resource Group created")

New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -SkuName $stotype -AllowSharedKeyAccess $false ;

Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
Assert-AreEqual $stoname $sto.StorageAccountName;
Assert-AreEqual $stotype $sto.Sku.Name;
Assert-AreEqual $loc.ToLower().Replace(" ", "") $sto.Location;
Assert-AreEqual $kind $sto.Kind;
#Assert-AreEqual $false $sto.AllowSharedKeyAccess

Set-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -AllowSharedKeyAccess $true -EnableHttpsTrafficOnly $true

Retry-IfException { $global:sto = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname; }
Assert-AreEqual $stoname $sto.StorageAccountName;
Assert-AreEqual $stotype $sto.Sku.Name;
Assert-AreEqual $loc.ToLower().Replace(" ", "") $sto.Location;
Assert-AreEqual $kind $sto.Kind;
#Assert-AreEqual $true $sto.AllowSharedKeyAccess

Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}



<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ function Test-StorageBlobContainerEncryptionScope
$stos = Get-AzStorageAccount -ResourceGroupName $rgname;

# create Scope
New-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -EncryptionScopeName $scopeName -StorageEncryption
New-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -EncryptionScopeName $scopeName -StorageEncryption -RequireInfrastructureEncryption
$scope = Get-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -EncryptionScopeName $scopeName
Assert-AreEqual $rgname $scope.ResourceGroupName
Assert-AreEqual $stoname $scope.StorageAccountName
Assert-AreEqual $scopeName $scope.Name
Assert-AreEqual "Microsoft.Storage" $scope.Source
Assert-AreEqual "Enabled" $scope.State
Assert-AreEqual $true $scope.RequireInfrastructureEncryption

# update Scope
$scope = Update-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $stoname -EncryptionScopeName $scopeName -State Disabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,12 @@ public void TestShareSoftDeletee()
{
TestController.NewInstance.RunPsTest(_logger, "Test-ShareSoftDelete");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestFileServiceProperties()
{
TestController.NewInstance.RunPsTest(_logger, "Test-FileServiceProperties");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function Test-FileServiceProperties
# Test
$stoname = 'sto' + $rgname;
$stotype = 'Premium_LRS';
$loc = Get-ProviderLocation ResourceManagement;
$loc = Get-ProviderLocation_Canary2 ResourceManagement;
$kind = 'FileStorage'

Write-Verbose "RGName: $rgname | Loc: $loc"
Expand All @@ -279,15 +279,43 @@ function Test-FileServiceProperties
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -Kind $kind
$stos = Get-AzStorageAccount -ResourceGroupName $rgname;

# Enable MC
Update-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname -EnableSmbMultichannel $true
# Enable MC, and set smb setting
Update-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname -EnableSmbMultichannel $true `
-SMBProtocolVersion SMB2.1,SMB3.0,SMB3.1.1 `
-SMBAuthenticationMethod Kerberos,NTLMv2 `
-SMBKerberosTicketEncryption RC4-HMAC,AES-256 `
-SMBChannelEncryption AES-128-CCM,AES-128-GCM,AES-256-GCM
$servicePropertie = Get-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual $true $servicePropertie.ProtocolSettings.Smb.Multichannel.Enabled

# Disable MC
Update-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname -EnableSmbMultichannel $false
Assert-AreEqual 3 $servicePropertie.ProtocolSettings.Smb.Versions.Count
Assert-AreEqual 2 $servicePropertie.ProtocolSettings.Smb.AuthenticationMethods.Count
Assert-AreEqual 2 $servicePropertie.ProtocolSettings.Smb.KerberosTicketEncryption.Count
Assert-AreEqual 3 $servicePropertie.ProtocolSettings.Smb.ChannelEncryption.Count

# Disable MC, update smb setting
Update-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname -EnableSmbMultichannel $false `
-SMBProtocolVersion SMB3.1.1 `
-SMBAuthenticationMethod Kerberos `
-SMBKerberosTicketEncryption AES-256 `
-SMBChannelEncryption AES-128-CCM
$servicePropertie = Get-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual $false $servicePropertie.ProtocolSettings.Smb.Multichannel.Enabled
Assert-AreEqual "SMB3.1.1" $servicePropertie.ProtocolSettings.Smb.Versions[0]
Assert-AreEqual "Kerberos" $servicePropertie.ProtocolSettings.Smb.AuthenticationMethods[0]
Assert-AreEqual "AES-256" $servicePropertie.ProtocolSettings.Smb.KerberosTicketEncryption[0]
Assert-AreEqual "AES-128-CCM" $servicePropertie.ProtocolSettings.Smb.ChannelEncryption[0]

# remove smb setting
Update-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname `
-SMBProtocolVersion @() `
-SMBAuthenticationMethod @()`
-SMBKerberosTicketEncryption @() `
-SMBChannelEncryption @()
$servicePropertie = Get-AzStorageFileServiceProperty -ResourceGroupName $rgname -StorageAccountName $stoname
Assert-AreEqual $false $servicePropertie.ProtocolSettings.Smb.Multichannel.Enabled
Assert-AreEqual $null $servicePropertie.ProtocolSettings.Smb.Versions
Assert-AreEqual $null $servicePropertie.ProtocolSettings.Smb.AuthenticationMethods
Assert-AreEqual $null $servicePropertie.ProtocolSettings.Smb.KerberosTicketEncryption
Assert-AreEqual $null $servicePropertie.ProtocolSettings.Smb.ChannelEncryption

Remove-AzStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
}
Expand Down
Loading

0 comments on commit ab1b3ce

Please sign in to comment.