Skip to content

Commit 6fabc52

Browse files
committed
Merge pull request Azure#83 from YuhuiZhong/kvga
Azure Key Vault data plane PowerShell GA update
2 parents 5f61df5 + b421b85 commit 6fabc52

File tree

65 files changed

+2188
-3334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2188
-3334
lines changed

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@
269269
<Component Id="cmpBA50088476D481806FA8A46CA2C5CEBE" Guid="*">
270270
<File Id="fil21E8691D4482B7702FD47A93501119F7" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\KeyVault\Microsoft.Azure.Common.NetFramework.dll" />
271271
</Component>
272+
<Component Id="cmpB82229C2B56084C7D51CD9617D9CAB2A" Guid="*">
273+
<File Id="fil0A15B10C4F3079CC04D78EDDF82DB5DD" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\KeyVault\Microsoft.Azure.KeyVault.dll" />
274+
</Component>
272275
<Component Id="cmpE98C5E961AE569F1BB93B80CA0520B55" Guid="*">
273276
<File Id="fil0E05BBFC00F0DB47B28ABE41B41B5609" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\KeyVault\Microsoft.Azure.ResourceManager.dll" />
274277
</Component>
@@ -2515,6 +2518,7 @@
25152518
<ComponentRef Id="cmpDC57306B3AFF355EE5DFF7378BD06B5D" />
25162519
<ComponentRef Id="cmp06B1E73DD89C32A6359580BBC00FA199" />
25172520
<ComponentRef Id="cmpBA50088476D481806FA8A46CA2C5CEBE" />
2521+
<ComponentRef Id="cmpB82229C2B56084C7D51CD9617D9CAB2A" />
25182522
<ComponentRef Id="cmpE98C5E961AE569F1BB93B80CA0520B55" />
25192523
<ComponentRef Id="cmp23368001E71D590284E662F949393266" />
25202524
<ComponentRef Id="cmp8885D62E14E2D7967F6F1C56F44E4821" />

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Commands.KeyVault.Test.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
<Reference Include="Microsoft.Azure.Common.Authentication">
6060
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.22-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
6161
</Reference>
62+
<Reference Include="Microsoft.Azure.KeyVault, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
63+
<SpecificVersion>False</SpecificVersion>
64+
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.0.9.0-preview\lib\net45\Microsoft.Azure.KeyVault.dll</HintPath>
65+
</Reference>
6266
<Reference Include="Microsoft.Azure.Common.NetFramework">
6367
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
6468
</Reference>
@@ -128,7 +132,8 @@
128132
<Compile Include="UnitTests\KeyVaultUnitTestBase.cs" />
129133
<Compile Include="UnitTests\RemoveKeyVaultKeyTests.cs" />
130134
<Compile Include="UnitTests\RemoveKeyVaultSecretTests.cs" />
131-
<Compile Include="UnitTests\SetKeyVaultKeyTests.cs" />
135+
<Compile Include="UnitTests\SetKeyVaultKeyAttributeTests.cs" />
136+
<Compile Include="UnitTests\SetKeyVaultSecretAttributeTests.cs" />
132137
<Compile Include="UnitTests\SetKeyVaultSecretTests.cs" />
133138
</ItemGroup>
134139
<ItemGroup>

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Models/UtilitiesTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.KeyVault.Client;
1615
using Microsoft.Azure.Commands.KeyVault.Models;
17-
using Microsoft.Azure.Commands.KeyVault.WebKey;
16+
using Microsoft.Azure.KeyVault.WebKey;
1817
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1918
using System;
2019
using System.IO;

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Scripts/Common.ps1

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,57 @@ function Write-ConsoleReport
261261
Write-Host -ForegroundColor Green "Start Time: $global:startTime"
262262
Write-Host -ForegroundColor Green "End Time: $global:endTime"
263263
Write-Host -ForegroundColor Green "Elapsed: "($global:endTime - $global:startTime).ToString()
264-
}
264+
}
265+
266+
function Equal-DateTime($left, $right)
267+
{
268+
if ($left -eq $null -and $right -eq $null)
269+
{
270+
return $true
271+
}
272+
if ($left -eq $null -or $right -eq $null)
273+
{
274+
return $false
275+
}
276+
277+
return (($left - $right).Duration() -le $delta)
278+
}
279+
280+
function Equal-Hashtable($left, $right)
281+
{
282+
if ((EmptyOrNullHashtable $left) -and (-Not (EmptyOrNullHashtable $right)))
283+
{
284+
return $false
285+
}
286+
if ((EmptyOrNullHashtable $right) -and (-Not (EmptyOrNullHashtable $left)))
287+
{
288+
return $false
289+
}
290+
if ($right.Count -ne $left.Count)
291+
{
292+
return $false
293+
}
294+
295+
return $true
296+
}
297+
298+
function EmptyOrNullHashtable($hashtable)
299+
{
300+
return ($hashtable -eq $null -or $hashtable.Count -eq 0)
301+
}
302+
303+
function Equal-OperationList($left, $right)
304+
{
305+
if ($left -eq $null -and $right -eq $null)
306+
{
307+
return $true
308+
}
309+
if ($left -eq $null -or $right -eq $null)
310+
{
311+
return $false
312+
}
313+
314+
$diff = Compare-Object -ReferenceObject $left -DifferenceObject $right -PassThru
315+
316+
return (-not $diff)
317+
}

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Scripts/RunKeyVaultTests.ps1

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ Run-TestProtected { Run-KeyTest {Test_CreateKeyInNonExistVault} "Test_CreateKeyI
9393
Run-TestProtected { Run-KeyTest {Test_ImportByokAsSoftwareKey} "Test_ImportByokAsSoftwareKey" } "Test_ImportByokAsSoftwareKey"
9494
Run-TestProtected { Run-KeyTest {Test_CreateKeyInNoPermissionVault} "Test_CreateKeyInNoPermissionVault" } "Test_CreateKeyInNoPermissionVault"
9595

96-
# Set-AzureKeyVaultKey tests
97-
Run-TestProtected { Run-KeyTest {Test_UpdateIndividualAttributes} "Test_UpdateIndividualAttributes" } "Test_UpdateIndividualAttributes"
98-
Run-TestProtected { Run-KeyTest {Test_UpdateAllEditableAttributes} "Test_UpdateAllEditableAttributes" } "Test_UpdateAllEditableAttributes"
96+
# Set-AzureKeyVaultKeyAttribute tests
97+
Run-TestProtected { Run-KeyTest {Test_UpdateIndividualKeyAttributes} "Test_UpdateIndividualKeyAttributes" } "Test_UpdateIndividualKeyAttributes"
98+
Run-TestProtected { Run-KeyTest {Test_UpdateAllEditableKeyAttributes} "Test_UpdateAllEditableKeyAttributes" } "Test_UpdateAllEditableKeyAttributes"
9999
Run-TestProtected { Run-KeyTest {Test_UpdateKeyWithNoChange} "Test_UpdateKeyWithNoChange" } "Test_UpdateKeyWithNoChange"
100100
Run-TestProtected { Run-KeyTest {Test_SetKeyPositionalParameter} "Test_SetKeyPositionalParameter" } "Test_SetKeyPositionalParameter"
101101
Run-TestProtected { Run-KeyTest {Test_SetKeyAliasParameter} "Test_SetKeyAliasParameter" } "Test_SetKeyAliasParameter"
102+
Run-TestProtected { Run-KeyTest {Test_SetKeyVersion} "Test_SetKeyVersion" } "Test_SetKeyVersion"
102103
Run-TestProtected { Run-KeyTest {Test_SetKeyInNonExistVault} "Test_SetKeyInNonExistVault" } "Test_SetKeyInNonExistVault"
103104
Run-TestProtected { Run-KeyTest {Test_SetNonExistKey} "Test_SetNonExistKey" } "Test_SetNonExistKey"
104-
Run-TestProtected { Run-KeyTest {Test_SetInvalidAttributes} "Test_SetInvalidAttributes" } "Test_SetInvalidAttributes"
105+
Run-TestProtected { Run-KeyTest {Test_SetInvalidKeyAttributes} "Test_SetInvalidKeyAttributes" } "Test_SetInvalidKeyAttributes"
105106
Run-TestProtected { Run-KeyTest {Test_SetKeyInNoPermissionVault} "Test_SetKeyInNoPermissionVault" } "Test_SetKeyInNoPermissionVault"
106107

107108
# Get-AzureKeyVaultKey tests
108109
Run-TestProtected { Run-KeyTest {Test_GetOneKey} "Test_GetOneKey" } "Test_GetOneKey"
109-
Run-TestProtected { Run-KeyTest {Test_GetAllKeys} "Test_GetAllKeys" } "Test_GetAllKeys"
110110
Run-TestProtected { Run-KeyTest {Test_GetPreviousVersionOfKey} "Test_GetPreviousVersionOfKey" } "Test_GetPreviousVersionOfKey"
111111
Run-TestProtected { Run-KeyTest {Test_GetKeyPositionalParameter} "Test_GetKeyPositionalParameter" } "Test_GetKeyPositionalParameter"
112112
Run-TestProtected { Run-KeyTest {Test_GetKeyAliasParameter} "Test_GetKeyAliasParameter" } "Test_GetKeyAliasParameter"
@@ -133,20 +133,36 @@ Run-TestProtected { Run-KeyTest {Test_RestoreFromNonExistingFile} "Test_RestoreF
133133
# *-AzureKeyVaultKey pipeline tests
134134
Run-TestProtected { Run-KeyTest {Test_PipelineUpdateKeys} "Test_PipelineUpdateKeys" } "Test_PipelineUpdateKeys"
135135
Run-TestProtected { Run-KeyTest {Test_PipelineRemoveKeys} "Test_PipelineRemoveKeys" } "Test_PipelineRemoveKeys"
136+
Run-TestProtected { Run-KeyTest {Test_PipelineUpdateKeyVersions} "Test_PipelineUpdateKeyVersions" } "Test_PipelineUpdateKeyVersions"
136137

137138

138139
# Set-AzureKeyVaultSecret tests
139140
Run-TestProtected { Run-SecretTest {Test_CreateSecret} "Test_CreateSecret" } "Test_CreateSecret"
141+
Run-TestProtected { Run-SecretTest {Test_CreateSecretWithCustomAttributes} "Test_CreateSecretWithCustomAttributes" } "Test_CreateSecretWithCustomAttributes"
140142
Run-TestProtected { Run-SecretTest {Test_UpdateSecret} "Test_UpdateSecret" } "Test_UpdateSecret"
143+
141144
Run-TestProtected { Run-SecretTest {Test_SetSecretPositionalParameter} "Test_SetSecretPositionalParameter" } "Test_SetSecretPositionalParameter"
142145
Run-TestProtected { Run-SecretTest {Test_SetSecretAliasParameter} "Test_SetSecretAliasParameter" } "Test_SetSecretAliasParameter"
143146
Run-TestProtected { Run-SecretTest {Test_SetSecretInNonExistVault} "Test_SetSecretInNonExistVault" } "Test_SetSecretInNonExistVault"
144147
Run-TestProtected { Run-SecretTest {Test_SetSecretInNoPermissionVault} "Test_SetSecretInNoPermissionVault" } "Test_SetSecretInNoPermissionVault"
145148

149+
# Set-AzureKeyVaultSecretAttribute tests
150+
Run-TestProtected { Run-SecretTest {Test_UpdateIndividualSecretAttributes} "Test_UpdateIndividualSecretAttributes" } "Test_UpdateIndividualSecretAttributes"
151+
Run-TestProtected { Run-SecretTest {Test_UpdateSecretWithNoChange} "Test_UpdateSecretWithNoChange" } "Test_UpdateSecretWithNoChange"
152+
Run-TestProtected { Run-SecretTest {Test_UpdateAllEditableSecretAttributes} "Test_UpdateAllEditableSecretAttributes" } "Test_UpdateAllEditableSecretAttributes"
153+
Run-TestProtected { Run-SecretTest {Test_SetSecretAttributePositionalParameter} "Test_SetSecretAttributePositionalParameter" } "Test_SetSecretAttributePositionalParameter"
154+
Run-TestProtected { Run-SecretTest {Test_SetSecretAttributeAliasParameter} "Test_SetSecretAttributeAliasParameter" } "Test_SetSecretAttributeAliasParameter"
155+
Run-TestProtected { Run-SecretTest {Test_SetSecretVersion} "Test_SetSecretVersion" } "Test_SetSecretVersion"
156+
Run-TestProtected { Run-SecretTest {Test_SetSecretInNonExistVault} "Test_SetSecretInNonExistVault" } "Test_SetSecretInNonExistVault"
157+
Run-TestProtected { Run-SecretTest {Test_SetNonExistSecret} "Test_SetNonExistSecret" } "Test_SetNonExistSecret"
158+
Run-TestProtected { Run-SecretTest {Test_SetInvalidSecretAttributes} "Test_SetInvalidSecretAttributes" } "Test_SetInvalidSecretAttributes"
159+
Run-TestProtected { Run-SecretTest {Test_SetSecretAttrInNoPermissionVault} "Test_SetSecretAttrInNoPermissionVault" } "Test_SetSecretAttrInNoPermissionVault"
160+
146161
# Get-AzureKeyVaultSecret tests
147162
Run-TestProtected { Run-SecretTest {Test_GetOneSecret} "Test_GetOneSecret" } "Test_GetOneSecret"
148163
Run-TestProtected { Run-SecretTest {Test_GetAllSecrets} "Test_GetAllSecrets" } "Test_GetAllSecrets"
149164
Run-TestProtected { Run-SecretTest {Test_GetPreviousVersionOfSecret} "Test_GetPreviousVersionOfSecret" } "Test_GetPreviousVersionOfSecret"
165+
Run-TestProtected { Run-SecretTest {Test_GetSecretVersions} "Test_GetSecretVersions" } "Test_GetSecretVersions"
150166
Run-TestProtected { Run-SecretTest {Test_GetSecretPositionalParameter} "Test_GetSecretPositionalParameter" } "Test_GetSecretPositionalParameter"
151167
Run-TestProtected { Run-SecretTest {Test_GetSecretAliasParameter} "Test_GetSecretAliasParameter" } "Test_GetSecretAliasParameter"
152168
Run-TestProtected { Run-SecretTest {Test_GetSecretInNonExistVault} "Test_GetSecretInNonExistVault" } "Test_GetSecretInNonExistVault"
@@ -164,6 +180,8 @@ Run-TestProtected { Run-SecretTest {Test_RemoveSecretInNoPermissionVault} "Test_
164180

165181
# *-AzureKeyVaultKey pipeline tests
166182
Run-TestProtected { Run-SecretTest {Test_PipelineUpdateSecrets} "Test_PipelineUpdateSecrets" } "Test_PipelineUpdateSecrets"
183+
Run-TestProtected { Run-SecretTest {Test_PipelineUpdateSecretAttributes} "Test_PipelineUpdateSecretAttributes" } "Test_PipelineUpdateSecretAttributes"
184+
Run-TestProtected { Run-SecretTest {Test_PipelineUpdateSecretVersions} "Test_PipelineUpdateSecretVersions" } "Test_PipelineUpdateSecretVersions"
167185
Run-TestProtected { Run-SecretTest {Test_PipelineRemoveSecrets} "Test_PipelineRemoveSecrets" } "Test_PipelineRemoveSecrets"
168186

169187
$global:endTime = Get-Date
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Param(
2+
[Parameter(Mandatory=$True,Position=0)]
3+
[ValidateSet('BVT','PROD')]
4+
[string]$testenv,
5+
[Parameter(Mandatory=$True,Position=1)]
6+
[string]$testns
7+
)
8+
9+
$invocationPath = Split-Path $MyInvocation.MyCommand.Definition;
10+
. (Join-Path $invocationPath "PSHCommon\Common.ps1");
11+
. (Join-Path $invocationPath "PSHCommon\Assert.ps1");
12+
. (Join-Path $invocationPath "Common.ps1");
13+
. (Join-Path $invocationPath "VaultKeyTests.ps1");
14+
. (Join-Path $invocationPath "VaultSecretTests.ps1");
15+
16+
$global:totalCount = 0;
17+
$global:passedCount = 0;
18+
$global:passedTests = @()
19+
$global:failedTests = @()
20+
$global:times = @{}
21+
$global:testEnv = $testenv.ToUpperInvariant()
22+
$global:testns = $testns
23+
24+
function Run-TestProtected
25+
{
26+
param([ScriptBlock]$script, [string] $testName)
27+
$testStart = Get-Date
28+
try
29+
{
30+
Write-Host -ForegroundColor Green =====================================
31+
Write-Host -ForegroundColor Green "Running test $testName"
32+
Write-Host -ForegroundColor Green =====================================
33+
Write-Host
34+
&$script
35+
$global:passedCount = $global:passedCount + 1
36+
Write-Host
37+
Write-Host -ForegroundColor Green =====================================
38+
Write-Host -ForegroundColor Green "Test Passed"
39+
Write-Host -ForegroundColor Green =====================================
40+
Write-Host
41+
$global:passedTests += $testName
42+
}
43+
catch
44+
{
45+
Out-String -InputObject $_.Exception | Write-Host -ForegroundColor Red
46+
Write-Host
47+
Write-Host -ForegroundColor Red =====================================
48+
Write-Host -ForegroundColor Red "Test Failed"
49+
Write-Host -ForegroundColor Red =====================================
50+
Write-Host
51+
$global:failedTests += $testName
52+
}
53+
finally
54+
{
55+
$testEnd = Get-Date
56+
$testElapsed = $testEnd - $testStart
57+
$global:times[$testName] = $testElapsed
58+
$global:totalCount = $global:totalCount + 1
59+
}
60+
}
61+
62+
# Initialize
63+
Write-Host Delete log files
64+
Cleanup-Log $invocationPath
65+
66+
$testkeyVault = Get-KeyVault
67+
Write-Host Test key vault is $testKeyVault
68+
Write-Host Initializing Key Tests
69+
Initialize-KeyTest
70+
Write-Host Initializing Secret Tests
71+
Initialize-SecretTest
72+
Write-Host Initialization Completed
73+
74+
$global:startTime = Get-Date
75+
76+
# Get-AzureKeyVaultKey tests
77+
Run-TestProtected { Run-KeyTest {Test_GetKeyVersions} "Test_GetKeyVersions" } "Test_GetKeyVersions"
78+
79+
80+
$global:endTime = Get-Date
81+
82+
# Report
83+
Write-FileReport
84+
Write-ConsoleReport
85+
86+
87+
# Post run
88+
Move-Log $invocationPath
89+
90+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Param(
2+
[Parameter(Mandatory=$True,Position=0)]
3+
[ValidateSet('BVT','PROD')]
4+
[string]$testenv,
5+
[Parameter(Mandatory=$True,Position=1)]
6+
[string]$testns
7+
)
8+
9+
$invocationPath = Split-Path $MyInvocation.MyCommand.Definition;
10+
. (Join-Path $invocationPath "PSHCommon\Common.ps1");
11+
. (Join-Path $invocationPath "PSHCommon\Assert.ps1");
12+
. (Join-Path $invocationPath "Common.ps1");
13+
. (Join-Path $invocationPath "VaultKeyTests.ps1");
14+
. (Join-Path $invocationPath "VaultSecretTests.ps1");
15+
16+
$global:totalCount = 0;
17+
$global:passedCount = 0;
18+
$global:passedTests = @()
19+
$global:failedTests = @()
20+
$global:times = @{}
21+
$global:testEnv = $testenv.ToUpperInvariant()
22+
$global:testns = $testns
23+
24+
function Run-TestProtected
25+
{
26+
param([ScriptBlock]$script, [string] $testName)
27+
$testStart = Get-Date
28+
try
29+
{
30+
Write-Host -ForegroundColor Green =====================================
31+
Write-Host -ForegroundColor Green "Running test $testName"
32+
Write-Host -ForegroundColor Green =====================================
33+
Write-Host
34+
&$script
35+
$global:passedCount = $global:passedCount + 1
36+
Write-Host
37+
Write-Host -ForegroundColor Green =====================================
38+
Write-Host -ForegroundColor Green "Test Passed"
39+
Write-Host -ForegroundColor Green =====================================
40+
Write-Host
41+
$global:passedTests += $testName
42+
}
43+
catch
44+
{
45+
Out-String -InputObject $_.Exception | Write-Host -ForegroundColor Red
46+
Write-Host
47+
Write-Host -ForegroundColor Red =====================================
48+
Write-Host -ForegroundColor Red "Test Failed"
49+
Write-Host -ForegroundColor Red =====================================
50+
Write-Host
51+
$global:failedTests += $testName
52+
}
53+
finally
54+
{
55+
$testEnd = Get-Date
56+
$testElapsed = $testEnd - $testStart
57+
$global:times[$testName] = $testElapsed
58+
$global:totalCount = $global:totalCount + 1
59+
}
60+
}
61+
62+
# Initialize
63+
Write-Host Delete log files
64+
Cleanup-Log $invocationPath
65+
66+
$testkeyVault = Get-KeyVault
67+
Write-Host Test key vault is $testKeyVault
68+
Write-Host Initializing Key Tests
69+
Initialize-KeyTest
70+
Write-Host Initializing Secret Tests
71+
Initialize-SecretTest
72+
Write-Host Initialization Completed
73+
74+
$global:startTime = Get-Date
75+
76+
# Get-AzureKeyVaultKey tests
77+
Run-TestProtected { Run-KeyTest {Test_GetAllKeys} "Test_GetAllKeys" } "Test_GetAllKeys"
78+
79+
80+
$global:endTime = Get-Date
81+
82+
# Report
83+
Write-FileReport
84+
Write-ConsoleReport
85+
86+
87+
# Post run
88+
Move-Log $invocationPath
89+
90+

0 commit comments

Comments
 (0)