Skip to content

Commit

Permalink
Merge branch 'update-testing' into 'main'
Browse files Browse the repository at this point in the history
Improve Testing and Add ISSUE_TEMPLATEs

See merge request wmarshall/SecretManagement.Warden!17
  • Loading branch information
marshallwp committed Sep 19, 2024
2 parents 1e889e0 + 152b8c6 commit 21de211
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 3 deletions.
69 changes: 69 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_Report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Bug report 🐛
description: Report errors or unexpected behavior 🤔
labels: Needs-Triage
body:
- type: markdown
attributes:
value: Write a summary of the issue.
- type: checkboxes
attributes:
label: Prerequisites
options:
- label: Write a descriptive title.
required: true
- label: Make sure you are able to repro it on the [latest released version](https://github.com/marshallwp/SecretManagement.Warden/tags)
required: true
- label: Search the existing issues.
required: true
- label: Refer to [Known Issues](https://github.com/marshallwp/SecretManagement.Warden#known-issues).
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: >
List of steps, sample code, failing test or link to a project that reproduces the behavior.
Make sure you place a stack trace inside a code (```) block to avoid linking unrelated issues.
placeholder: >
I am experiencing a problem with X.
I think Y should be happening but Z is actually happening.
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
render: console
placeholder: |
PS> 2 + 2
4
validations:
required: true
- type: textarea
attributes:
label: Actual behavior
render: console
placeholder: |
PS> 2 + 2
5
validations:
required: true
- type: textarea
attributes:
label: Error details
description: Paste verbatim output from `Get-Error` if PowerShell return an error.
render: console
placeholder: PS> Get-Error
- type: textarea
attributes:
label: Environment data
description: Paste verbatim output from `$PSVersionTable` below.
render: powershell
placeholder: PS> $PSVersionTable
validations:
required: true
- type: textarea
attributes:
label: Visuals
description: >
Please upload images or animations that can be used to reproduce issues in the area below.
Try the [Steps Recorder](https://support.microsoft.com/en-us/windows/record-steps-to-reproduce-a-problem-46582a9b-620f-2e36-00c9-04e25d784e47)
on Windows or [Screenshot](https://support.apple.com/en-us/HT208721) on macOS.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_Request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Feature Request / Idea 🚀
description: Suggest a new feature or improvement (this does not mean you have to implement it)
labels: [Issue-Enhancement, Needs-Triage]
body:
- type: textarea
attributes:
label: Summary of the new feature / enhancement
description: >
A clear and concise description of what the problem is that the
new feature would solve. Try formulating it in user story style
(if applicable).
placeholder: "'As a user I want X so that Y...' with X being the being the action and Y being the value of the action."
validations:
required: true
- type: textarea
attributes:
label: Proposed technical implementation details (optional)
placeholder: >
A clear and concise description of what you want to happen.
Consider providing an example PowerShell experience with expected result.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: PowerShell Support
url: https://github.com/PowerShell/PowerShell/blob/master/.github/SUPPORT.md
about: PowerShell Support Questions/Help
- name: Microsoft.PowerShell.SecretManagement Issues
url: https://github.com/PowerShell/SecretManagement/issues/new/choose
about: Report any issues with the base module here.
10 changes: 9 additions & 1 deletion .github/workflows/pester-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ jobs:
# Run Pester tests
$config = New-PesterConfiguration
$config.Run.Path = "."
$config.CodeCoverage.Enabled = $true
$config.CodeCoverage.Enabled = $IsLinux
$config.CodeCoverage.Path = @(
"./SecretManagement.Warden.Extension/classes",
"./SecretManagement.Warden.Extension/private",
"./SecretManagement.Warden.Extension/public"
)
$config.CodeCoverage.OutputPath = "coverage.xml"
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = "Unit.Tests.xml"
Expand All @@ -129,18 +134,21 @@ jobs:
retention-days: 7

- name: Setup .NET Core # Required to execute ReportGenerator
if: runner.os == 'Linux'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
dotnet-quality: 'ga'

- name: ReportGenerator
if: runner.os == 'Linux'
uses: danielpalme/[email protected]
with:
reports: coverage.xml
targetdir: .
reporttypes: MarkdownSummaryGithub

- name: Publish Coverage In Build Summary
if: runner.os == 'Linux'
shell: bash
run: cat ./SummaryGithub.md >> $GITHUB_STEP_SUMMARY # Adjust path and filename if necessary
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.SYNOPSIS
Converts a PSCustomObject to a HashTable.
.NOTES
In PowerShell 7.3+, "ConvertFrom-Json -AsHashtable" outputs an [OrderedHashtable] object. Unfortunately, Get-Secret does not allow you to return an OrderedHashtable, so this function is used to create a regular, unordered variant.
Microsoft.PowerShell.SecretManagement only supports the following data types: byte[], string, SecureString, PSCredential, and Hashtable.
See: https://github.com/PowerShell/SecretManagement/blob/main/README.md
.EXAMPLE
$json | ConvertFrom-Json | ConvertTo-HashTable
Parses JSON string and outputs a HashTable.
Expand Down
1 change: 0 additions & 1 deletion SecretManagement.Warden.Extension/public/Get-Secret.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function Get-Secret {
}
{ "Login","Card","Identity" -icontains $_ } {
# Output login as a hashtable. This allows us to support credentials that lack a username and therefore cannot output a PSCredential.
# *Unlike Get-SecretInfo, Get-Secret does not support ordered hashtables.
return $Result.$_ | ConvertTo-Hashtable
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,20 @@ Describe "ConvertTo-BWEncoding" {
$sample | Should -Be $Expected
}
}

Context "Verbose Output" {
It "<InputType>: [Verbose] <Expected>" -ForEach @(
@{ InputType="Int32"; Case=32; Expected=@('Object is already a JSON string', 'Converting JSON to Base64 encoding') },
@{ InputType="String"; Case=$str; Expected="Converting JSON to Base64 encoding" },
@{ InputType="Base64"; Case=$strB64; Expected="Object is already Base64 encoded" },
@{ InputType="HashTable"; Case=$obj; Expected=@('Converting object to JSON', 'Converting JSON to Base64 encoding') },
@{ InputType="JSON"; Case=$json; Expected='Converting JSON to Base64 encoding' },
@{ InputType="JSON (Base64)"; Case=$jsonB64; Expected="Object is already Base64 encoded" }
) {
$tmpFile = New-TemporaryFile
ConvertTo-BWEncoding $Case -Verbose 4> $tmpFile.FullName
Get-Content $tmpFile | Should -Be $Expected
Remove-Item $tmpFile
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ BeforeAll {
. (Join-Path $BasePath "classes" "BitwardenEnum.ps1")

Mock Sync-BitwardenVault { }

Import-Module -Name Microsoft.PowerShell.SecretManagement
}

Describe "Get-SecretInfo" {
Expand Down

0 comments on commit 21de211

Please sign in to comment.