From ca6fa7c0de76221765a659cdc17531c0de6e0e0d Mon Sep 17 00:00:00 2001 From: blueww Date: Wed, 26 Feb 2025 15:17:24 +0800 Subject: [PATCH] Update test cases with FileShareOauth, FilePV2, keyvault Fix --- .../RegressionTests/config_template.xml | 1 + src/Storage/RegressionTests/dataplane.ps1 | 117 ++++++++++++----- src/Storage/RegressionTests/srp.ps1 | 122 ++++++++++++++++-- src/Storage/RegressionTests/utils.ps1 | 1 + 4 files changed, 202 insertions(+), 39 deletions(-) diff --git a/src/Storage/RegressionTests/config_template.xml b/src/Storage/RegressionTests/config_template.xml index 36a90af18153..9320b1fd4a0d 100644 --- a/src/Storage/RegressionTests/config_template.xml +++ b/src/Storage/RegressionTests/config_template.xml @@ -70,6 +70,7 @@ placeholder + /subscriptions/{subscriptionID}/resourceGroups/{resourceGroupsName}/providers/Microsoft.KeyVault/vaults/{keyVaultName} placeholder placeholder placeholder diff --git a/src/Storage/RegressionTests/dataplane.ps1 b/src/Storage/RegressionTests/dataplane.ps1 index 8906d1dd3792..fa6ba94da398 100644 --- a/src/Storage/RegressionTests/dataplane.ps1 +++ b/src/Storage/RegressionTests/dataplane.ps1 @@ -2,9 +2,9 @@ BeforeAll { # Modify the path to your own - Import-Module .\utils.ps1 + Import-Module (get-item .\utils.ps1).FullName - [xml]$config = Get-Content .\config.xml + [xml]$config = Get-Content (get-item .\config.xml).FullName $globalNode = $config.SelectSingleNode("config/section[@id='global']") $testNode = $config.SelectSingleNode("config/section[@id='dataplane']") @@ -276,6 +276,7 @@ Describe "dataplane test" { Set-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName -AllowBlobPublicAccess $true sleep 120 # Set sleep time to 2 min to make sure AllowBlobPublicAccess becomes True + ## regression test for Fix Set-AzStorageContainerAcl can clean up the stored Access Policy New-AzStorageContainerStoredAccessPolicy -Container $containerName -Policy 123 -Permission rw -Context $ctx New-AzStorageContainerStoredAccessPolicy -Container $containerName -Policy 234 -Permission rwdl -Context $ctx @@ -1796,7 +1797,7 @@ Describe "dataplane test" { # Set-AzStorageFileContent -ShareName $containerName -Path 0size -Source C:\temp\0 -Context $ctx -force $file = Get-AzStorageFileContent -Destination $localDestFile -ShareName $shareName -Path $bigfile.ShareFileClient.Path -CheckMd5 -Context $ctx2 -force -PassThru - CompareFileFileMD5 $localDestFile $file + CompareFileFileMD5 (get-item $localDestFile).FullName $file # del $localDestFile @@ -2085,7 +2086,7 @@ Describe "dataplane test" { $localLargeSrcFile = ".\data\testfile_307200K_0" # File of size 300M. Needs to be created beforehand $localDestFile = ".\created\testoauth" # test will create the file $localDestFileName = "testoauth" - $shareName = "sharefileoauth" + $shareName = "$(GetRandomContainerName)oauth" $filename = "filefileoauth" $dirname = "dir1" $filepath = "dir1\test1" @@ -2096,9 +2097,9 @@ Describe "dataplane test" { #Add-AzAccount -ServicePrincipal -Tenant $globalNode.tenantId -SubscriptionId $globalNode.subscriptionId -Credential $cred $ctxoauth = New-AzStorageContext -StorageAccountName $accountname -EnableFileBackupRequestIntent - $ctxkey = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $accountname).Context + $ctxkey = New-AzStorageContext -StorageAccountName $accountname -StorageAccountKey (Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $accountname)[0].Value $ctxoauth2 = New-AzStorageContext -StorageAccountName $accountname2 -EnableFileBackupRequestIntent - $ctxkey2 = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $accountname2).Context + #$ctxkey2 = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $accountname2).Context New-AzStorageShare -Name $shareName -Context $ctxkey Set-AzStorageFileContent -ShareName $shareName -Source $localSrcFile -Path $filename -Context $ctxoauth -Force @@ -2109,12 +2110,40 @@ Describe "dataplane test" { $dir = $share | Get-AzStorageFile -Path $dirname $file = $share | Get-AzStorageFile -Path $filename + # share API with Oauth + $share2 = New-AzStorageShare -Name "$($shareName)2" -Context $ctxoauth + $share2.Name | should -Be "$($shareName)2" + $shares = Get-AzStorageShare -Context $ctxoauth + $shares.Count | should -BeGreaterOrEqual 2 + $count1 = $shares.Count + + $share2 = Set-AzStorageShareQuota -Name "$($shareName)2" -Context $ctxoauth -Quota 200 + $share2 = Get-AzStorageShare -Name "$($shareName)2" -Context $ctxoauth + $share2.Name | should -Be "$($shareName)2" + $share2.Quota | should -Be 200 + + New-AzStorageShareStoredAccessPolicy -Name $shareName -Context $ctxoauth -Policy 123 -Permission rw + New-AzStorageShareStoredAccessPolicy -Name $shareName -Context $ctxoauth -Policy 1234 -Permission r -StartTime (Get-Date) -ExpiryTime (Get-Date).Add(1) + set-AzStorageShareStoredAccessPolicy -Name $shareName -Context $ctxoauth -Policy 123 -Permission rwd -StartTime (Get-Date) + $policy = Get-AzStorageShareStoredAccessPolicy -Name $shareName -Context $ctxoauth + $policy.Count | should -be 2 + Remove-AzStorageShareStoredAccessPolicy -Name $shareName -Context $ctxoauth -Policy 123 + + Remove-AzStorageShare -Name "$($shareName)2" -Context $ctxoauth -Force + $share2.Name | should -Be "$($shareName)2" + $shares = Get-AzStorageShare -Context $ctxoauth + $shares.Count | should -Be ($count1-1) + + + # Set and get permission $permission = $testNode.permission - $response = $share.ShareClient.CreatePermission($permission); + $inputpermission = new-object Azure.Storage.Files.Shares.Models.ShareFilePermission + $inputpermission.Permission = $permission + $response = $share.ShareClient.CreatePermission($inputpermission); $key = $response.Value.FilePermissionKey $outputPermission = $share.ShareClient.GetPermission($key) - $outputPermission.Value | Should -Be $permission + $outputPermission.Value.Permission | Should -Be $permission # file handler $handleCount = Close-AzStorageFileHandle -ShareName $shareName -CloseAll -Context $ctxoauth -PassThru @@ -2214,7 +2243,7 @@ Describe "dataplane test" { New-AzStorageContainer -Name $shareName -Context $ctxoauth -ErrorAction SilentlyContinue $b = Set-AzStorageblobContent -Container $shareName -File $localSrcFile -blob testblob -Context $ctxoauth -Force - New-AzStorageShare -Name $shareName -Context $ctxkey2 -ErrorAction SilentlyContinue + New-AzStorageShare -Name $shareName -Context $ctxoauth2 -ErrorAction SilentlyContinue New-AzStorageDirectory -ShareName $shareName -Path dir1 -Context $ctxoauth2 -ErrorAction SilentlyContinue Set-AzStorageFileContent -ShareName $shareName -Source $localSrcFile -Path dir1/test1 -Context $ctxoauth -Force $Error.Clear() @@ -2368,25 +2397,8 @@ Describe "dataplane test" { $stopmessage = Stop-AzStorageFileCopy -ShareFileClient $fd.ShareFileClient -Context $ctxoauth -Force -ErrorAction SilentlyContinue $error[0].Exception.Message | should -BeLike "There is currently no pending copy operation*" $error.Clear() - - # should fail + $Error.Count | should -be 0 - $error.Clear() - New-AzStorageShare -Name $shareName -Context $ctxoauth -ErrorAction SilentlyContinue - Get-AzStorageShare -Context $ctxoauth -ErrorAction SilentlyContinue - Get-AzStorageShare -Name $shareName -Context $ctxoauth -ErrorAction SilentlyContinue - Remove-AzStorageShare -Name $shareName -Context $ctxoauth -Force -ErrorAction SilentlyContinue - Set-AzStorageShareQuota -Name $shareName -Quota 1024 -Context $ctxoauth -ErrorAction SilentlyContinue - New-AzStorageShareStoredAccessPolicy -ShareName $shareName -Policy 123 -Permission rw -Context $ctxoauth -ErrorAction SilentlyContinue - Set-AzStorageShareStoredAccessPolicy -ShareName $shareName -Policy 123 -Permission rw -Context $ctxoauth -ErrorAction SilentlyContinue - Get-AzStorageShareStoredAccessPolicy -ShareName $shareName -Context $ctxoauth -ErrorAction SilentlyContinue - Remove-AzStorageShareStoredAccessPolicy -ShareName $shareName -Policy 123 -Context $ctxoauth -ErrorAction SilentlyContinue - $error.Count | should -be 9 - foreach ($e in $error) - { - $e.Exception.Message | should -BeLike "*This API does not support bearer tokens. For OAuth, use the Storage Resource Provider APIs instead. Learn more: https://aka.ms/azurefiles/restapi.*" - } - $error.Clear() Set-AzStorageServiceMetricsProperty -ServiceType File -MetricsType Hour -Context $ctxoauth -ErrorAction SilentlyContinue $error[0].Exception.Message | should -BeLike "*Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.*" @@ -2408,8 +2420,9 @@ Describe "dataplane test" { $e.Exception.Message | should -BeLike "*Create File service SAS only supported with SharedKey credential.*" } $error.Clear() - - Remove-AzStorageShare -Name $shareName -Context $ctxkey -Force + + Remove-AzStorageShare -Name $shareName -Context $ctxoauth -Force + Remove-AzStorageShare -Name $shareName -Context $ctxoauth2 -Force $Error.Count | should -be 0 } @@ -2461,12 +2474,12 @@ Describe "dataplane test" { $f.Name | Should -Be "files..." $f.ShareFileClient.Path | Should -Be "test1./test2../files..." $f.ShareFileClient.Name | Should -Be "files..." - $f.Length | Should -Be 1024 + $f.Length | Should -Be (Get-Item .\data\testfile_1024K_0).Length $f = Set-AzStorageFileContent -ShareName $shareName -Path "test1./test2../files.1.." -Source .\data\testfile_10240K_0 -Context $ctx -PassThru -Force $f.Name | Should -Be "files.1.." $f.ShareFileClient.Path | Should -Be "test1./test2../files.1.." - $f.Length | Should -Be 10240 + $f.Length | Should -Be (Get-Item .\data\testfile_10240K_0).Length $f.ShareFileClient.Name | Should -Be "files.1.." # download file/dir @@ -2576,6 +2589,48 @@ Describe "dataplane test" { } + It "Storage Account Context works on both AllowSharedKeyAccess = true/false account." { + $Error.Clear() + + # with get context with sharedkey + $ctx2 = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName2).Context + + $result = Get-AzStorageContainer -Context $ctx -MaxCount 1 + $result | should -Not -Be $null + $result = Get-AzStorageShare -Context $ctx + $result | should -Not -Be $null + $result = Get-AzStorageTable -Context $ctx + $result | should -Not -Be $null + $result = Get-AzStorageQueue -Context $ctx + $result | should -Not -Be $null + + try + { + # with get context with Oauth + Set-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName2 -AllowSharedKeyAccess $false + + $ctx2 = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName2).Context + + $result = Get-AzStorageContainer -Context $ctx -MaxCount 1 + $result | should -Not -Be $null + New-AzStorageDirectory -ShareName $containerName -Path diroauthtest -Context $ctx -ErrorAction SilentlyContinue + $result = Get-AzStorageFile -ShareName $containerName -Context $ctx + $result | should -Not -Be $null + $result = Get-AzStorageTable -Context $ctx + $result | should -Not -Be $null + $result = Get-AzStorageQueue -Context $ctx + $result | should -Not -Be $null + } + catch + { + Set-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName2 -AllowSharedKeyAccess $true + throw; + } + Set-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName2 -AllowSharedKeyAccess $true + + $Error.Count | should -be 0 + } + It "Test case name" { $Error.Clear() diff --git a/src/Storage/RegressionTests/srp.ps1 b/src/Storage/RegressionTests/srp.ps1 index d1fcfb48b289..a2b3329f4a27 100644 --- a/src/Storage/RegressionTests/srp.ps1 +++ b/src/Storage/RegressionTests/srp.ps1 @@ -3,7 +3,7 @@ BeforeAll { Import-Module .\utils.ps1 - [xml]$config = Get-Content .\config.xml + [xml]$config = Get-Content (get-item .\config.xml).FullName $globalNode = $config.SelectSingleNode("config/section[@id='global']") $testNode = $config.SelectSingleNode("config/section[@id='srp']") @@ -604,11 +604,11 @@ Describe "Management plan test" { $accountNameFS = $accountName + "fs" - $account = New-AzStorageAccount -ResourceGroupName $rgname -StorageAccountName $accountNameFS -SkuName Premium_LRS -Location "westus" -Kind FileStorage -AccessTier hot -EnableHttpsTrafficOnly $false + $account = New-AzStorageAccount -ResourceGroupName $rgname -StorageAccountName $accountNameFS -SkuName Premium_LRS -Location "eastus2euap" -Kind FileStorage -AccessTier hot -EnableHttpsTrafficOnly $false $account.ResourceGroupName | should -Be $rgname $account.StorageAccountName | should -Be $accountNameFS $account.Sku.Name | should -Be "Premium_LRS" - $account.Location | should -Be "westus" + $account.Location | should -Be "eastus2euap" $account.Kind | should -Be "FileStorage" $share2 = New-AzRmStorageShare -ResourceGroupName $rgname -StorageAccountName $accountNameFS -Name testsharefs2 -AccessTier Premium @@ -621,6 +621,104 @@ Describe "Management plan test" { $share2 | Remove-AzRmStorageShare -Force + $share1 = New-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 -PaidBurstingEnabled -PaidBurstingMaxBandwidthMibps 129 -PaidBurstingMaxIops 3032 + $share1 = get-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 + $share1.FileSharePaidBursting.PaidBurstingEnabled | Should -Be $true + $share1.FileSharePaidBursting.PaidBurstingMaxIops | Should -Be 3032 + $share1.FileSharePaidBursting.PaidBurstingMaxBandwidthMibps | Should -Be 129 + Update-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 -PaidBurstingMaxBandwidthMibps 128 -PaidBurstingMaxIops 3033 + $share1 = get-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 + $share1.FileSharePaidBursting.PaidBurstingEnabled | Should -Be $true + $share1.FileSharePaidBursting.PaidBurstingMaxIops | Should -Be 3033 + $share1.FileSharePaidBursting.PaidBurstingMaxBandwidthMibps | Should -Be 128 + Update-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 -PaidBurstingEnabled $false + $share1 = get-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 + $share1.FileSharePaidBursting.PaidBurstingEnabled | Should -Be $false + $share1.FileSharePaidBursting.PaidBurstingMaxIops | Should -Be $null + $share1.FileSharePaidBursting.PaidBurstingMaxBandwidthMibps | Should -Be $null + Update-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 -PaidBurstingEnabled $true -PaidBurstingMaxBandwidthMibps 130 -PaidBurstingMaxIops 3040 + $share1 = get-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 + $share1.FileSharePaidBursting.PaidBurstingEnabled | Should -Be $true + $share1.FileSharePaidBursting.PaidBurstingMaxIops | Should -Be 3040 + $share1.FileSharePaidBursting.PaidBurstingMaxBandwidthMibps | Should -Be 130 + + $share1 | Remove-AzRmStorageShare -Force + + Remove-AzStorageAccount -ResourceGroupName $rgname -StorageAccountName $accountNameFS -Force -AsJob + + $Error.Count | should -be 0 + } + + + It "File provisionV2 Account" { + $Error.Clear() + + $accountNameFS = $accountName + "fs2" + + $account = New-AzStorageAccount -ResourceGroupName $rgname -StorageAccountName $accountNameFS -SkuName PremiumV2_LRS -Kind FileStorage -Location eastus2euap + $account.ResourceGroupName | should -Be $rgname + $account.StorageAccountName | should -Be $accountNameFS + $account.Sku.Name | should -Be "PremiumV2_LRS" + $account.Location | should -Be "eastus2euap" + $account.Kind | should -Be "FileStorage" + + # get file service usage + $usage = Get-AzStorageFileServiceUsage -ResourceGroupName $rgname -StorageAccountName $accountNameFS + $usage.ResourceGroupName | should -Be $rgname + $usage.BurstingConstantBurstFloorIops | should -BeGreaterThan 0 + $usage.BurstingConstantBurstIoScalar | should -BeGreaterThan 0 + $usage.BurstingConstantBurstTimeframeSecond | should -BeGreaterThan 0 + $usage.FileShareLimitMaxProvisionedBandwidthMiBPerSec | should -BeGreaterThan 0 + $usage.FileShareLimitMaxProvisionedIops | should -BeGreaterThan 0 + $usage.FileShareLimitMaxProvisionedStorageGiB | should -BeGreaterThan 0 + $usage.FileShareLimitMinProvisionedBandwidthMiBPerSec | should -BeGreaterThan 0 + $usage.FileShareLimitMinProvisionedIops | should -BeGreaterThan 0 + $usage.FileShareLimitMinProvisionedStorageGiB | should -BeGreaterThan 0 + $usage.FileShareRecommendationBandwidthScalar | should -BeGreaterThan 0 + $usage.FileShareRecommendationBaseBandwidthMiBPerSec | should -BeGreaterThan 0 + $usage.FileShareRecommendationBaseIops | should -BeGreaterThan 0 + $usage.FileShareRecommendationIoScalar | should -BeGreaterThan 0 + $usage.LiveShareFileShareCount | should -Be 0 + $usage.LiveShareProvisionedBandwidthMiBPerSec | should -Be 0 + $usage.LiveShareProvisionedIops | should -Be 0 + $usage.LiveShareProvisionedStorageGiB | should -Be 0 + $usage.SoftDeletedShareFileShareCount | should -Be 0 + $usage.SoftDeletedShareProvisionedBandwidthMiBPerSec | should -Be 0 + $usage.SoftDeletedShareProvisionedIops | should -Be 0 + $usage.SoftDeletedShareProvisionedStorageGiB | should -Be 0 + $usage.StorageAccountLimitMaxFileShare | should -BeGreaterThan 0 + $usage.StorageAccountLimitMaxProvisionedBandwidthMiBPerSec | should -BeGreaterThan 0 + $usage.StorageAccountLimitMaxProvisionedIops | should -BeGreaterThan 0 + $usage.StorageAccountLimitMaxProvisionedStorageGiB | should -BeGreaterThan 0 + + # new share properties + $share1 = New-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 -ProvisionedBandwidthMibps 129 -ProvisionedIops 3032 -QuotaGiB 32 + $share1 = Get-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 + $share1.ProvisionedIops | Should -Be 3032 + $share1.ProvisionedBandwidthMibps | Should -Be 129 + $share1.QuotaGiB | Should -Be 32 + $share1.NextAllowedQuotaDowngradeTime | Should -Not -Be $null + $share1.NextAllowedProvisionedIopsDowngradeTime | Should -Not -Be $null + $share1.NextAllowedProvisionedBandwidthDowngradeTime | Should -Not -Be $null + $share1.IncludedBurstIops | should -BeGreaterThan 0 + $share1.MaxBurstCreditsForIops | should -BeGreaterThan 0 + + $share1 = Update-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 -ProvisionedBandwidthMibps 130 -ProvisionedIops 3033 + $share1.ProvisionedIops | Should -Be 3033 + $share1.ProvisionedBandwidthMibps | Should -Be 130 + $share1.QuotaGiB | Should -Be 32 + $share1 = Get-AzRmStorageShare -ResourceGroupName $rgname -AccountName $accountNameFS -ShareName testsharefs1 + $share1.ProvisionedIops | Should -Be 3033 + $share1.ProvisionedBandwidthMibps | Should -Be 130 + $share1.QuotaGiB | Should -Be 32 + $share1.NextAllowedQuotaDowngradeTime | Should -Not -Be $null + $share1.NextAllowedProvisionedIopsDowngradeTime | Should -Not -Be $null + $share1.NextAllowedProvisionedBandwidthDowngradeTime | Should -Not -Be $null + $share1.IncludedBurstIops | should -BeGreaterThan 0 + $share1.MaxBurstCreditsForIops | should -BeGreaterThan 0 + + $share1 | Remove-AzRmStorageShare -Force + Remove-AzStorageAccount -ResourceGroupName $rgname -StorageAccountName $accountNameFS -Force -AsJob $Error.Count | should -be 0 @@ -789,17 +887,23 @@ Describe "Management plan test" { It "key version" { $Error.Clear() - #keyversion + ## Prepare key vault + # $keyVault = New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $location -EnablePurgeProtection + # $KeyvaultUri = $keyvault.VaultUri + # $key = Add-AzKeyVaultKey -VaultName $vaultName -Name $keyname -Destination 'Software' + # $keyversion = $key.Version + $keyVaultNode = $testNode.SelectSingleNode("keyVault[@id='1']") $vaultName = $keyVaultNode.vaultName $KeyvaultUri = $keyVaultNode.keyVaultUri $keyname = $keyVaultNode.keyName $keyversion = $keyVaultNode.keyVersion + $keyvaultId = $testNode.keyVault.SelectSingleNode("keyvaultId").'#text' $accountNameKeyV = $accountName + "kv" # Set up a new account $a = New-AzStorageAccount -ResourceGroupName $rgname -Name $accountNameKeyV -AssignIdentity -SkuName Standard_LRS -Location eastus - Set-AzKeyVaultAccessPolicy -VaultName $vaultName -ResourceGroupName $rgname -ObjectId $a.Identity.PrincipalId -PermissionsToKeys get,wrapkey,unwrapkey -BypassObjectIdValidation + New-AzRoleAssignment -ObjectID $a.Identity.PrincipalId -RoleDefinitionName "Key Vault Administrator" -Scope $keyvaultId #-debug $a = Set-AzStorageAccount -ResourceGroupName $rgname -Name $accountNameKeyV -StorageEncryption $a.Encryption.KeySource | Should -Be “Microsoft.Storage” @@ -1395,10 +1499,12 @@ Describe "Management plan test" { $KeyUri = $testNode.keyVault.SelectSingleNode("keyUri[@id='1']").'#text' $KeyUri2 = $testNode.keyVault.SelectSingleNode("keyUri[@id='2']").'#text' $KeyUri3 = $testNode.keyVault.SelectSingleNode("keyUri[@id='3']").'#text' + $vaultName = $testNode.keyVault.SelectSingleNode("vaultName").'#text' + $keyvaultId = $testNode.keyVault.SelectSingleNode("keyvaultId").'#text' # Prepare storage account $acc = New-AzStorageAccount -ResourceGroupName $rgname -Name $accountNameEncypScope -SkuName Standard_LRS -Location eastus -AssignIdentity - Set-AzKeyVaultAccessPolicy -VaultName $testNode.keyVault.vaultName -ResourceGroupName $rgname -ObjectId $acc.Identity.PrincipalId -PermissionsToKeys get,wrapkey,unwrapkey -BypassObjectIdValidation + New-AzRoleAssignment -ObjectID $acc.Identity.PrincipalId -RoleDefinitionName "Key Vault Administrator" -Scope $keyvaultId #-debug $scope = New-AzStorageEncryptionScope -ResourceGroupName $rgname -StorageAccountName $accountNameEncypScope -EncryptionScopeName $msscopename -StorageEncryption -RequireInfrastructureEncryption $scope.Name | should -be $msscopename @@ -2585,8 +2691,8 @@ Describe "Management plan test" { $accountNameVLW = $testNode.SelectSingleNode("accountName[@id='1']").'#text' ## e.g. “testaccount” $ctx = (Get-AzStorageAccount -ResourceGroupName $rgname -Name $accountNameVLW).Context - $containerNameVLW = "vlwtest" - $containerNameVLW2 = "vlwtestmigration2" + $containerNameVLW = "$(GetRandomContainerName)vlwtest" + $containerNameVLW2 = "$(GetRandomContainerName)vlwtestmigration2" $localSrcFile = "C:\temp\testfile_10240K_0" $blobname = "testvlw1" diff --git a/src/Storage/RegressionTests/utils.ps1 b/src/Storage/RegressionTests/utils.ps1 index 2bcea940d4df..ec1ed3171f99 100644 --- a/src/Storage/RegressionTests/utils.ps1 +++ b/src/Storage/RegressionTests/utils.ps1 @@ -71,6 +71,7 @@ function GetRandomAccountName function GetFileContentMD5 { param([string]$filePath) + $filePath = (Get-Item $filePath).FullName $hash = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($filePath))) return $hash }