-
Notifications
You must be signed in to change notification settings - Fork 57
win_psDscAdapter and psDscAdapter PScredentials fix for passing username and password #1308
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
Open
mimachniak
wants to merge
56
commits into
PowerShell:main
Choose a base branch
from
mimachniak:win_psDscAdapter-PSCredentials-fix-ScriptDSC
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+604
−36
Open
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
61f4b85
Add to win_psDscAdapter function for extraxting string from PSCredent…
mimachniak cd5df41
Add to win_psDscAdapter for ScriptBase resources PSCredentails fix co…
mimachniak 98e7099
Merge branch 'PowerShell:main' into win_psDscAdapter-PSCredentials-fi…
mimachniak 0a7c6aa
Fix win_psDscAdapter for ScriptBase resources PSCredentails fix conve…
mimachniak 82aeec4
psDscAdapter for ClassBase resources PSCredentails fix convert to Sys…
mimachniak 506ba9f
Add for testClass testing yaml with secureObject - main file and para…
mimachniak 49c381c
Fix win_psDscAdapter for ClassBase resources PSCredentails fix conver…
mimachniak 403e6b5
Fix win_psDscAdapter for ClassBase resources PSCredentails fix conver…
mimachniak 352dd69
Ad unit test for credentaials in powershellgroup.config.tests.ps1 - v…
mimachniak 4af004e
Ad unit test for credentaials in win_powershellgroup.tests.ps1 - vali…
mimachniak dd7425e
Ad unit test for credentaials in win_powershellgroup.tests.ps1 - vali…
mimachniak b8cff4a
Add script base DSC resources for testing credentials
mimachniak 63cd935
Add script base DSC resources for testing credentials and fix win_PsD…
mimachniak 73dacde
Script base yaml DSC resources for credential valid
mimachniak 34b6b73
Add script base resource test in win_powershellgroup.tests.ps1
mimachniak 877ee8b
Add to win_psDscAdapter.psm1 support for secure object and test value…
mimachniak 7984d06
Add to psDscAdapter.psm1 support for secure object and test value par…
mimachniak 661259b
Change faild test win_powershellgroup.tests it false
mimachniak f6b366e
Add to psDscAdapter.psm1 remove output of credntials
mimachniak 6763c23
Remove spaces
mimachniak 779e259
Add to psDscAdapter.psm1 remove output of credntials
mimachniak 2d10057
Add to unit test for PowerShell adapter in verions 5.1
mimachniak 3c57cf8
Fix test file parsing
mimachniak 3542591
Fix DSC - test and class path creation for subfolder
mimachniak 4400c8f
Run test
mimachniak 46dc975
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak 6ecf98d
Fix some test issue
mimachniak 980f2bc
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak 17bd44a
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak 6342821
Add workflow_dispatch trigger to rust.yml
mimachniak 802704c
Remove workflow_dispatch from rust.yml
mimachniak f8ce2bf
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak 0d2647c
Merge branch 'PowerShell:main' into win_psDscAdapter-PSCredentials-fi…
mimachniak c4e1e2f
Merge branch 'PowerShell:main' into win_psDscAdapter-PSCredentials-fi…
mimachniak 12e18c1
Fix loading old mof module - regquired access ProgramFileModule ythat…
mimachniak 132c31f
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak c71240f
Update adapters/powershell/Tests/class_ps_resources_secret.parameters…
mimachniak 35613e2
Update adapters/powershell/Tests/win_powershellgroup.tests.ps1
mimachniak 466a595
Update adapters/powershell/psDscAdapter/win_psDscAdapter.psm1
mimachniak 3ea45e9
Update adapters/powershell/Tests/TestScriptBaseDSC/DSCResources/Crede…
mimachniak 76a8990
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak aff99b5
Update adapters/powershell/psDscAdapter/win_psDscAdapter.psm1
mimachniak 67717e0
Update adapters/powershell/psDscAdapter/win_psDscAdapter.psm1
mimachniak 1397b2e
Update adapters/powershell/Tests/TestScriptBaseDSC/DSCResources/Crede…
mimachniak 6cbe62e
Update adapters/powershell/psDscAdapter/win_psDscAdapter.psm1
mimachniak d2d3d1c
Update adapters/powershell/Tests/win_powershellgroup.tests.ps1
mimachniak c3b118d
Remove case sensitive issue for display Credential object requires bo…
mimachniak 99da2c8
Add suggestion for secure object .Value.PSObject.Properties['secureOb…
mimachniak 2823483
Add suggestion for secure object .Value.PSObject.Properties['secureOb…
mimachniak 2826fba
Update adapters/powershell/Tests/win_powershellgroup.tests.ps1
mimachniak 1ea2346
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak 753c301
Update adapters/powershell/Tests/win_powershellgroup.tests.ps1
mimachniak 28d5b3d
Remove throw - in dsc class
mimachniak 1418dfa
Remove throw - in dsc class
mimachniak e624d82
Test resolved - to pass
mimachniak 8cc64e8
Merge branch 'main' into win_psDscAdapter-PSCredentials-fix-ScriptDSC
mimachniak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ on: | |
| - "*.md" | ||
| - ".vscode/*.json" | ||
| - ".github/ISSUE_TEMPLATE/**" | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
|
|
||
83 changes: 83 additions & 0 deletions
83
...shell/Tests/TestScriptBaseDSC/DSCResources/CredentialValidation/CredentialValidation.psm1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| $VerbosePreference = 'SilentlyContinue' | ||
| $InformationPreference = 'SilentlyContinue' | ||
| $ProgressPreference = 'Continue' | ||
| $ErrorActionPreference = 'SilentlyContinue' | ||
|
|
||
| function Get-TargetResource { | ||
| [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')] | ||
| [OutputType([Hashtable])] | ||
| param ( | ||
| [Parameter(Mandatory)] | ||
| [string] $Name, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [System.Management.Automation.PSCredential] | ||
| $Credential | ||
| ) | ||
| Write-Verbose "[GET] Get Function running" | ||
| return @{ | ||
| Name = $Name | ||
| Credential = $Credential | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function Test-TargetResource { | ||
| [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')] | ||
| [OutputType([System.Boolean])] | ||
| param ( | ||
| [Parameter(Mandatory)] | ||
| [string] $Name, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [System.Management.Automation.PSCredential] | ||
| $Credential | ||
|
|
||
| ) | ||
| Write-Verbose "[TEST]Checking credentials" | ||
| Write-Verbose "[TEST]Checking credentials UserName: $($Credential.UserName)" | ||
| Write-Verbose "[TEST]Checking credentials Password: <redacted>" | ||
|
|
||
| if ($null -eq $Credential) { | ||
| $inDesiredState = $false | ||
| return $false | ||
| } | ||
|
|
||
| if ($Credential.UserName -ne 'MyUser') { | ||
| $inDesiredState = $false | ||
| } else { | ||
| $inDesiredState = $true | ||
| } | ||
|
|
||
|
|
||
| return $inDesiredState | ||
|
|
||
| } | ||
|
|
||
| function Set-TargetResource { | ||
| [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')] | ||
| [CmdletBinding()] | ||
| param ( | ||
| [Parameter(Mandatory)] | ||
| [string] $Name, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [System.Management.Automation.PSCredential] | ||
| $Credential | ||
|
|
||
| ) | ||
|
|
||
| if ($null -eq $Credential) { | ||
| $inDesiredState = $false | ||
| return $false | ||
| } | ||
|
|
||
| if ($Credential.UserName -ne 'MyUser') { | ||
| $inDesiredState = $false | ||
| } else { | ||
| $inDesiredState = $true | ||
| } | ||
|
|
||
| Write-Verbose "[SET]Credential cannot be remediated by DSC." | ||
| return $inDesiredState | ||
| } | ||
6 changes: 6 additions & 0 deletions
6
...Tests/TestScriptBaseDSC/DSCResources/CredentialValidation/CredentialValidation.schema.mof
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [ClassVersion("1.0.0.0"), FriendlyName("CredentialValidation")] | ||
| class CredentialValidation : OMI_BaseResource | ||
| { | ||
| [Key] string Name; | ||
| [Required, Description("Test Credentials for Script Base"), EmbeddedInstance("MSFT_Credential")] String Credential; | ||
| }; |
62 changes: 62 additions & 0 deletions
62
adapters/powershell/Tests/TestScriptBaseDSC/TestScriptBaseDSC.psd1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| @{ | ||
| # Script module or binary module file associated with this manifest. | ||
| RootModule = 'TestScriptBaseDSC.psm1' | ||
|
|
||
| # Version number of this module. | ||
| moduleVersion = '0.0.1' | ||
|
|
||
| # ID used to uniquely identify this module | ||
| GUID = 'c3775be8-84a1-43f5-a99c-1b9f2d6bc178' | ||
|
|
||
| # Author of this module | ||
| Author = '' | ||
|
|
||
| # Company or vendor of this module | ||
| CompanyName = '' | ||
|
|
||
| # Copyright statement for this module | ||
| Copyright = '' | ||
|
|
||
| # Description of the functionality provided by this module | ||
| Description = '' | ||
|
|
||
| # Minimum version of the Windows PowerShell engine required by this module | ||
| PowerShellVersion = '5.0' | ||
|
|
||
| # Cmdlets to export from this module | ||
| CmdletsToExport = @() | ||
|
|
||
| # Variables to export from this module | ||
| VariablesToExport = @() | ||
|
|
||
| # Aliases to export from this module | ||
| AliasesToExport = @() | ||
|
|
||
| # Dsc Resources to export from this module | ||
| DscResourcesToExport = @('CredentialValidation') | ||
|
|
||
| # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. | ||
| PrivateData = @{ | ||
|
|
||
| PSData = @{ | ||
|
|
||
| # Tags applied to this module. These help with module discovery in online galleries. | ||
| Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') | ||
|
|
||
| # A URL to the license for this module. | ||
| LicenseUri = '' | ||
|
|
||
| # A URL to the main website for this project. | ||
| ProjectUri = '' | ||
|
|
||
| # A URL to an icon representing this module. | ||
| IconUri = '' | ||
|
|
||
| # ReleaseNotes of this module | ||
| ReleaseNotes = '' | ||
|
|
||
| # Set to a prerelease string value if the release should be a prerelease. | ||
| Prerelease = '' | ||
| } # End of PSData hashtable | ||
| } # End of PrivateData hashtable | ||
| } |
2 changes: 2 additions & 0 deletions
2
adapters/powershell/Tests/TestScriptBaseDSC/TestScriptBaseDSC.psm1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Root module for CredentialValidationDsc | ||
| # No code required |
29 changes: 29 additions & 0 deletions
29
adapters/powershell/Tests/class_ps_resources_secret.dsc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| parameters: | ||
| showSecrets: | ||
| type: bool | ||
| defaultValue: true | ||
| cred: | ||
| type: secureObject | ||
| metadata: | ||
| Microsoft.DSC: | ||
| requiredSecurityContext: elevated # this is the default and just used as an example indicating this config works for admins and non-admins | ||
| resources: | ||
| - name: Working with classic DSC resources | ||
| type: Microsoft.DSC/PowerShell | ||
| properties: | ||
| resources: | ||
| - name: Class-resource Info | ||
| type: TestClassResource/TestClassResource | ||
| properties: | ||
| Name: TestClassResource1 | ||
| Prop1: ValueForProp1 | ||
| Credential: "[parameters('cred')]" | ||
| - name: SecureObject | ||
| type: Microsoft.DSC.Debug/Echo | ||
| properties: | ||
| output: "[parameters('cred')]" | ||
| showSecrets: "[parameters('showSecrets')]" |
4 changes: 4 additions & 0 deletions
4
adapters/powershell/Tests/class_ps_resources_secret.parameters.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| parameters: | ||
| cred: | ||
| username: admin | ||
| password: {To be Override} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
adapters/powershell/Tests/script_ps_resources_secret.dsc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| parameters: | ||
| cred: | ||
| type: secureObject | ||
| defaultValue: | ||
| username: MyUser | ||
| password: Password | ||
| resources: | ||
| - name: Working with classic DSC resources | ||
| type: Microsoft.Windows/WindowsPowerShell | ||
| properties: | ||
| resources: | ||
| - name: Script-resource Info | ||
| type: TestScriptBaseDSC/CredentialValidation | ||
| properties: | ||
| Name: TestScriptResource1 | ||
| Credential: "[parameters('cred')]" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.