From 9d6e70df2504939bbe376579aed15e30ed3d43bc Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Sun, 10 Apr 2022 22:51:18 +1200 Subject: [PATCH] Fix and Update Pipeline files to latest pattern - Fixes #507 (#509) --- .github/CONTRIBUTING.md | 4 +- .../ISSUE_TEMPLATE/Problem_with_resource.md | 57 ------------ .../ISSUE_TEMPLATE/Problem_with_resource.yml | 86 +++++++++++++++++++ .github/ISSUE_TEMPLATE/Resource_proposal.md | 21 ----- .github/ISSUE_TEMPLATE/Resource_proposal.yml | 39 +++++++++ .github/ISSUE_TEMPLATE/config.yml | 6 ++ .github/PULL_REQUEST_TEMPLATE.md | 31 ++++--- CHANGELOG.md | 20 +++++ SECURITY.md | 30 +++++++ azure-pipelines.yml | 59 +++++++------ build.yaml | 16 +++- .../DSC_NetAdapterState.psm1 | 7 +- .../en-US/DSC_NetAdapterState.strings.psd1 | 1 + .../DSC_NetAdapterLso.Integration.Tests.ps1 | 45 ++++++++-- .../Integration/DSC_NetAdapterLso.config.ps1 | 13 +-- tests/Unit/DSC_NetAdapterState.Tests.ps1 | 7 +- 16 files changed, 307 insertions(+), 135 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/Problem_with_resource.md create mode 100644 .github/ISSUE_TEMPLATE/Problem_with_resource.yml delete mode 100644 .github/ISSUE_TEMPLATE/Resource_proposal.md create mode 100644 .github/ISSUE_TEMPLATE/Resource_proposal.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 SECURITY.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 79a46819..f6895ab3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1 +1,3 @@ -If you'd like to contribute to this project, please review the [Contribution Guidelines](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md). +# Contributing + +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). diff --git a/.github/ISSUE_TEMPLATE/Problem_with_resource.md b/.github/ISSUE_TEMPLATE/Problem_with_resource.md deleted file mode 100644 index 2431f65c..00000000 --- a/.github/ISSUE_TEMPLATE/Problem_with_resource.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -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/Problem_with_resource.yml b/.github/ISSUE_TEMPLATE/Problem_with_resource.yml new file mode 100644 index 00000000..14205708 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Problem_with_resource.yml @@ -0,0 +1,86 @@ +name: Problem with a resource +description: If you have a problem, bug, or enhancement with a resource in this resource module. +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + Please prefix the issue title (above) with the resource name, e.g. 'ResourceName: Short description of my issue'! + + Your feedback and support is greatly appreciated, thanks for contributing! + - type: textarea + id: description + attributes: + label: Problem description + description: Details of the scenario you tried and the problem that is occurring. + validations: + required: true + - type: textarea + id: logs + attributes: + label: Verbose logs + description: | + Verbose logs showing the problem. **NOTE! Sensitive information should be obfuscated.** _Will be automatically formatted as plain text._ + placeholder: | + Paste verbose logs here + render: text + validations: + required: true + - type: textarea + id: configuration + attributes: + label: DSC configuration + description: | + The DSC configuration that is used to reproduce the issue (as detailed as possible). **NOTE! Sensitive information should be obfuscated.** _Will be automatically formatted as PowerShell code._ + placeholder: | + Paste DSC configuration here + render: powershell + validations: + required: true + - type: textarea + id: suggestedSolution + attributes: + label: Suggested solution + description: Do you have any suggestions how to solve the issue? + validations: + required: true + - type: textarea + id: targetNodeOS + attributes: + label: Operating system the target node is running + description: | + Please provide as much as possible about the target node, for example edition, version, build, and language. _Will be automatically formatted as plain text._ + + On OS with WMF 5.1 the following command can help get this information: `Get-ComputerInfo -Property @('OsName','OsOperatingSystemSKU','OSArchitecture','WindowsVersion','WindowsBuildLabEx','OsLanguage','OsMuiLanguages')` + placeholder: | + Add operating system information here + render: text + validations: + required: true + - type: textarea + id: targetNodePS + attributes: + label: PowerShell version and build the target node is running + description: | + Please provide the version and build of PowerShell the target node is running. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `$PSVersionTable` + placeholder: | + Add PowerShell information here + render: text + validations: + required: true + - type: textarea + id: moduleVersion + attributes: + label: NetworkingDsc version + description: | + Please provide the version of the NetworkingDsc module that was used. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `Get-Module -Name 'NetworkingDsc' -ListAvailable | ft Name,Version,Path` + placeholder: | + Add module information here + render: text + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/Resource_proposal.md b/.github/ISSUE_TEMPLATE/Resource_proposal.md deleted file mode 100644 index 9f2a069a..00000000 --- a/.github/ISSUE_TEMPLATE/Resource_proposal.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -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/ISSUE_TEMPLATE/Resource_proposal.yml b/.github/ISSUE_TEMPLATE/Resource_proposal.yml new file mode 100644 index 00000000..2ddd0986 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Resource_proposal.yml @@ -0,0 +1,39 @@ +name: New resource proposal +description: If you have a new resource proposal that you think should be added to this resource module. +title: "NewResourceName: New resource proposal" +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + Please replace `NewResourceName` in the issue title (above) with your proposed resource name. + + Thank you for contributing and making this resource module better! + - type: textarea + id: description + attributes: + label: Resource proposal + description: Provide information how this resource will/should work and how it will help users. + validations: + required: true + - type: textarea + id: proposedProperties + attributes: + label: Proposed properties + description: | + List all the proposed properties that the resource should have (key, required, write, and/or read). For each property provide a detailed description, the data type, if a default value should be used, and if the property is limited to a set of values. + value: | + Property | Type qualifier | Data type | Description | Default value | Allowed values + --- | --- | --- | --- | --- | --- + PropertyName | Key | String | Detailed description | None | None + validations: + required: true + - type: textarea + id: considerations + attributes: + label: Special considerations or limitations + description: | + Provide any considerations or limitations you can think of that a contributor should take in account when coding the proposed resource, and or what limitations a user will encounter or should consider when using the proposed resource. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..9917040e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,6 @@ +blank_issues_enabled: false +contact_links: + - name: "Virtual PowerShell User Group #DSC channel" + url: https://dsccommunity.org/community/contact/ + about: "To talk to the community and maintainers of DSC Community, please visit the #DSC channel." + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8f9fed13..e9f674de 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,21 +11,29 @@ You may remove this comment block, and the other comment blocks, but please keep the headers and the task list. --> + #### 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 CHANGELOG.md. - Entry should say what was changed, and how that affects users (if applicable). -- [ ] Resource documentation added/updated in README.md in resource folder. -- [ ] Resource parameter descriptions added/updated in schema.mof + +- [ ] Added an entry to the change log under the Unreleased section of the + file CHANGELOG.md. Entry should say what was changed and how that + affects users (if applicable), and reference the issue being resolved + (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). +- [ ] Unit tests added/updated. See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] Integration tests added/updated (where possible). See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] New/changed code adheres to [DSC Community Style Guidelines](https://dsccommunity.org/styleguidelines). diff --git a/CHANGELOG.md b/CHANGELOG.md index 8741e112..f6a7be15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 support for changing proxy settings for current user. BREAKING CHANGE: Added support for configuring proxy settings for a user account by adding `Target` parameter - Fixes [Issue #423](https://github.com/dsccommunity/NetworkingDsc/issues/423). +- Updated .github issue templates to standard - Fixes [Issue #508](https://github.com/dsccommunity/NetworkingDsc/issues/508). +- Added Create_ChangeLog_GitHub_PR task to publish stage of build pipeline. +- Added SECURITY.md. +- Updated pipeline Deploy_Module anb Code_Coverage jobs to use ubuntu-latest + images - Fixes [Issue #508](https://github.com/dsccommunity/NetworkingDsc/issues/508). +- Updated pipeline unit tests and integration tests to use Windows Server 2019 and + Windows Server 2022 images - Fixes [Issue #507](https://github.com/dsccommunity/NetworkingDsc/issues/507). +- NetAdapterState + - Added a new message when setting the state of an adapter. + +### Fixed + +- Fixed pipeline by replacing the GitVersion task in the `azure-pipelines.yml` + with a script. +- NetAdapterState + - Fixed so that the resource is idempotent so that `Enable-NetAdapter` and + `Disable-NetAdapter` are only called when change is required. +- NetAdapterLso + - Fixed integration tests so that they will be skipped if a network adapter + with NDIS version 6 or greater is not available. ## [8.2.0] - 2020-10-16 diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..7bd7bc20 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,30 @@ +## Security + +The DSC Community takes the security of our modules seriously, which includes all source code repositories managed through our GitHub organization. + +If you believe you have found a security vulnerability in any DSC Community owned repository, please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to one or several members of the DSC Community organization. +The easiest way to do so is to send us a direct message via twitter or slack. + +You should receive a response within 48 hours. If for some reason you do not, please follow up to other member of the community. + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + + * Type of issue + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +## Preferred Languages + +We prefer all communications to be in English. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fc0231e9..de6bd0a1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,24 +24,27 @@ stages: - job: Package_Module displayName: 'Package Module' pool: - vmImage: 'ubuntu 16.04' + vmImage: 'ubuntu-latest' steps: - - task: GitVersion@5 - name: gitversion - displayName: 'Evaluate Next Version' - inputs: - runtime: 'core' - configFilePath: 'GitVersion.yml' + - pwsh: | + dotnet tool install --global GitVersion.Tool + $gitVersionObject = dotnet-gitversion | ConvertFrom-Json + $gitVersionObject.PSObject.Properties.ForEach{ + Write-Host -Object "Setting Task Variable '$($_.Name)' with value '$($_.Value)'." + Write-Host -Object "##vso[task.setvariable variable=$($_.Name);]$($_.Value)" + } + Write-Host -Object "##vso[build.updatebuildnumber]$($gitVersionObject.FullSemVer)" + displayName: Calculate ModuleVersion (GitVersion) - task: PowerShell@2 name: package displayName: 'Build & Package Module' inputs: filePath: './build.ps1' - arguments: '-Tasks pack -ResolveDependency' + arguments: '-ResolveDependency -tasks pack' pwsh: true env: - ModuleVersion: $(gitVersion.Informationalversion) + ModuleVersion: $(NuGetVersionV2) - task: PublishPipelineArtifact@1 displayName: 'Publish Pipeline Artifact' @@ -83,10 +86,10 @@ stages: testRunTitle: 'HQRM' condition: succeededOrFailed() - - job: Test_Unit_2016 - displayName: 'Unit (Windows Server 2016)' + - job: Test_Unit_2019 + displayName: 'Unit (Windows Server 2019)' pool: - vmImage: 'vs2017-win2016' + vmImage: 'windows-2019' timeoutInMinutes: 0 steps: - task: DownloadPipelineArtifact@2 @@ -109,7 +112,7 @@ stages: inputs: testResultsFormat: 'NUnit' testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Unit (Windows Server 2016)' + testRunTitle: 'Unit (Windows Server 2019)' condition: succeededOrFailed() - task: PublishPipelineArtifact@1 @@ -121,9 +124,9 @@ stages: - job: Code_Coverage displayName: 'Publish Code Coverage' - dependsOn: Test_Unit_2016 + dependsOn: Test_Unit_2019 pool: - vmImage: 'ubuntu 16.04' + vmImage: 'ubuntu-latest' timeoutInMinutes: 0 steps: - task: DownloadPipelineArtifact@2 @@ -151,10 +154,10 @@ stages: bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml" displayName: 'Publish Code Coverage to Codecov.io' - - job: Test_Integration_2016 - displayName: 'Integration (Windows Server 2016)' + - job: Test_Integration_2019 + displayName: 'Integration (Windows Server 2019)' pool: - vmImage: 'vs2017-win2016' + vmImage: 'windows-2019' timeoutInMinutes: 0 steps: - task: DownloadPipelineArtifact@2 @@ -185,13 +188,13 @@ stages: inputs: testResultsFormat: 'NUnit' testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Integration (Windows Server 2016)' + testRunTitle: 'Integration (Windows Server 2019)' condition: succeededOrFailed() - - job: Test_Unit_2019 - displayName: 'Unit (Windows Server 2019)' + - job: Test_Unit_2022 + displayName: 'Unit (Windows Server 2022)' pool: - vmImage: 'windows-2019' + vmImage: 'windows-2022' timeoutInMinutes: 0 steps: - task: DownloadPipelineArtifact@2 @@ -214,13 +217,13 @@ stages: inputs: testResultsFormat: 'NUnit' testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Unit (Windows Server 2019)' + testRunTitle: 'Unit (Windows Server 2022)' condition: succeededOrFailed() - - job: Test_Integration_2019 - displayName: 'Integration (Windows Server 2019)' + - job: Test_Integration_2022 + displayName: 'Integration (Windows Server 2022)' pool: - vmImage: 'windows-2019' + vmImage: 'windows-2022' timeoutInMinutes: 0 steps: - task: DownloadPipelineArtifact@2 @@ -251,7 +254,7 @@ stages: inputs: testResultsFormat: 'NUnit' testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml' - testRunTitle: 'Integration (Windows Server 2019)' + testRunTitle: 'Integration (Windows Server 2022)' condition: succeededOrFailed() - stage: Deploy @@ -269,7 +272,7 @@ stages: - job: Deploy_Module displayName: 'Deploy Module' pool: - vmImage: 'ubuntu 16.04' + vmImage: 'ubuntu-latest' steps: - task: DownloadPipelineArtifact@2 displayName: 'Download Pipeline Artifact' diff --git a/build.yaml b/build.yaml index acc777d1..0cb7837d 100644 --- a/build.yaml +++ b/build.yaml @@ -48,9 +48,10 @@ BuildWorkflow: - Pester_If_Code_Coverage_Under_Threshold publish: + - publish_module_to_gallery - Publish_Release_To_GitHub - - Publish_Module_To_gallery - Publish_GitHub_Wiki_Content + - Create_ChangeLog_GitHub_PR #################################################### # PESTER Configuration # @@ -108,3 +109,16 @@ GitHubConfig: GitHubConfigUserName: dscbot GitHubConfigUserEmail: dsccommunity@outlook.com UpdateChangelogOnPrerelease: false + +#################################################### +# DscResource.DocGenerator Configuration # +#################################################### +DscResource.DocGenerator: + Generate_Conceptual_Help: + MarkdownCodeRegularExpression: + - '\`(.+?)\`' # Match inline code-block + - '\\(\\)' # Match escaped backslash + - '\[[^\[]+\]\((.+?)\)' # Match markdown URL + - '_(.+?)_' # Match Italic (underscore) + - '\*\*(.+?)\*\*' # Match bold + - '\*(.+?)\*' # Match Italic (asterisk) diff --git a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 index 793801e7..9f8f5645 100644 --- a/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 +++ b/source/DSCResources/DSC_NetAdapterState/DSC_NetAdapterState.psm1 @@ -129,8 +129,13 @@ function Set-TargetResource ) -join '') } - if ($netAdapter) + if ($netAdapter -and $State -ne $netAdapter.State) { + Write-Verbose -Message ( @( + "$($MyInvocation.MyCommand): " + $($script:localizedData.SettingNetAdapterStateMessage -f $Name, $State) + ) -join '') + try { if ($State -eq 'Disabled') diff --git a/source/DSCResources/DSC_NetAdapterState/en-US/DSC_NetAdapterState.strings.psd1 b/source/DSCResources/DSC_NetAdapterState/en-US/DSC_NetAdapterState.strings.psd1 index 7c7533fa..2fa13d6f 100644 --- a/source/DSCResources/DSC_NetAdapterState/en-US/DSC_NetAdapterState.strings.psd1 +++ b/source/DSCResources/DSC_NetAdapterState/en-US/DSC_NetAdapterState.strings.psd1 @@ -2,6 +2,7 @@ ConvertFrom-StringData @' CheckingNetAdapterMessage = Checking if network adapter exists or not. + SettingNetAdapterStateMessage = Setting network adapter '{0}' state to '{1}'. NetAdapterNotFoundMessage = Network adapter '{0}' not found. NetAdapterTestingStateMessage = Checking if adapter '{0}' is in desired state. NetAdapterStateMessage = Network adapter '{0}' returned state '{1}'. diff --git a/tests/Integration/DSC_NetAdapterLso.Integration.Tests.ps1 b/tests/Integration/DSC_NetAdapterLso.Integration.Tests.ps1 index c950b303..c5a1e90c 100644 --- a/tests/Integration/DSC_NetAdapterLso.Integration.Tests.ps1 +++ b/tests/Integration/DSC_NetAdapterLso.Integration.Tests.ps1 @@ -18,17 +18,44 @@ $script:testEnvironment = Initialize-TestEnvironment ` Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +<# + To run these tests a network adapter that has NDIS version of 6 or greater. + If this is not available then the tests will be skipped. +#> +$script:netAdapter = Get-NetAdapter | Where-Object -FilterScript { + $_.NdisVersion -ge 6 +} | Select-Object -First 1 + +if (-not $script:netAdapter) +{ + Write-Verbose -Message ('A network adapter with NDIS version of 6 or greater is required to run these tests. Integration tests will be skipped.') + return +} + # Begin Testing try { Describe 'NetAdapterLso Integration Tests' { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Name = $script:netAdapter.Name + Protocol = 'IPv6' + State = $true + } + ) + } + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile -Verbose -ErrorAction Stop Describe "$($script:dscResourceName)_Integration" { - It 'Should compile and apply the MOF without throwing' { + It 'Should compile without throwing' { { - & "$($script:dscResourceName)_Config" -OutputPath $TestDrive + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData Start-DscConfiguration ` -Path $TestDrive ` @@ -44,13 +71,21 @@ try { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw } + It 'Should be able to call Test-DscConfiguration without throwing' { + { $script:currentState = Test-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should report that DSC is in state' { + $script:currentState | Should -BeTrue + } + It 'Should have set the resource and all the parameters should match' { $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } - $current.Name | Should -Be $TestEnableLsoIPv6.Name - $current.Protocol | Should -Be $TestEnableLsoIPv6.Protocol - $current.State | Should -Be $TestEnableLsoIPv6.State + $current.Name | Should -Be $configData.AllNodes[0].Name + $current.Protocol | Should -Be $configData.AllNodes[0].Protocol + $current.State | Should -Be $configData.AllNodes[0].State } } } diff --git a/tests/Integration/DSC_NetAdapterLso.config.ps1 b/tests/Integration/DSC_NetAdapterLso.config.ps1 index facab487..7efb5308 100644 --- a/tests/Integration/DSC_NetAdapterLso.config.ps1 +++ b/tests/Integration/DSC_NetAdapterLso.config.ps1 @@ -1,19 +1,12 @@ -$NetAdapter = Get-NetAdapter | Where-Object {$_.NdisVersion -ge 6} | Select-Object -First 1 -$TestEnableLsoIPv6 = [PSObject]@{ - Name = $NetAdapter.Name - Protocol = 'IPv6' - State = $true -} - configuration DSC_NetAdapterLso_Config { Import-DscResource -ModuleName NetworkingDsc node localhost { NetAdapterLso Integration_Test { - Name = $TestEnableLsoIPv6.Name - Protocol = $TestEnableLsoIPv6.Protocol - State = $TestEnableLsoIPv6.State + Name = $Node.Name + Protocol = $Node.Protocol + State = $Node.State } } } diff --git a/tests/Unit/DSC_NetAdapterState.Tests.ps1 b/tests/Unit/DSC_NetAdapterState.Tests.ps1 index 308789a7..669d83ca 100644 --- a/tests/Unit/DSC_NetAdapterState.Tests.ps1 +++ b/tests/Unit/DSC_NetAdapterState.Tests.ps1 @@ -38,11 +38,13 @@ try $netAdapterEnabled = [PSCustomObject]@{ Name = 'Ethernet' AdminStatus = [Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetAdapter.NET_IF_ADMIN_STATUS]::Up + State = 'Enabled' } $netAdapterDisabled = [PSCustomObject]@{ Name = 'Ethernet' AdminStatus = [Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetAdapter.NET_IF_ADMIN_STATUS]::Down + State = 'Disabled' } $netAdapterUnsupported = [PSCustomObject]@{ @@ -132,6 +134,7 @@ try $netAdapterEnabled } Mock -CommandName Disable-NetAdapter + Mock -CommandName Enable-NetAdapter It 'Should not throw an exception' { { Set-TargetResource @setTargetResourceEnabled } | Should -Not -Throw @@ -140,6 +143,7 @@ try It 'Should not call Disable-NetAdapter' { Assert-MockCalled -CommandName Get-NetAdapter -Exactly -Times 1 Assert-MockCalled -CommandName Disable-NetAdapter -Exactly -Times 0 + Assert-MockCalled -CommandName Enable-NetAdapter -Exactly -Times 0 } } @@ -165,8 +169,8 @@ try Mock -CommandName Get-NetAdapter -MockWith { $netAdapterDisabled } - Mock -CommandName Enable-NetAdapter Mock -CommandName Disable-NetAdapter + Mock -CommandName Enable-NetAdapter It 'Should not throw an exception' { { Set-TargetResource @setTargetResourceDisabled } | Should -Not -Throw @@ -174,6 +178,7 @@ try It 'Should not call Enable-NetAdapter' { Assert-MockCalled -CommandName Get-NetAdapter -Exactly -Times 1 + Assert-MockCalled -CommandName Disable-NetAdapter -Exactly -Times 0 Assert-MockCalled -CommandName Enable-NetAdapter -Exactly -Times 0 } }