|
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 |
3 | 2 |
|
4 | 3 | InModuleScope Arcus.Scripting.ApiManagement { |
5 | 4 | Describe "Arcus Azure API Management unit tests" { |
6 | 5 | Context "Back up Azure API Management instance" { |
7 | 6 | BeforeEach { |
8 | 7 | # 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 |
14 | 11 | } |
15 | 12 | It "Creates storage context during API management backup" { |
16 | 13 | # Arrange |
17 | 14 | $resourceGroup = "shopping" |
18 | | - $storageAccountResourceGroup = "stock" |
19 | | - $expectedStorageAccountName = "shopping-storage" |
| 15 | + $storageAccountResourceGroup = "stock" |
20 | 16 | $serviceName = "shopping-API-management" |
21 | | - $targetContainerName = "backup-storage" |
22 | | - $storageKeyValue = "my-storage-key" |
| 17 | + $targetContainerName = "backup-storage" |
23 | 18 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
24 | 19 | $accessType = 'SystemAssignedManagedIdentity' |
25 | 20 |
|
@@ -54,11 +49,9 @@ InModuleScope Arcus.Scripting.ApiManagement { |
54 | 49 | # Arrange |
55 | 50 | $resourceGroup = "shopping" |
56 | 51 | $storageAccountResourceGroup = "stock" |
57 | | - $expectedStorageAccountName = "shopping-storage" |
58 | 52 | $serviceName = "shopping-API-management" |
59 | 53 | $targetContainerName = "backup-storage" |
60 | 54 | $targetBlobName = "backup-storage-blob" |
61 | | - $storageKeyValue = "my-storage-key" |
62 | 55 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
63 | 56 | $accessType = 'SystemAssignedManagedIdentity' |
64 | 57 |
|
@@ -93,10 +86,8 @@ InModuleScope Arcus.Scripting.ApiManagement { |
93 | 86 | # Arrange |
94 | 87 | $resourceGroup = "shopping" |
95 | 88 | $storageAccountResourceGroup = "stock" |
96 | | - $expectedStorageAccountName = "shopping-storage" |
97 | 89 | $serviceName = "shopping-API-management" |
98 | 90 | $targetContainerName = "backup-storage" |
99 | | - $storageKeyValue = "my-storage-key" |
100 | 91 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
101 | 92 | $accessType = 'SystemAssignedManagedIdentity' |
102 | 93 |
|
@@ -131,10 +122,8 @@ InModuleScope Arcus.Scripting.ApiManagement { |
131 | 122 | # Arrange |
132 | 123 | $resourceGroup = "shopping" |
133 | 124 | $storageAccountResourceGroup = "stock" |
134 | | - $expectedStorageAccountName = "shopping-storage" |
135 | 125 | $serviceName = "shopping-API-management" |
136 | 126 | $targetContainerName = "backup-storage" |
137 | | - $storageKeyValue = "my-storage-key" |
138 | 127 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
139 | 128 | $defaultProfile = New-Object -TypeName Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile |
140 | 129 | $accessType = 'SystemAssignedManagedIdentity' |
@@ -170,10 +159,8 @@ InModuleScope Arcus.Scripting.ApiManagement { |
170 | 159 | # Arrange |
171 | 160 | $resourceGroup = "shopping" |
172 | 161 | $storageAccountResourceGroup = "stock" |
173 | | - $expectedStorageAccountName = "shopping-storage" |
174 | 162 | $serviceName = "shopping-API-management" |
175 | 163 | $targetContainerName = "backup-storage" |
176 | | - $storageKeyValue = "my-storage-key" |
177 | 164 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
178 | 165 | $accessType = 'UserAssignedManagedIdentity' |
179 | 166 | $identityClientId = 'someidentityid' |
@@ -788,24 +775,21 @@ InModuleScope Arcus.Scripting.ApiManagement { |
788 | 775 | } |
789 | 776 | } |
790 | 777 | 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 | + } |
791 | 784 | It "Restores API management service w/o pass thru and profile" { |
792 | 785 | # Arrange |
793 | 786 | $resourceGroup = "shopping" |
794 | 787 | $storageAccountResourceGroup = "stock" |
795 | | - $expectedStorageAccountName = "shopping-storage" |
796 | 788 | $serviceName = "shopping-API-management" |
797 | 789 | $containerName = "backup-storage" |
798 | 790 | $blobName = "backup-storage-blob" |
799 | | - $storageKeyValue = "my-storage-key" |
800 | 791 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
801 | 792 |
|
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 | | - |
809 | 793 | Mock Get-AzStorageAccountKey { |
810 | 794 | $ResourceGroupName | Should -Be $storageAccountResourceGroup |
811 | 795 | $StorageAccountName | Should -Be $expectedStorageAccountName |
@@ -836,20 +820,11 @@ InModuleScope Arcus.Scripting.ApiManagement { |
836 | 820 | # Arrange |
837 | 821 | $resourceGroup = "shopping" |
838 | 822 | $storageAccountResourceGroup = "stock" |
839 | | - $expectedStorageAccountName = "shopping-storage" |
840 | 823 | $serviceName = "shopping-API-management" |
841 | 824 | $containerName = "backup-storage" |
842 | 825 | $blobName = "backup-storage-blob" |
843 | | - $storageKeyValue = "my-storage-key" |
844 | 826 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
845 | 827 |
|
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 | | - |
853 | 828 | Mock Get-AzStorageAccountKey { |
854 | 829 | $ResourceGroupName | Should -Be $storageAccountResourceGroup |
855 | 830 | $StorageAccountName | Should -Be $expectedStorageAccountName |
@@ -880,21 +855,12 @@ InModuleScope Arcus.Scripting.ApiManagement { |
880 | 855 | # Arrange |
881 | 856 | $resourceGroup = "shopping" |
882 | 857 | $storageAccountResourceGroup = "stock" |
883 | | - $expectedStorageAccountName = "shopping-storage" |
884 | 858 | $serviceName = "shopping-API-management" |
885 | 859 | $containerName = "backup-storage" |
886 | 860 | $blobName = "backup-storage-blob" |
887 | | - $storageKeyValue = "my-storage-key" |
888 | 861 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
889 | 862 | $defaultProfile = New-Object -TypeName Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile |
890 | 863 |
|
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 | | - |
898 | 864 | Mock Get-AzStorageAccountKey { |
899 | 865 | $ResourceGroupName | Should -Be $storageAccountResourceGroup |
900 | 866 | $StorageAccountName | Should -Be $expectedStorageAccountName |
@@ -925,21 +891,12 @@ InModuleScope Arcus.Scripting.ApiManagement { |
925 | 891 | # Arrange |
926 | 892 | $resourceGroup = "shopping" |
927 | 893 | $storageAccountResourceGroup = "stock" |
928 | | - $expectedStorageAccountName = "shopping-storage" |
929 | 894 | $serviceName = "shopping-API-management" |
930 | 895 | $containerName = "backup-storage" |
931 | 896 | $blobName = "backup-storage-blob" |
932 | | - $storageKeyValue = "my-storage-key" |
933 | 897 | $storageKey = New-Object -TypeName Microsoft.Azure.Management.Storage.Models.StorageAccountKey -ArgumentList @($null, $storageKeyValue, $null) |
934 | 898 | $defaultProfile = New-Object -TypeName Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile |
935 | 899 |
|
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 | | - |
943 | 900 | Mock Get-AzStorageAccountKey { |
944 | 901 | $ResourceGroupName | Should -Be $storageAccountResourceGroup |
945 | 902 | $StorageAccountName | Should -Be $expectedStorageAccountName |
|
0 commit comments