Skip to content

. #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2015
Merged

. #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,31 @@ function Get-ImportKeyFile([string]$filesuffix, [bool] $exists=$true)
}
}

<#
.SYNOPSIS
Get 1024 bit key file path to be imported
#>
function Get-ImportKeyFile1024([string]$filesuffix, [bool] $exists=$true)
{
if ($exists)
{
$file = "$filesuffix"+"test1024.$filesuffix"
}
else
{
$file = "notexist" + ".$filesuffix"
}

if ($global:testEnv -eq 'BVT')
{
return Join-Path $invocationPath "bvtdata\$file"
}
else
{
return Join-Path $invocationPath "proddata\$file"
}
}

<#
.SYNOPSIS
Remove log file under a folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ Run-TestProtected { Run-KeyTest {Test_CreateSoftwareKeyWithCustomAttributes} "Te
Run-TestProtected { Run-KeyTest {Test_CreateHsmKeyWithDefaultAttributes} "Test_CreateHsmKeyWithDefaultAttributes" } "Test_CreateHsmKeyWithDefaultAttributes"
Run-TestProtected { Run-KeyTest {Test_CreateHsmKeyWithCustomAttributes} "Test_CreateHsmKeyWithCustomAttributes" } "Test_CreateHsmKeyWithCustomAttributes"
Run-TestProtected { Run-KeyTest {Test_ImportPfxWithDefaultAttributes} "Test_ImportPfxWithDefaultAttributes" } "Test_ImportPfxWithDefaultAttributes"
Run-TestProtected { Run-KeyTest {Test_ImportPfxWith1024BitKey} "Test_ImportPfxWith1024BitKey" } "Test_ImportPfxWith1024BitKey"
Run-TestProtected { Run-KeyTest {Test_ImportPfxWithCustomAttributes} "Test_ImportPfxWithCustomAttributes" } "Test_ImportPfxWithCustomAttributes"
Run-TestProtected { Run-KeyTest {Test_ImportPfxAsHsmWithDefaultAttributes} "Test_ImportPfxAsHsmWithDefaultAttributes" } "Test_ImportPfxAsHsmWithDefaultAttributes"
Run-TestProtected { Run-KeyTest {Test_ImportPfxAsHsmWithCustomAttributes} "Test_ImportPfxAsHsmWithCustomAttributes" } "Test_ImportPfxAsHsmWithCustomAttributes"
Run-TestProtected { Run-KeyTest {Test_ImportByokWithDefaultAttributes} "Test_ImportByokWithDefaultAttributes" } "Test_ImportByokWithDefaultAttributes"
Run-TestProtected { Run-KeyTest {Test_ImportByokWith1024BitKey} "Test_ImportByokWith1024BitKey" } "Test_ImportByokWith1024BitKey"
Run-TestProtected { Run-KeyTest {Test_ImportByokWithCustomAttributes} "Test_ImportByokWithCustomAttributes" } "Test_ImportByokWithCustomAttributes"
Run-TestProtected { Run-KeyTest {Test_AddKeyPositionalParameter} "Test_AddKeyPositionalParameter" } "Test_AddKeyPositionalParameter"
Run-TestProtected { Run-KeyTest {Test_AddKeyAliasParameter} "Test_AddKeyAliasParameter" } "Test_AddKeyAliasParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $delta=[TimeSpan]::FromMinutes(2)
$tags=@{"tag1"="value1"; "tag2"=""; "tag3"=$null}
$newtags= @{"tag1"="value1"; "tag2"="value2"; "tag3"="value3"; "tag4"="value4"}
$emptytags=@{}
$defaultKeySizeInBytes = 256



Expand Down Expand Up @@ -67,6 +68,7 @@ function Test_CreateSoftwareKeyWithDefaultAttributes
Assert-NotNull $key
$global:createdKeys += $keyname
Assert-KeyAttributes $key.Attributes 'RSA' $true $null $null $null $null
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
}

<#
Expand Down Expand Up @@ -95,6 +97,7 @@ function Test_CreateHsmKeyWithDefaultAttributes
Assert-NotNull $key
$global:createdKeys += $keyname
Assert-KeyAttributes $key.Attributes 'RSA-HSM' $true $null $null $null $null
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
}

<#
Expand Down Expand Up @@ -124,6 +127,23 @@ function Test_ImportPfxWithDefaultAttributes
Assert-NotNull $key
$global:createdKeys += $keyname
Assert-KeyAttributes $key.Attributes 'RSA' $true $null $null $null $null
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
}

<#
.SYNOPSIS
Tests import pfx with default attributes
#>
function Test_ImportPfxWith1024BitKey
{
$keyVault = Get-KeyVault
$keyname=Get-KeyName 'pfx1024'
$pfxpath = Get-ImportKeyFile1024 'pfx'
$key=Add-AzureKeyVaultKey -VaultName $keyVault -Name $keyname -KeyFilePath $pfxpath -KeyFilePassword $securepfxpwd
Assert-NotNull $key
$global:createdKeys += $keyname
Assert-KeyAttributes $key.Attributes 'RSA' $true $null $null $null $null
Assert-AreEqual $key.Key.N.Length 128
}

<#
Expand Down Expand Up @@ -184,6 +204,23 @@ function Test_ImportByokWithDefaultAttributes
Assert-NotNull $key
$global:createdKeys += $keyname
Assert-KeyAttributes $key.Attributes 'RSA-HSM' $true $null $null $null $null
Assert-AreEqual $key.Key.N.Length $defaultKeySizeInBytes
}

<#
.SYNOPSIS
Tests import byok with default attributes
#>
function Test_ImportByokWith1024BitKey
{
$keyVault = Get-KeyVault
$keyname=Get-KeyName 'byok1024'
$byokpath = Get-ImportKeyFile1024 'byok'
$key=Add-AzureKeyVaultKey -VaultName $keyVault -Name $keyname -KeyFilePath $byokpath
Assert-NotNull $key
$global:createdKeys += $keyname
Assert-KeyAttributes $key.Attributes 'RSA-HSM' $true $null $null $null $null
Assert-AreEqual $key.Key.N.Length 128
}

<#
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.