Skip to content
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

First wave of build/test updates #224

Closed
Closed
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
artifacts/
module/

_site/
_themes/
.DS_Store
Expand All @@ -12,7 +15,6 @@ maml/
**/obj/**
packages.config
packages/
SecretManagement.sln
Tools/NuGet/
test/result.pester.xml
updatablehelp/
Expand Down
10 changes: 10 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<PropertyGroup>

<ModuleVersion>1.1.2</ModuleVersion>

<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a funny variable. I looked it up and sure enough MSBuildThisFileDirectory "Include[s] the final backslash in the path."


</PropertyGroup>
</Project>
8 changes: 8 additions & 0 deletions ExtensionModules/CredManStore/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<PropertyGroup>

<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>

</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '1.0'
RootModule = '..\Microsoft.PowerShell.CredManStore.dll'
RootModule = './Microsoft.PowerShell.CredManStore.dll'
FunctionsToExport = @('Set-Secret','Get-Secret','Remove-Secret','Get-SecretInfo','Test-SecretVault')
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
# Licensed under the MIT License.

Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {

BeforeAll {

if (! $IsWindows)
$ModuleRoot = Split-Path $PSScriptRoot | Join-Path -ChildPath 'artifacts/publish/Microsoft.PowerShell.CredManStore/Release'
$ProjectRoot = Split-Path $PSScriptRoot | Split-Path | Split-Path
if (-not $IsWindows)
{
$defaultParameterValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:Skip"] = $true
$PSDefaultParameterValues["It:Skip"] = $true
return
}
else

if (-not (Get-Module -Name Microsoft.PowerShell.SecretManagement -ErrorAction Ignore))
{
if ((Get-Module -Name Microsoft.PowerShell.SecretManagement -ErrorAction Ignore) -eq $null)
{
Import-Module -Name Microsoft.PowerShell.SecretManagement
}
Import-Module -Name Microsoft.PowerShell.SecretManagement
}

if ((Get-Module -Name Microsoft.PowerShell.CredManStore -ErrorAction Ignore) -eq $null)
{
Import-Module -Name ..\Microsoft.PowerShell.CredManStore.psd1
}
if (-not (Get-Module -Name Microsoft.PowerShell.CredManStore -ErrorAction Ignore))
{
Import-Module -Name $ModuleRoot\Microsoft.PowerShell.CredManStore.psd1
}
}

Expand All @@ -34,9 +33,11 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {

Context "CredMan Store Vault Byte[] type" {

$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$bytesToWrite = [System.Text.Encoding]::UTF8.GetBytes('TestStringForBytes')
$errorCode = 0
BeforeAll {
$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$bytesToWrite = [System.Text.Encoding]::UTF8.GetBytes('TestStringForBytes')
$errorCode = 0
}

It "Verifies byte[] write to store" {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::WriteObject(
Expand All @@ -54,7 +55,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outBytes,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
[System.Text.Encoding]::UTF8.GetString($outBytes) | Should -BeExactly 'TestStringForBytes'
Expand All @@ -66,7 +67,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outInfo,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outInfo.Key | Should -BeExactly $secretName
Expand All @@ -77,17 +78,19 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::DeleteObject(
$secretName,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
}
}

Context "CredMan Store Vault String type" {

$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$stringToWrite = 'TestStringForString'
$errorCode = 0
BeforeAll {
$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$stringToWrite = 'TestStringForString'
$errorCode = 0
}

It "Verifes string write to store" {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::WriteObject(
Expand All @@ -105,7 +108,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outString,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outString | Should -BeExactly 'TestStringForString'
Expand All @@ -117,7 +120,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outInfo,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outInfo.Key | Should -BeExactly $secretName
Expand All @@ -128,18 +131,20 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::DeleteObject(
$secretName,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
}
}

Context "CredMan Store Vault SecureString type" {

$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$randomSecret = [System.IO.Path]::GetRandomFileName()
$secureStringToWrite = ConvertTo-SecureString -String $randomSecret -AsPlainText -Force
$errorCode = 0
BeforeAll {
$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$randomSecret = [System.IO.Path]::GetRandomFileName()
$secureStringToWrite = ConvertTo-SecureString -String $randomSecret -AsPlainText -Force
$errorCode = 0
}

It "Verifies SecureString write to store" {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::WriteObject(
Expand All @@ -157,7 +162,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outSecureString,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
[System.Net.NetworkCredential]::new('',$outSecureString).Password | Should -BeExactly $randomSecret
Expand All @@ -169,7 +174,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outInfo,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outInfo.Key | Should -BeExactly $secretName
Expand All @@ -180,17 +185,19 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::DeleteObject(
$secretName,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
}
}

Context "CredMan Store Vault PSCredential type" {

$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$randomSecret = [System.IO.Path]::GetRandomFileName()
$errorCode = 0
BeforeAll {
$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$randomSecret = [System.IO.Path]::GetRandomFileName()
$errorCode = 0
}

It "Verifies PSCredential type write to store" {
$cred = [pscredential]::new('UserL', (ConvertTo-SecureString $randomSecret -AsPlainText -Force))
Expand All @@ -209,7 +216,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outCred,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outCred.UserName | Should -BeExactly "UserL"
Expand All @@ -222,7 +229,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outInfo,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outInfo.Key | Should -BeExactly $secretName
Expand All @@ -233,18 +240,20 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::DeleteObject(
$secretName,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
}
}

Context "CredMan Store Vault Hashtable type" {

$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$randomSecretA = [System.IO.Path]::GetRandomFileName()
$randomSecretB = [System.IO.Path]::GetRandomFileName()
$errorCode = 0
BeforeAll {
$secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName())
$randomSecretA = [System.IO.Path]::GetRandomFileName()
$randomSecretB = [System.IO.Path]::GetRandomFileName()
$errorCode = 0
}

It "Verifies Hashtable type write to store" {
$ht = @{
Expand All @@ -269,7 +278,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outHT,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outHT.Blob.Count | Should -Be 2
Expand All @@ -285,7 +294,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$secretName,
[ref] $outInfo,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
$outInfo.Key | Should -BeExactly $secretName
Expand All @@ -296,7 +305,7 @@ Describe "Test Microsoft.PowerShell.CredManStore module" -tags CI {
$success = [Microsoft.PowerShell.CredManStore.LocalCredManStore]::DeleteObject(
$secretName,
[ref] $errorCode)

$success | Should -BeTrue
$errorCode | Should -Be 0
}
Expand Down
Loading
Loading