Skip to content

Commit 9a81242

Browse files
authored
feat: Upgrade Az.* dependent modules (#439)
* update az packages * add Az.Storage to required modules * unit tests on windows * revert unit test image change * remove unnecessary code from beforeach * fix storage fileshare test * fixed api management unit tests
1 parent de395da commit 9a81242

11 files changed

Lines changed: 16 additions & 60 deletions

File tree

Binary file not shown.
0 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.ApiManagement.tests.ps1

Lines changed: 12 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
Import-Module Az.Storage
2-
Import-Module -Name $PSScriptRoot\..\Arcus.Scripting.ApiManagement -ErrorAction Stop
1+
Import-Module -Name $PSScriptRoot\..\Arcus.Scripting.ApiManagement -ErrorAction Stop
32

43
InModuleScope Arcus.Scripting.ApiManagement {
54
Describe "Arcus Azure API Management unit tests" {
65
Context "Back up Azure API Management instance" {
76
BeforeEach {
87
# Test values, not really pointing to anything
9-
$testSasToken = "?st=2013-09-03T04%3A12%3A15Z&se=2013-09-03T05%3A12%3A15Z&sr=c&sp=r&sig=fN2NPxLK99tR2%2BWnk48L3lMjutEj7nOwBo7MXs2hEV8%3D"
10-
$testEndpoint = "http://storageaccountname.blob.core.windows.net"
11-
$testConnection = [System.String]::Format("BlobEndpoint={0};QueueEndpoint={0};TableEndpoint={0};SharedAccessSignature={1}", $testEndpoint, $testSasToken)
12-
$storageAccount = [Microsoft.Azure.Storage.CloudStorageAccount]::Parse($testConnection)
13-
$expectedStorageContext = New-Object -TypeName Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext -ArgumentList $storageAccount
8+
$expectedStorageAccountName = "shopping-storage"
9+
$storageKeyValue = "mystoragekey"
10+
$expectedStorageContext = New-AzStorageContext -StorageAccountName $expectedStorageAccountName -StorageAccountKey $storageKeyValue
1411
}
1512
It "Creates storage context during API management backup" {
1613
# Arrange
1714
$resourceGroup = "shopping"
18-
$storageAccountResourceGroup = "stock"
19-
$expectedStorageAccountName = "shopping-storage"
15+
$storageAccountResourceGroup = "stock"
2016
$serviceName = "shopping-API-management"
21-
$targetContainerName = "backup-storage"
22-
$storageKeyValue = "my-storage-key"
17+
$targetContainerName = "backup-storage"
2318
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
2419
$accessType = 'SystemAssignedManagedIdentity'
2520

@@ -54,11 +49,9 @@ InModuleScope Arcus.Scripting.ApiManagement {
5449
# Arrange
5550
$resourceGroup = "shopping"
5651
$storageAccountResourceGroup = "stock"
57-
$expectedStorageAccountName = "shopping-storage"
5852
$serviceName = "shopping-API-management"
5953
$targetContainerName = "backup-storage"
6054
$targetBlobName = "backup-storage-blob"
61-
$storageKeyValue = "my-storage-key"
6255
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
6356
$accessType = 'SystemAssignedManagedIdentity'
6457

@@ -93,10 +86,8 @@ InModuleScope Arcus.Scripting.ApiManagement {
9386
# Arrange
9487
$resourceGroup = "shopping"
9588
$storageAccountResourceGroup = "stock"
96-
$expectedStorageAccountName = "shopping-storage"
9789
$serviceName = "shopping-API-management"
9890
$targetContainerName = "backup-storage"
99-
$storageKeyValue = "my-storage-key"
10091
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
10192
$accessType = 'SystemAssignedManagedIdentity'
10293

@@ -131,10 +122,8 @@ InModuleScope Arcus.Scripting.ApiManagement {
131122
# Arrange
132123
$resourceGroup = "shopping"
133124
$storageAccountResourceGroup = "stock"
134-
$expectedStorageAccountName = "shopping-storage"
135125
$serviceName = "shopping-API-management"
136126
$targetContainerName = "backup-storage"
137-
$storageKeyValue = "my-storage-key"
138127
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
139128
$defaultProfile = New-Object -TypeName Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile
140129
$accessType = 'SystemAssignedManagedIdentity'
@@ -170,10 +159,8 @@ InModuleScope Arcus.Scripting.ApiManagement {
170159
# Arrange
171160
$resourceGroup = "shopping"
172161
$storageAccountResourceGroup = "stock"
173-
$expectedStorageAccountName = "shopping-storage"
174162
$serviceName = "shopping-API-management"
175163
$targetContainerName = "backup-storage"
176-
$storageKeyValue = "my-storage-key"
177164
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
178165
$accessType = 'UserAssignedManagedIdentity'
179166
$identityClientId = 'someidentityid'
@@ -788,24 +775,21 @@ InModuleScope Arcus.Scripting.ApiManagement {
788775
}
789776
}
790777
Context "Restore Azure API Management instance" {
778+
BeforeEach {
779+
# Test values, not really pointing to anything
780+
$expectedStorageAccountName = "shopping-storage"
781+
$storageKeyValue = "mystoragekey"
782+
$expectedStorageContext = New-AzStorageContext -StorageAccountName $expectedStorageAccountName -StorageAccountKey $storageKeyValue
783+
}
791784
It "Restores API management service w/o pass thru and profile" {
792785
# Arrange
793786
$resourceGroup = "shopping"
794787
$storageAccountResourceGroup = "stock"
795-
$expectedStorageAccountName = "shopping-storage"
796788
$serviceName = "shopping-API-management"
797789
$containerName = "backup-storage"
798790
$blobName = "backup-storage-blob"
799-
$storageKeyValue = "my-storage-key"
800791
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
801792

802-
# Test values, not really pointing to anything
803-
$testSasToken = "?st=2013-09-03T04%3A12%3A15Z&se=2013-09-03T05%3A12%3A15Z&sr=c&sp=r&sig=fN2NPxLK99tR2%2BWnk48L3lMjutEj7nOwBo7MXs2hEV8%3D"
804-
$testEndpoint = "http://storageaccountname.blob.core.windows.net"
805-
$testConnection = [System.String]::Format("BlobEndpoint={0};QueueEndpoint={0};TableEndpoint={0};SharedAccessSignature={1}", $testEndpoint, $testSasToken)
806-
$storageAccount = [Microsoft.Azure.Storage.CloudStorageAccount]::Parse($testConnection)
807-
$expectedStorageContext = New-Object -TypeName Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext -ArgumentList $storageAccount
808-
809793
Mock Get-AzStorageAccountKey {
810794
$ResourceGroupName | Should -Be $storageAccountResourceGroup
811795
$StorageAccountName | Should -Be $expectedStorageAccountName
@@ -836,20 +820,11 @@ InModuleScope Arcus.Scripting.ApiManagement {
836820
# Arrange
837821
$resourceGroup = "shopping"
838822
$storageAccountResourceGroup = "stock"
839-
$expectedStorageAccountName = "shopping-storage"
840823
$serviceName = "shopping-API-management"
841824
$containerName = "backup-storage"
842825
$blobName = "backup-storage-blob"
843-
$storageKeyValue = "my-storage-key"
844826
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
845827

846-
# Test values, not really pointing to anything
847-
$testSasToken = "?st=2013-09-03T04%3A12%3A15Z&se=2013-09-03T05%3A12%3A15Z&sr=c&sp=r&sig=fN2NPxLK99tR2%2BWnk48L3lMjutEj7nOwBo7MXs2hEV8%3D"
848-
$testEndpoint = "http://storageaccountname.blob.core.windows.net"
849-
$testConnection = [System.String]::Format("BlobEndpoint={0};QueueEndpoint={0};TableEndpoint={0};SharedAccessSignature={1}", $testEndpoint, $testSasToken)
850-
$storageAccount = [Microsoft.Azure.Storage.CloudStorageAccount]::Parse($testConnection)
851-
$expectedStorageContext = New-Object -TypeName Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext -ArgumentList $storageAccount
852-
853828
Mock Get-AzStorageAccountKey {
854829
$ResourceGroupName | Should -Be $storageAccountResourceGroup
855830
$StorageAccountName | Should -Be $expectedStorageAccountName
@@ -880,21 +855,12 @@ InModuleScope Arcus.Scripting.ApiManagement {
880855
# Arrange
881856
$resourceGroup = "shopping"
882857
$storageAccountResourceGroup = "stock"
883-
$expectedStorageAccountName = "shopping-storage"
884858
$serviceName = "shopping-API-management"
885859
$containerName = "backup-storage"
886860
$blobName = "backup-storage-blob"
887-
$storageKeyValue = "my-storage-key"
888861
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
889862
$defaultProfile = New-Object -TypeName Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile
890863

891-
# Test values, not really pointing to anything
892-
$testSasToken = "?st=2013-09-03T04%3A12%3A15Z&se=2013-09-03T05%3A12%3A15Z&sr=c&sp=r&sig=fN2NPxLK99tR2%2BWnk48L3lMjutEj7nOwBo7MXs2hEV8%3D"
893-
$testEndpoint = "http://storageaccountname.blob.core.windows.net"
894-
$testConnection = [System.String]::Format("BlobEndpoint={0};QueueEndpoint={0};TableEndpoint={0};SharedAccessSignature={1}", $testEndpoint, $testSasToken)
895-
$storageAccount = [Microsoft.Azure.Storage.CloudStorageAccount]::Parse($testConnection)
896-
$expectedStorageContext = New-Object -TypeName Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext -ArgumentList $storageAccount
897-
898864
Mock Get-AzStorageAccountKey {
899865
$ResourceGroupName | Should -Be $storageAccountResourceGroup
900866
$StorageAccountName | Should -Be $expectedStorageAccountName
@@ -925,21 +891,12 @@ InModuleScope Arcus.Scripting.ApiManagement {
925891
# Arrange
926892
$resourceGroup = "shopping"
927893
$storageAccountResourceGroup = "stock"
928-
$expectedStorageAccountName = "shopping-storage"
929894
$serviceName = "shopping-API-management"
930895
$containerName = "backup-storage"
931896
$blobName = "backup-storage-blob"
932-
$storageKeyValue = "my-storage-key"
933897
$storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null)
934898
$defaultProfile = New-Object -TypeName Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile
935899

936-
# Test values, not really pointing to anything
937-
$testSasToken = "?st=2013-09-03T04%3A12%3A15Z&se=2013-09-03T05%3A12%3A15Z&sr=c&sp=r&sig=fN2NPxLK99tR2%2BWnk48L3lMjutEj7nOwBo7MXs2hEV8%3D"
938-
$testEndpoint = "http://storageaccountname.blob.core.windows.net"
939-
$testConnection = [System.String]::Format("BlobEndpoint={0};QueueEndpoint={0};TableEndpoint={0};SharedAccessSignature={1}", $testEndpoint, $testSasToken)
940-
$storageAccount = [Microsoft.Azure.Storage.CloudStorageAccount]::Parse($testConnection)
941-
$expectedStorageContext = New-Object -TypeName Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext -ArgumentList $storageAccount
942-
943900
Mock Get-AzStorageAccountKey {
944901
$ResourceGroupName | Should -Be $storageAccountResourceGroup
945902
$StorageAccountName | Should -Be $expectedStorageAccountName

0 commit comments

Comments
 (0)