From 9b9e286b207ba8b8c78c35d6d0d6765ed1585123 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Fri, 18 May 2018 08:02:53 +0200 Subject: [PATCH 01/10] Update tests to use Assert-VerifiableMock (#71) - Changes to xWindowsUpdate - Tests no longer fail on `Assert-VerifiableMocks`, these are now renamed to `Assert-VerifiableMock` (breaking change in Pester v4). --- README.md | 3 + Tests/Unit/MSFT_xWindowsUpdate.tests.ps1 | 6 +- Tests/Unit/MSFT_xWindowsUpdateAgent.tests.ps1 | 60 +++++++++---------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 6136e0b..bb34e5f 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,9 @@ Please check out common DSC Resources ### Unreleased +* Tests no longer fail on `Assert-VerifiableMocks`, these are now renamed + to `Assert-VerifiableMock` (breaking change in Pester v4). + ### 2.7.0.0 * xWindowsUpdateAgent: Fix Get-TargetResource returning incorrect key diff --git a/Tests/Unit/MSFT_xWindowsUpdate.tests.ps1 b/Tests/Unit/MSFT_xWindowsUpdate.tests.ps1 index 1249e72..2346d63 100644 --- a/Tests/Unit/MSFT_xWindowsUpdate.tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsUpdate.tests.ps1 @@ -49,7 +49,7 @@ try $getResult = (Get-TargetResource -Path 'C:\test.msu' -Id 'KB123457' ) it 'should have called get-hotfix'{ - Assert-VerifiableMocks + Assert-VerifiableMock } it 'should return id="KB123456"'{ @@ -72,7 +72,7 @@ try $getResult = (Test-TargetResource -Path 'C:\test.msu' -Id 'KB123456' ) it 'should have called get-hotfix'{ - Assert-VerifiableMocks + Assert-VerifiableMock } it 'should return $true'{ @@ -86,7 +86,7 @@ try $getResult = (Test-TargetResource -Path 'C:\test.msu' -Id 'KB123457' ) it 'should have called get-hotfix'{ - Assert-VerifiableMocks + Assert-VerifiableMock } it 'should return $true'{ diff --git a/Tests/Unit/MSFT_xWindowsUpdateAgent.tests.ps1 b/Tests/Unit/MSFT_xWindowsUpdateAgent.tests.ps1 index 8781388..6697709 100644 --- a/Tests/Unit/MSFT_xWindowsUpdateAgent.tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsUpdateAgent.tests.ps1 @@ -42,7 +42,7 @@ try # The InModuleScope command allows you to perform white-box unit testing on the internal # (non-exported) code of a Script Module. InModuleScope $Global:DSCResourceName { - + #region Pester Test Initialization $Global:mockedSearchResultWithUpdate = [PSCustomObject] @{ Updates = @{ @@ -154,7 +154,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'null search result and disabled notification' { @@ -208,7 +208,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'no updates property and disabled notification' { @@ -260,7 +260,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'no updates and disabled notification' { @@ -312,7 +312,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'no updates , disabled notification, and reboot required' { @@ -364,7 +364,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'updates and disable notification' { @@ -416,7 +416,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'updates and other notification' { @@ -468,7 +468,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } } @@ -502,7 +502,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -531,7 +531,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -558,7 +558,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure UpToDate with no updates, disabled notification and reboot requirde' { @@ -584,7 +584,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure UpToDate with updates and disabled notification' { @@ -610,7 +610,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure Disable with updates and disable notification' { @@ -646,7 +646,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure Disable with updates and other notification' { @@ -682,7 +682,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -709,7 +709,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure UpdateNow = $false with updates and other notification' { @@ -745,7 +745,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } } @@ -805,7 +805,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure UpToDate with no updates, mu and disabled notification' { @@ -853,7 +853,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -904,7 +904,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -956,7 +956,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -1004,7 +1004,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure UpToDate with no updates, disabled notification and reboot required' { @@ -1051,7 +1051,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure UpToDate with updates and disabled notification' { @@ -1097,7 +1097,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure UpToDate with updates and disabled notification with reboot after install' { @@ -1158,7 +1158,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } Context 'Ensure Disable with updates and disable notification' { @@ -1216,7 +1216,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -1276,7 +1276,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -1321,7 +1321,7 @@ try } it 'should have called the mock' { - Assert-VerifiableMocks + Assert-VerifiableMock } } @@ -1483,7 +1483,7 @@ try } it "should have called the mock" { - Assert-VerifiableMocks + Assert-VerifiableMock } it "should have created testdrive:\addservice2.txt" { @@ -1603,7 +1603,7 @@ try Assert-MockCalled -CommandName Write-Warning -Times 1 -Exactly -Scope It } - + It 'Calls write-warning when Important updates are requested but not Security updates' { $PropertiesToTest = @{ IsSingleInstance = 'Yes' From 64cae11ab75ea3f24818eb810123ac9cc1f4fdfb Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 19 May 2018 16:17:45 +0200 Subject: [PATCH 02/10] WindowsUpdate: Clarify the description of resources in README.md (#72) - Clarify windows update module readme. - Fix module and resource name confusion. - Add a summary of xWindowsUpdateAgent. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb34e5f..65c8bfd 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,11 @@ dev: [![Build status](https://ci.appveyor.com/api/projects/status/t4bw4lnmxy1dg3 [![codecov](https://codecov.io/gh/PowerShell/xWindowsUpdate/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/xWindowsUpdate) The **xWindowsUpdate** module contains the **xHotfix** and -**xMicrosoftUpdate** DSC resources. **xWindowsUpdate** installs a -Windows Update (or hotfix) from a given path. For more information on -Windows Update and Hotfix, please refer to +**xWindowsUpdateAgent** DSC resources. **xHotfix** installs a +Windows Update (or hotfix) from a given path. +**xWindowsUpdateAgent** will configure the source download settings for the machine, +update notifications on the system, and can automatically initiate installation of the updates. +For more information on Windows Update and Hotfix, please refer to [this TechNet article](http://technet.microsoft.com/en-us/library/cc750077.aspx). **xMicrosoftUpdate** enables or disables Microsoft Update. From fc6267dad24fb8611d3c95bf7975cb69886f4617 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 19 May 2018 16:30:47 +0200 Subject: [PATCH 03/10] Update change log in README.md (#73) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 65c8bfd..bb6f52d 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ Please check out common DSC Resources * Tests no longer fail on `Assert-VerifiableMocks`, these are now renamed to `Assert-VerifiableMock` (breaking change in Pester v4). +* README.md has been updated with correct description of the resources + ([issue #58](https://github.com/PowerShell/xWindowsUpdate/issues/58)). ### 2.7.0.0 From 1afc7a4a45c7eea5e46a01e562860b050b58aa27 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 28 May 2018 13:06:03 +0200 Subject: [PATCH 04/10] xWindowsUpdate: Fix tests failing after update in test framework (#75) - Changes to xWindowsUpdate - Updated appveyor.yml to use the correct parameters to call the test framework. --- README.md | 1 + appveyor.yml | 38 ++++++++++++++++---------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index bb6f52d..8f3940d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Please check out common DSC Resources to `Assert-VerifiableMock` (breaking change in Pester v4). * README.md has been updated with correct description of the resources ([issue #58](https://github.com/PowerShell/xWindowsUpdate/issues/58)). +* Updated appveyor.yml to use the correct parameters to call the test framework. ### 2.7.0.0 diff --git a/appveyor.yml b/appveyor.yml index e86e5b7..d1f677d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,8 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# +#---------------------------------# +# environment configuration # +#---------------------------------# version: 2.5.{build}.0 -install: +install: - git clone https://github.com/PowerShell/DscResource.Tests - ps: | $moduleName = 'xWindowsUpdate' @@ -10,38 +10,32 @@ install: Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" Invoke-AppveyorInstallTask -#---------------------------------# -# build configuration # -#---------------------------------# +#---------------------------------# +# build configuration # +#---------------------------------# build: false -#---------------------------------# -# test configuration # -#---------------------------------# +#---------------------------------# +# test configuration # +#---------------------------------# test_script: - ps: | Invoke-AppveyorTestScriptTask ` -Type 'Default' ` - -MainModulePath $mainModuleFolder ` -ExcludeTag @() ` -CodeCoverage ` -CodeCovIo - -#---------------------------------# -# deployment configuration # -#---------------------------------# -# scripts to run before deployment -deploy_script: +#---------------------------------# +# deployment configuration # +#---------------------------------# + +# scripts to run before deployment +deploy_script: - ps: | Invoke-AppveyorAfterTestTask ` -Type 'Wiki' ` -MainModulePath $mainModuleFolder ` -ResourceModuleName $moduleName - - - - - From b10426e212827ab7a182b6b45f31fb46c9dfa6ae Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 18 Jun 2018 11:51:50 +0200 Subject: [PATCH 05/10] Activate the GitHub App Stale on the GitHub repository (#78) --- .github/stale.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..84f3eaa --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,44 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +limitPerRun: 30 + +pulls: + daysUntilStale: 14 + daysUntilClose: false + exemptProjects: true + exemptMilestones: true + staleLabel: abandoned + exemptLabels: + - needs review + - on hold + - waiting for CLA pass + + markComment: > + Labeling this pull request (PR) as abandoned since it has gone 14 days or more + since the last update. An abandoned PR can be continued by another contributor. + The abandoned label will be removed if work on this PR is taken up again. + +issues: + daysUntilStale: 30 + daysUntilClose: 40 + exemptProjects: true + exemptMilestones: true + staleLabel: stale + exemptLabels: + - bug + - enhancement + - tests + - documentation + - resource proposal + - on hold + + markComment: > + This issue has been automatically marked as stale because + it has not had activity from the community in the last 30 days. It will be + closed if no further activity occurs within 10 days. If the issue is labelled + with any of the work labels (e.g bug, enhancement, documentation, or tests) + then the issue will not auto-close. + + closeComment: > + This issue has been automatically closed because it is has not had activity + from the community in the last 40 days. From b6bc6b4afec64dd28b011b1dbadd3ff8740dc175 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 23 Aug 2018 20:26:44 +0200 Subject: [PATCH 06/10] Add pull request template and issue templates (#80) --- .github/ISSUE_TEMPLATE/General.md | 7 +++ .../ISSUE_TEMPLATE/Problem_with_resource.md | 57 +++++++++++++++++++ .github/ISSUE_TEMPLATE/Resource_proposal.md | 21 +++++++ .github/PULL_REQUEST_TEMPLATE.md | 47 +++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/General.md create mode 100644 .github/ISSUE_TEMPLATE/Problem_with_resource.md create mode 100644 .github/ISSUE_TEMPLATE/Resource_proposal.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/General.md b/.github/ISSUE_TEMPLATE/General.md new file mode 100644 index 0000000..fbcdf24 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/General.md @@ -0,0 +1,7 @@ +--- +name: General question or documentation update +about: If you have a general question or documentation update suggestion around the resource module. +--- + diff --git a/.github/ISSUE_TEMPLATE/Problem_with_resource.md b/.github/ISSUE_TEMPLATE/Problem_with_resource.md new file mode 100644 index 0000000..2431f65 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Problem_with_resource.md @@ -0,0 +1,57 @@ +--- +name: Problem with a resource +about: If you have a problem, bug, or enhancement with a resource in this resource module. +--- + +#### Details of the scenario you tried and the problem that is occurring + +#### Verbose logs showing the problem + +#### Suggested solution to the issue + +#### The DSC configuration that is used to reproduce the issue (as detailed as possible) +```powershell +# insert configuration here +``` + +#### The operating system the target node is running + + +#### Version and build of PowerShell the target node is running + + +#### Version of the DSC module that was used ('dev' if using current dev branch) diff --git a/.github/ISSUE_TEMPLATE/Resource_proposal.md b/.github/ISSUE_TEMPLATE/Resource_proposal.md new file mode 100644 index 0000000..9f2a069 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Resource_proposal.md @@ -0,0 +1,21 @@ +--- +name: New resource proposal +about: If you have a new resource proposal that you think should be added to this resource module. +--- + +### Description + +### Proposed properties + +### Special considerations or limitations diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..84e1ea8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,47 @@ + +#### Pull Request (PR) description + + +#### This Pull Request (PR) fixes the following issues + + +#### Task list + +- [ ] Added an entry under the Unreleased section of the change log in the README.md. + Entry should say what was changed, and how that affects users (if applicable). +- [ ] Resource documentation added/updated in README.md. +- [ ] Resource parameter descriptions added/updated in README.md, schema.mof + and comment-based help. +- [ ] Comment-based help added/updated. +- [ ] Localization strings added/updated in all localization files as appropriate. +- [ ] Examples appropriately added/updated. +- [ ] Unit tests added/updated. See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). +- [ ] Integration tests added/updated (where possible). See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md). +- [ ] New/changed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md). From bd314ec1942981b06dba6fded346a0dc25012b26 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 22 Sep 2018 17:10:41 +0200 Subject: [PATCH 07/10] Update to use template files (#81) --- .gitattributes | 2 ++ .gitignore | 3 +- .vscode/analyzersettings.psd1 | 53 +++++++++++++++++++++++++++++++++++ .vscode/settings.json | 14 +++++++++ README.md | 3 ++ appveyor.yml | 31 ++++++++++---------- 6 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 .gitattributes create mode 100644 .vscode/analyzersettings.psd1 create mode 100644 .vscode/settings.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5613d53 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Needed for publishing of examples, build worker defaults to core.autocrlf=input. +* text eol=crlf diff --git a/.gitignore b/.gitignore index add5492..b03606a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -/DSCResource.Tests - +DSCResource.Tests diff --git a/.vscode/analyzersettings.psd1 b/.vscode/analyzersettings.psd1 new file mode 100644 index 0000000..be415e4 --- /dev/null +++ b/.vscode/analyzersettings.psd1 @@ -0,0 +1,53 @@ +@{ + <# + For the custom rules to work, the DscResource.Tests repo must be + cloned. It is automatically clone as soon as any unit or + integration tests are run. + #> + CustomRulePath = '.\DSCResource.Tests\DscResource.AnalyzerRules' + + IncludeRules = @( + # DSC Resource Kit style guideline rules. + 'PSAvoidDefaultValueForMandatoryParameter', + 'PSAvoidDefaultValueSwitchParameter', + 'PSAvoidInvokingEmptyMembers', + 'PSAvoidNullOrEmptyHelpMessageAttribute', + 'PSAvoidUsingCmdletAliases', + 'PSAvoidUsingComputerNameHardcoded', + 'PSAvoidUsingDeprecatedManifestFields', + 'PSAvoidUsingEmptyCatchBlock', + 'PSAvoidUsingInvokeExpression', + 'PSAvoidUsingPositionalParameters', + 'PSAvoidShouldContinueWithoutForce', + 'PSAvoidUsingWMICmdlet', + 'PSAvoidUsingWriteHost', + 'PSDSCReturnCorrectTypesForDSCFunctions', + 'PSDSCStandardDSCFunctionsInResource', + 'PSDSCUseIdenticalMandatoryParametersForDSC', + 'PSDSCUseIdenticalParametersForDSC', + 'PSMisleadingBacktick', + 'PSMissingModuleManifestField', + 'PSPossibleIncorrectComparisonWithNull', + 'PSProvideCommentHelp', + 'PSReservedCmdletChar', + 'PSReservedParams', + 'PSUseApprovedVerbs', + 'PSUseCmdletCorrectly', + 'PSUseOutputTypeCorrectly', + 'PSAvoidGlobalVars', + 'PSAvoidUsingConvertToSecureStringWithPlainText', + 'PSAvoidUsingPlainTextForPassword', + 'PSAvoidUsingUsernameAndPasswordParams', + 'PSDSCUseVerboseMessageInDSCResource', + 'PSShouldProcess', + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSUsePSCredentialType', + + <# + This is to test all the DSC Resource Kit custom rules. + The name of the function-blocks of each custom rule start + with 'Measure*'. + #> + 'Measure-*' + ) +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0969e57 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "powershell.codeFormatting.openBraceOnSameLine": false, + "powershell.codeFormatting.newLineAfterOpenBrace": false, + "powershell.codeFormatting.newLineAfterCloseBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenParen": true, + "powershell.codeFormatting.whitespaceAroundOperator": true, + "powershell.codeFormatting.whitespaceAfterSeparator": true, + "powershell.codeFormatting.ignoreOneLineBlock": false, + "powershell.codeFormatting.preset": "Custom", + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1" +} diff --git a/README.md b/README.md index 8f3940d..3e9de9b 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,9 @@ Please check out common DSC Resources * README.md has been updated with correct description of the resources ([issue #58](https://github.com/PowerShell/xWindowsUpdate/issues/58)). * Updated appveyor.yml to use the correct parameters to call the test framework. +* Update appveyor.yml to use the default template. +* Added default template files .gitattributes, and .gitignore, and + .vscode folder. ### 2.7.0.0 diff --git a/appveyor.yml b/appveyor.yml index d1f677d..3b06625 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,14 +1,17 @@ #---------------------------------# # environment configuration # #---------------------------------# + version: 2.5.{build}.0 +environment: + gallery_api: + secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv + install: - git clone https://github.com/PowerShell/DscResource.Tests - - ps: | - $moduleName = 'xWindowsUpdate' - $mainModuleFolder = ".\" - Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorInstallTask + - ps: Write-Verbose -Message "PowerShell version $($PSVersionTable.PSVersion)" -Verbose + - ps: Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" + - ps: Invoke-AppveyorInstallTask #---------------------------------# # build configuration # @@ -22,20 +25,18 @@ build: false test_script: - ps: | - Invoke-AppveyorTestScriptTask ` - -Type 'Default' ` - -ExcludeTag @() ` - -CodeCoverage ` - -CodeCovIo + Invoke-AppveyorTestScriptTask -CodeCoverage -CodeCovIo + +# scripts to run before deployment +after_test: + - ps: | + Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" + Invoke-AppveyorAfterTestTask #---------------------------------# # deployment configuration # #---------------------------------# -# scripts to run before deployment deploy_script: - ps: | - Invoke-AppveyorAfterTestTask ` - -Type 'Wiki' ` - -MainModulePath $mainModuleFolder ` - -ResourceModuleName $moduleName + Invoke-AppVeyorDeployTask From ec6a3de0a0292d1896d985b569b6baa8f22c5d75 Mon Sep 17 00:00:00 2001 From: Chirishman Date: Mon, 25 Mar 2019 03:09:31 -0400 Subject: [PATCH 08/10] Fixed Verbose Statement Returning Incorrect Variable (#83) * Merge pull request #1 from PowerShell/dev updates * Fix to Verbose Statement * Second instance of wrong variable found --- .../MSFT_xWindowsUpdateAgent.psm1 | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.psm1 b/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.psm1 index 2e0e97f..dcad632 100644 --- a/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.psm1 +++ b/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.psm1 @@ -11,15 +11,15 @@ function Add-WuaService [Parameter(Mandatory=$true)] [string] $ServiceId, - - [int] + + [int] $Flags = 7, - + [string] $AuthorizationCabPath = [string]::Empty - + ) - + $wuaServiceManager = Get-WuaServiceManager $wuaServiceManager.AddService2($ServiceId, $Flags, $AuthorizationCabPath) } @@ -31,7 +31,7 @@ function Remove-WuaService [string] $ServiceId ) - + $wuaServiceManager = Get-WuaServiceManager $wuaServiceManager.RemoveService($ServiceId) } @@ -44,7 +44,7 @@ function Get-WuaSearchString [switch] $optional, [switch] - $important + $important ) $securityCategoryId = "'0FA1201D-4330-4FA8-8AE9-B877473B6441'" <# @@ -65,46 +65,46 @@ function Get-WuaSearchString # security and optional and not important elseif ($security -and $optional) { # or can only be used at the top most boolean expression - return "(IsAssigned=0 and IsHidden=0 and IsInstalled=0) or (CategoryIds contains $securityCategoryId and IsHidden=0 and IsInstalled=0)" + return "(IsAssigned=0 and IsHidden=0 and IsInstalled=0) or (CategoryIds contains $securityCategoryId and IsHidden=0 and IsInstalled=0)" } # security and not optional and important elseif($security -and $important ){ - # Installing everything not hidden, + # Installing everything not hidden, # not optional (optional are not assigned) and not already installed return 'IsAssigned=1 and IsHidden=0 and IsInstalled=0' } elseif ($optional -and $important) { - # Installing everything not hidden, + # Installing everything not hidden, # not optional (optional are not assigned) and not already installed return 'IsHidden=0 and IsInstalled=0' - + } # security and not optional and not important elseif ($security) { - # Installing everything that is security and not hidden, + # Installing everything that is security and not hidden, # and not already installed - return "CategoryIds contains $securityCategoryId and IsHidden=0 and IsInstalled=0" + return "CategoryIds contains $securityCategoryId and IsHidden=0 and IsInstalled=0" } # not security and not optional and important elseif ($important) { - # Installing everything that is not hidden, + # Installing everything that is not hidden, # is assigned (not optional) and not already installed # not valid cannot do not contains or a boolean not # Note important updates will include security updates - return "IsAssigned=1 and IsHidden=0 and IsInstalled=0" + return "IsAssigned=1 and IsHidden=0 and IsInstalled=0" } # not security and optional and not important elseif ($optional) { - # Installing everything that is not hidden, + # Installing everything that is not hidden, # is not assigned (is optional) and not already installed # not valid cannot do not contains or a boolean not - + # Note optional updates may include security updates - return "IsAssigned=0 and IsHidden=0 and IsInstalled=0" + return "IsAssigned=0 and IsHidden=0 and IsInstalled=0" } - + return "CategoryIds contains $securityCategoryId and IsHidden=0 and IsInstalled=0" - + } function Get-WuaAu @@ -188,7 +188,7 @@ function Invoke-WuaDownloadUpdates $downloader.Updates = $UpdateCollection Write-Verbose -Message 'Downloading updates...' -Verbose - $downloadResult = $downloader.Download() + $downloadResult = $downloader.Download() } function Invoke-WuaInstallUpdates @@ -251,9 +251,9 @@ function Get-WuaRebootRequired Write-Verbose -Message 'TryGet RebootRequired...' -Verbose $rebootRequired = (Get-WuaSystemInfo).rebootRequired Write-Verbose -Message "Got rebootRequired: $rebootRequired" -Verbose - return $rebootRequired + return $rebootRequired } -ExceptionReturnValue $true - + } function Get-WuaSession { @@ -267,20 +267,20 @@ function get-WuaSearcher [parameter(Mandatory = $true, ParameterSetName = 'searchString')] [System.String] $SearchString, - + [parameter(ParameterSetName = 'category')] [ValidateSet("Security","Important","Optional")] [AllowEmptyCollection()] [AllowNull()] [System.String[]] $Category= @('Security') - + ) - + $memberSearchString = $SearchString if($PSCmdlet.ParameterSetName -eq 'category') { - $searchStringParams = @{} + $searchStringParams = @{} foreach($CategoryItem in $Category) { $searchStringParams[$CategoryItem]=$true @@ -292,11 +292,11 @@ function get-WuaSearcher param( [parameter(Mandatory = $true)] [System.String] - $memberSearchString + $memberSearchString ) Write-Verbose -Message "Searching for updating using: $memberSearchString" -Verbose - return ((Get-WuaSession).CreateUpdateSearcher()).Search($memberSearchString) - } -argumentList @($memberSearchString) + return ((Get-WuaSession).CreateUpdateSearcher()).Search($memberSearchString) + } -argumentList @($memberSearchString) } function Test-SearchResult @@ -310,7 +310,7 @@ function Test-SearchResult [System.Object] $SearchResult ) - + if(!(@($SearchResult | get-member |Select-Object -ExpandProperty Name) -contains 'Updates')) { Write-Verbose 'Did not find updates on SearchResult' @@ -334,24 +334,24 @@ function Get-TargetResource [ValidateSet("Yes")] [System.String] $IsSingleInstance, - + [ValidateSet("Security","Important","Optional")] [AllowEmptyCollection()] [AllowNull()] [System.String[]] $Category= @('Security'), - + [ValidateSet("Disabled","ScheduledInstallation")] [System.String] $Notifications, - + [parameter(Mandatory = $true)] [ValidateSet("WindowsUpdate","MicrosoftUpdate","WSUS")] [System.String] $Source, - + [bool] - $UpdateNow = $false + $UpdateNow = $false ) Test-TargetResourceProperties @PSBoundParameters @@ -365,7 +365,7 @@ function Get-TargetResource $totalUpdatesNotInstalled = 0 if($SearchResult -and (Test-SearchResult -SearchResult $SearchResult)) { - $totalUpdatesNotInstalled = $SearchResult.Updates.Count + $totalUpdatesNotInstalled = $SearchResult.Updates.Count } $UpdateNowReturn = $false if($totalUpdatesNotInstalled -eq 0 -and !$rebootRequired) @@ -376,9 +376,9 @@ function Get-TargetResource $notificationLevel = (Get-WuaAuNotificationLevel) - + $CategoryReturn = $Category - + $SourceReturn = 'WindowsUpdate' $UpdateServices = (Get-WuaServiceManager).Services #Check if the microsoft update service is registered @@ -391,12 +391,12 @@ function Get-TargetResource elseif ($defaultService.IsManaged) { $SourceReturn = 'WSUS' } - + $returnValue = @{ IsSingleInstance = 'Yes' Category = $CategoryReturn - AutomaticUpdatesNotificationSetting = $notificationLevel - TotalUpdatesNotInstalled = $totalUpdatesNotInstalled + AutomaticUpdatesNotificationSetting = $notificationLevel + TotalUpdatesNotInstalled = $totalUpdatesNotInstalled RebootRequired = $rebootRequired Notifications = $notificationLevel Source = $SourceReturn @@ -409,7 +409,7 @@ function Get-TargetResource function Set-TargetResource { # should be [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidGlobalVars", "DSCMachineStatus")], but it doesn't work - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidGlobalVars", "")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidGlobalVars", "")] [CmdletBinding(SupportsShouldProcess=$true)] param ( @@ -417,26 +417,26 @@ function Set-TargetResource [ValidateSet("Yes")] [System.String] $IsSingleInstance, - + [ValidateSet("Security","Important","Optional")] [System.String[]] $Category= @('Security'), - + [ValidateSet("Disabled","ScheduledInstallation")] [System.String] $Notifications, - + [parameter(Mandatory = $true)] [ValidateSet("WindowsUpdate","MicrosoftUpdate","WSUS")] [System.String] $Source, - + [bool] - $UpdateNow = $false + $UpdateNow = $false ) Test-TargetResourceProperties @PSBoundParameters - + $Get = Get-TargetResource @PSBoundParameters $updateCompliant = ($UpdateNow -eq $false -or $Get.UpdateNow -eq $UpdateNow) @@ -444,7 +444,7 @@ function Set-TargetResource $notificationCompliant = (!$Notifications -or $Notifications -eq $Get.Notifications) Write-Verbose "notifications compliant: $notificationCompliant" $SourceCompliant = (!$Source -or $Source -eq $Get.Source) - Write-Verbose "service compliant: $notificationCompliant" + Write-Verbose "service compliant: $SourceCompliant" If(!$updateCompliant -and $PSCmdlet.ShouldProcess("Install Updates")) { @@ -458,9 +458,9 @@ function Set-TargetResource $title = $update.Title Write-Verbose -Message "Found update: $Title" -Verbose } - + Invoke-WuaDownloadUpdates -UpdateCollection $SearchResult.Updates - + Invoke-WuaInstallUpdates -UpdateCollection $SearchResult.Updates @@ -494,7 +494,7 @@ function Set-TargetResource $ErrorMsg = $_.Exception.Message Write-Verbose $ErrorMsg } - } + } If(!$SourceCompliant ) { @@ -506,7 +506,7 @@ function Set-TargetResource } elseif($PSCmdlet.ShouldProcess("Disable Microsoft Update Service")) { Write-Verbose "Disable the Microsoft Update setting" - Remove-WuaService -ServiceId '7971f918-a847-4430-9279-4a52d1efe18d' + Remove-WuaService -ServiceId '7971f918-a847-4430-9279-4a52d1efe18d' } } @@ -523,22 +523,22 @@ function Test-TargetResource [ValidateSet("Yes")] [System.String] $IsSingleInstance, - + [ValidateSet("Security","Important","Optional")] [System.String[]] $Category= @('Security'), - + [ValidateSet("Disabled","ScheduledInstallation")] [System.String] $Notifications, - + [parameter(Mandatory = $true)] [ValidateSet("WindowsUpdate","MicrosoftUpdate","WSUS")] [System.String] $Source, - + [bool] - $UpdateNow = $false + $UpdateNow = $false ) Test-TargetResourceProperties @PSBoundParameters @@ -550,7 +550,7 @@ function Test-TargetResource $notificationCompliant = (!$Notifications -or $Notifications -eq $Get.Notifications) Write-Verbose "notifications compliant: $notificationCompliant" $SourceCompliant = (!$Source -or $Source -eq $Get.Source) - Write-Verbose "service compliant: $notificationCompliant" + Write-Verbose "service compliant: $SourceCompliant" If($updateCompliant -and $notificationCompliant -and $SourceCompliant) { return $true @@ -569,26 +569,26 @@ function Test-TargetResourceProperties [ValidateSet("Yes")] [System.String] $IsSingleInstance, - + [ValidateSet("Security","Important","Optional")] [AllowEmptyCollection()] [AllowNull()] [System.String[]] $Category, - + [ValidateSet("Disabled","ScheduledInstallation")] [System.String] $Notifications, - + [parameter(Mandatory = $true)] [ValidateSet("WindowsUpdate","MicrosoftUpdate","WSUS")] [System.String] $Source, - + [bool] - $UpdateNow + $UpdateNow ) - $searchStringParams = @{} + $searchStringParams = @{} foreach($CategoryItem in $Category) { $searchStringParams[$CategoryItem.ToLowerInvariant()]=$true @@ -596,15 +596,15 @@ function Test-TargetResourceProperties if($UpdateNow -and (!$Category -or $Category.Count -eq 0)) { - Write-Warning 'Defaulting to updating to security updates only. Please specify Category to avoid this warning.' + Write-Warning 'Defaulting to updating to security updates only. Please specify Category to avoid this warning.' } elseif ($searchStringParams.ContainsKey('important') -and !$searchStringParams.ContainsKey('security') ) { - Write-Warning "Important updates will include security updates. Please include Security in category to avoid this warning." + Write-Warning "Important updates will include security updates. Please include Security in category to avoid this warning." } elseif ($searchStringParams.ContainsKey('optional') -and !$searchStringParams.ContainsKey('security') ) { - Write-Verbose "Optional updates may include security updates." + Write-Verbose "Optional updates may include security updates." } - + if($Source -eq 'WSUS') { throw 'The WSUS service option is not implemented.' From db45ece117ac10771deaf8e8daa105041dfc1183 Mon Sep 17 00:00:00 2001 From: Katie Keim Date: Wed, 3 Apr 2019 12:05:29 -0700 Subject: [PATCH 09/10] Add missing release note --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3e9de9b..2469c5c 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Please check out common DSC Resources ### Unreleased +* xWindowsUpdateAgent: Fixed verbose statement returning incorrect variable * Tests no longer fail on `Assert-VerifiableMocks`, these are now renamed to `Assert-VerifiableMock` (breaking change in Pester v4). * README.md has been updated with correct description of the resources From 23384b98710566de1a41324afb0ce4f2c2e077f7 Mon Sep 17 00:00:00 2001 From: Katie Kragenbrink Date: Wed, 3 Apr 2019 12:22:11 -0700 Subject: [PATCH 10/10] Releasing version 2.8.0.0 --- README.md | 2 ++ xWindowsUpdate.psd1 | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2469c5c..71c6039 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ Please check out common DSC Resources ### Unreleased +### 2.8.0.0 + * xWindowsUpdateAgent: Fixed verbose statement returning incorrect variable * Tests no longer fail on `Assert-VerifiableMocks`, these are now renamed to `Assert-VerifiableMock` (breaking change in Pester v4). diff --git a/xWindowsUpdate.psd1 b/xWindowsUpdate.psd1 index f0693d3..0a0aacf 100644 --- a/xWindowsUpdate.psd1 +++ b/xWindowsUpdate.psd1 @@ -1,6 +1,6 @@ @{ # Version number of this module. -ModuleVersion = '2.7.0.0' +moduleVersion = '2.8.0.0' # ID used to uniquely identify this module GUID = 'a9cba250-ea73-4d82-b31b-7e58cc50ffd1' @@ -47,7 +47,15 @@ PrivateData = @{ # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = '* xWindowsUpdateAgent: Fix Get-TargetResource returning incorrect key + ReleaseNotes = '* xWindowsUpdateAgent: Fixed verbose statement returning incorrect variable +* Tests no longer fail on `Assert-VerifiableMocks`, these are now renamed + to `Assert-VerifiableMock` (breaking change in Pester v4). +* README.md has been updated with correct description of the resources + ([issue 58](https://github.com/PowerShell/xWindowsUpdate/issues/58)). +* Updated appveyor.yml to use the correct parameters to call the test framework. +* Update appveyor.yml to use the default template. +* Added default template files .gitattributes, and .gitignore, and + .vscode folder. ' @@ -58,3 +66,4 @@ PrivateData = @{ +