Skip to content

Commit 2523d79

Browse files
unknownunknown
unknown
authored and
unknown
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents e5bf7c4 + 5d5b475 commit 2523d79

File tree

7 files changed

+64
-0
lines changed

7 files changed

+64
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,31 @@ function Get-ImportKeyFile([string]$filesuffix, [bool] $exists=$true)
8686
}
8787
}
8888

89+
<#
90+
.SYNOPSIS
91+
Get 1024 bit key file path to be imported
92+
#>
93+
function Get-ImportKeyFile1024([string]$filesuffix, [bool] $exists=$true)
94+
{
95+
if ($exists)
96+
{
97+
$file = "$filesuffix"+"test1024.$filesuffix"
98+
}
99+
else
100+
{
101+
$file = "notexist" + ".$filesuffix"
102+
}
103+
104+
if ($global:testEnv -eq 'BVT')
105+
{
106+
return Join-Path $invocationPath "bvtdata\$file"
107+
}
108+
else
109+
{
110+
return Join-Path $invocationPath "proddata\$file"
111+
}
112+
}
113+
89114
<#
90115
.SYNOPSIS
91116
Remove log file under a folder

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ Run-TestProtected { Run-KeyTest {Test_CreateSoftwareKeyWithCustomAttributes} "Te
7979
Run-TestProtected { Run-KeyTest {Test_CreateHsmKeyWithDefaultAttributes} "Test_CreateHsmKeyWithDefaultAttributes" } "Test_CreateHsmKeyWithDefaultAttributes"
8080
Run-TestProtected { Run-KeyTest {Test_CreateHsmKeyWithCustomAttributes} "Test_CreateHsmKeyWithCustomAttributes" } "Test_CreateHsmKeyWithCustomAttributes"
8181
Run-TestProtected { Run-KeyTest {Test_ImportPfxWithDefaultAttributes} "Test_ImportPfxWithDefaultAttributes" } "Test_ImportPfxWithDefaultAttributes"
82+
Run-TestProtected { Run-KeyTest {Test_ImportPfxWith1024BitKey} "Test_ImportPfxWith1024BitKey" } "Test_ImportPfxWith1024BitKey"
8283
Run-TestProtected { Run-KeyTest {Test_ImportPfxWithCustomAttributes} "Test_ImportPfxWithCustomAttributes" } "Test_ImportPfxWithCustomAttributes"
8384
Run-TestProtected { Run-KeyTest {Test_ImportPfxAsHsmWithDefaultAttributes} "Test_ImportPfxAsHsmWithDefaultAttributes" } "Test_ImportPfxAsHsmWithDefaultAttributes"
8485
Run-TestProtected { Run-KeyTest {Test_ImportPfxAsHsmWithCustomAttributes} "Test_ImportPfxAsHsmWithCustomAttributes" } "Test_ImportPfxAsHsmWithCustomAttributes"
8586
Run-TestProtected { Run-KeyTest {Test_ImportByokWithDefaultAttributes} "Test_ImportByokWithDefaultAttributes" } "Test_ImportByokWithDefaultAttributes"
87+
Run-TestProtected { Run-KeyTest {Test_ImportByokWith1024BitKey} "Test_ImportByokWith1024BitKey" } "Test_ImportByokWith1024BitKey"
8688
Run-TestProtected { Run-KeyTest {Test_ImportByokWithCustomAttributes} "Test_ImportByokWithCustomAttributes" } "Test_ImportByokWithCustomAttributes"
8789
Run-TestProtected { Run-KeyTest {Test_AddKeyPositionalParameter} "Test_AddKeyPositionalParameter" } "Test_AddKeyPositionalParameter"
8890
Run-TestProtected { Run-KeyTest {Test_AddKeyAliasParameter} "Test_AddKeyAliasParameter" } "Test_AddKeyAliasParameter"

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ $delta=[TimeSpan]::FromMinutes(2)
1010
$tags=@{"tag1"="value1"; "tag2"=""; "tag3"=$null}
1111
$newtags= @{"tag1"="value1"; "tag2"="value2"; "tag3"="value3"; "tag4"="value4"}
1212
$emptytags=@{}
13+
$defaultKeySizeInBytes = 256
1314

1415

1516

@@ -67,6 +68,7 @@ function Test_CreateSoftwareKeyWithDefaultAttributes
6768
Assert-NotNull $key
6869
$global:createdKeys += $keyname
6970
Assert-KeyAttributes $key.Attributes 'RSA' $true $null $null $null $null
71+
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
7072
}
7173

7274
<#
@@ -95,6 +97,7 @@ function Test_CreateHsmKeyWithDefaultAttributes
9597
Assert-NotNull $key
9698
$global:createdKeys += $keyname
9799
Assert-KeyAttributes $key.Attributes 'RSA-HSM' $true $null $null $null $null
100+
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
98101
}
99102

100103
<#
@@ -124,6 +127,23 @@ function Test_ImportPfxWithDefaultAttributes
124127
Assert-NotNull $key
125128
$global:createdKeys += $keyname
126129
Assert-KeyAttributes $key.Attributes 'RSA' $true $null $null $null $null
130+
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
131+
}
132+
133+
<#
134+
.SYNOPSIS
135+
Tests import pfx with default attributes
136+
#>
137+
function Test_ImportPfxWith1024BitKey
138+
{
139+
$keyVault = Get-KeyVault
140+
$keyname=Get-KeyName 'pfx1024'
141+
$pfxpath = Get-ImportKeyFile1024 'pfx'
142+
$key=Add-AzureKeyVaultKey -VaultName $keyVault -Name $keyname -KeyFilePath $pfxpath -KeyFilePassword $securepfxpwd
143+
Assert-NotNull $key
144+
$global:createdKeys += $keyname
145+
Assert-KeyAttributes $key.Attributes 'RSA' $true $null $null $null $null
146+
Assert-AreEqual $key.Key.N.Length 128
127147
}
128148

129149
<#
@@ -184,6 +204,23 @@ function Test_ImportByokWithDefaultAttributes
184204
Assert-NotNull $key
185205
$global:createdKeys += $keyname
186206
Assert-KeyAttributes $key.Attributes 'RSA-HSM' $true $null $null $null $null
207+
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
208+
}
209+
210+
<#
211+
.SYNOPSIS
212+
Tests import byok with default attributes
213+
#>
214+
function Test_ImportByokWith1024BitKey
215+
{
216+
$keyVault = Get-KeyVault
217+
$keyname=Get-KeyName 'byok1024'
218+
$byokpath = Get-ImportKeyFile1024 'byok'
219+
$key=Add-AzureKeyVaultKey -VaultName $keyVault -Name $keyname -KeyFilePath $byokpath
220+
Assert-NotNull $key
221+
$global:createdKeys += $keyname
222+
Assert-KeyAttributes $key.Attributes 'RSA-HSM' $true $null $null $null $null
223+
Assert-AreEqual $key.Key.N.Length 128
187224
}
188225

189226
<#

0 commit comments

Comments
 (0)