Skip to content

Commit 29db5e1

Browse files
authored
Pester 5 Migration - Rename resources from MSFT to DSC (#66)
* Add repo changes * HQRM fixes * Disable all tests * Remove exports * Migrate Cipher * Update strings * Rename MSFT to DSC * Update changelog * Rename strings * Rename remaining resources * Migrate CipherSuites * Remove unused strings * Migrate Hash * Fix example * Fix json format * Migrate KeyExchangeAlgo * Remove old file * Migrate Protocol * Migrate SChannelSettings * Convert .Common * Remove unused functions * Review comments * Fix verbose message * Align strings to community conventions * Update pipeline to test multiple versions * Remove unknown stage * Fix * Update changelog * Fix parameter filters * Fix test title * Remove unused helper module * Fix title * Update compatibility version * Remove commented code
1 parent 02149c5 commit 29db5e1

75 files changed

Lines changed: 3885 additions & 2607 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/analyzersettings.psd1

Lines changed: 109 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,115 @@
11
@{
2-
CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules'
3-
includeDefaultRules = $true
4-
IncludeRules = @(
5-
# DSC Resource Kit style guideline rules.
6-
'PSAvoidDefaultValueForMandatoryParameter',
7-
'PSAvoidDefaultValueSwitchParameter',
8-
'PSAvoidInvokingEmptyMembers',
9-
'PSAvoidNullOrEmptyHelpMessageAttribute',
10-
'PSAvoidUsingCmdletAliases',
11-
'PSAvoidUsingComputerNameHardcoded',
12-
'PSAvoidUsingDeprecatedManifestFields',
13-
'PSAvoidUsingEmptyCatchBlock',
14-
'PSAvoidUsingInvokeExpression',
15-
'PSAvoidUsingPositionalParameters',
16-
'PSAvoidShouldContinueWithoutForce',
17-
'PSAvoidUsingWMICmdlet',
18-
'PSAvoidUsingWriteHost',
19-
'PSDSCReturnCorrectTypesForDSCFunctions',
20-
'PSDSCStandardDSCFunctionsInResource',
21-
'PSDSCUseIdenticalMandatoryParametersForDSC',
22-
'PSDSCUseIdenticalParametersForDSC',
23-
'PSMisleadingBacktick',
24-
'PSMissingModuleManifestField',
25-
'PSPossibleIncorrectComparisonWithNull',
26-
'PSProvideCommentHelp',
27-
'PSReservedCmdletChar',
28-
'PSReservedParams',
29-
'PSUseApprovedVerbs',
30-
'PSUseCmdletCorrectly',
31-
'PSUseOutputTypeCorrectly',
32-
'PSAvoidGlobalVars',
33-
'PSAvoidUsingConvertToSecureStringWithPlainText',
34-
'PSAvoidUsingPlainTextForPassword',
35-
'PSAvoidUsingUsernameAndPasswordParams',
36-
'PSDSCUseVerboseMessageInDSCResource',
37-
'PSShouldProcess',
38-
'PSUseDeclaredVarsMoreThanAssignments',
39-
'PSUsePSCredentialType',
2+
CustomRulePath = @(
3+
'./output/RequiredModules/DscResource.AnalyzerRules'
4+
'./output/RequiredModules/Indented.ScriptAnalyzerRules'
5+
)
6+
IncludeDefaultRules = $true
7+
IncludeRules = @(
8+
# DSC Community style guideline rules from the module ScriptAnalyzer.
9+
'PSAvoidDefaultValueForMandatoryParameter'
10+
'PSAvoidDefaultValueSwitchParameter'
11+
'PSAvoidInvokingEmptyMembers'
12+
'PSAvoidNullOrEmptyHelpMessageAttribute'
13+
'PSAvoidUsingCmdletAliases'
14+
'PSAvoidUsingComputerNameHardcoded'
15+
'PSAvoidUsingDeprecatedManifestFields'
16+
'PSAvoidUsingEmptyCatchBlock'
17+
'PSAvoidUsingInvokeExpression'
18+
'PSAvoidUsingPositionalParameters'
19+
'PSAvoidShouldContinueWithoutForce'
20+
'PSAvoidUsingWMICmdlet'
21+
'PSAvoidUsingWriteHost'
22+
'PSDSCReturnCorrectTypesForDSCFunctions'
23+
'PSDSCStandardDSCFunctionsInResource'
24+
'PSDSCUseIdenticalMandatoryParametersForDSC'
25+
'PSDSCUseIdenticalParametersForDSC'
26+
'PSMisleadingBacktick'
27+
'PSMissingModuleManifestField'
28+
'PSPossibleIncorrectComparisonWithNull'
29+
'PSProvideCommentHelp'
30+
'PSReservedCmdletChar'
31+
'PSReservedParams'
32+
'PSUseApprovedVerbs'
33+
'PSUseCmdletCorrectly'
34+
'PSUseOutputTypeCorrectly'
35+
'PSAvoidGlobalVars'
36+
'PSAvoidUsingConvertToSecureStringWithPlainText'
37+
'PSAvoidUsingPlainTextForPassword'
38+
'PSAvoidUsingUsernameAndPasswordParams'
39+
'PSDSCUseVerboseMessageInDSCResource'
40+
'PSShouldProcess'
41+
'PSUseDeclaredVarsMoreThanAssignments'
42+
'PSUsePSCredentialType'
43+
44+
# Additional rules from the module ScriptAnalyzer
45+
'PSUseConsistentWhitespace'
46+
'UseCorrectCasing'
47+
'PSPlaceOpenBrace'
48+
'PSPlaceCloseBrace'
49+
'AlignAssignmentStatement'
50+
'AvoidUsingDoubleQuotesForConstantString'
51+
'UseShouldProcessForStateChangingFunctions'
4052

53+
# Rules from the modules DscResource.AnalyzerRules
4154
'Measure-*'
55+
56+
# Rules from the module Indented.ScriptAnalyzerRules
57+
'AvoidCreatingObjectsFromAnEmptyString'
58+
'AvoidDashCharacters'
59+
'AvoidEmptyNamedBlocks'
60+
'AvoidFilter'
61+
'AvoidHelpMessage'
62+
'AvoidNestedFunctions'
63+
'AvoidNewObjectToCreatePSObject'
64+
'AvoidParameterAttributeDefaultValues'
65+
'AvoidProcessWithoutPipeline'
66+
'AvoidSmartQuotes'
67+
'AvoidThrowOutsideOfTry'
68+
'AvoidWriteErrorStop'
69+
'AvoidWriteOutput'
70+
'UseSyntacticallyCorrectExamples'
4271
)
4372

73+
<#
74+
The following types are not rules but parse errors reported by PSScriptAnalyzer
75+
so they cannot be excluded. They need to be filtered out from the result of
76+
Invoke-ScriptAnalyzer.
77+
78+
TypeNotFound - Because classes in the project cannot be found unless built.
79+
RequiresModuleInvalid - Because 'using module' in prefix.ps1 cannot be resolved as source file.
80+
#>
81+
ExcludeRules = @()
82+
83+
Rules = @{
84+
PSUseConsistentWhitespace = @{
85+
Enable = $true
86+
CheckOpenBrace = $true
87+
CheckInnerBrace = $true
88+
CheckOpenParen = $true
89+
CheckOperator = $false
90+
CheckSeparator = $true
91+
CheckPipe = $true
92+
CheckPipeForRedundantWhitespace = $true
93+
CheckParameter = $false
94+
}
95+
96+
PSPlaceOpenBrace = @{
97+
Enable = $true
98+
OnSameLine = $false
99+
NewLineAfter = $true
100+
IgnoreOneLineBlock = $false
101+
}
102+
103+
PSPlaceCloseBrace = @{
104+
Enable = $true
105+
NoEmptyLineBefore = $true
106+
IgnoreOneLineBlock = $false
107+
NewLineAfter = $true
108+
}
109+
110+
PSAlignAssignmentStatement = @{
111+
Enable = $true
112+
CheckHashtable = $true
113+
}
114+
}
44115
}

.vscode/settings.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@
77
"powershell.codeFormatting.whitespaceAroundOperator": true,
88
"powershell.codeFormatting.whitespaceAfterSeparator": true,
99
"powershell.codeFormatting.ignoreOneLineBlock": false,
10-
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline",
10+
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
1111
"powershell.codeFormatting.preset": "Custom",
1212
"powershell.codeFormatting.alignPropertyValuePairs": true,
13+
"powershell.codeFormatting.useConstantStrings": true,
1314
"powershell.developer.bundledModulesPath": "${cwd}/output/RequiredModules",
14-
"powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1",
15+
"powershell.scriptAnalysis.settingsPath": "/.vscode/analyzersettings.psd1",
1516
"powershell.scriptAnalysis.enable": true,
1617
"files.trimTrailingWhitespace": true,
1718
"files.trimFinalNewlines": true,
1819
"files.insertFinalNewline": true,
1920
"files.associations": {
2021
"*.ps1xml": "xml"
2122
},
23+
"cSpell.dictionaries": [
24+
"powershell"
25+
],
2226
"cSpell.words": [
2327
"COMPANYNAME",
2428
"ICONURI",
@@ -32,10 +36,26 @@
3236
"keepachangelog",
3337
"notin",
3438
"pscmdlet",
35-
"steppable"
39+
"steppable",
40+
"HKLM",
41+
"Diffie",
42+
"FIPS"
43+
],
44+
"cSpell.ignorePaths": [
45+
".git"
3646
],
3747
"[markdown]": {
3848
"files.trimTrailingWhitespace": false,
3949
"files.encoding": "utf8"
40-
}
50+
},
51+
"powershell.pester.useLegacyCodeLens": false,
52+
"pester.testFilePath": [
53+
"[tT]ests/[qQ][aA]/*.[tT]ests.[pP][sS]1",
54+
"[tT]ests/[uU]nit/**/*.[tT]ests.[pP][sS]1",
55+
"[tT]ests/[uU]nit/*.[tT]ests.[pP][sS]1"
56+
],
57+
"pester.runTestsInNewProcess": true,
58+
"pester.pesterModulePath": "./output/RequiredModules/Pester",
59+
"powershell.pester.codeLens": true,
60+
"pester.suppressCodeLensNotice": true
4161
}

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Rename SChannelDsc.Utils to SChannelDsc.Common.
1313
- Convert SChannelDsc.Common a buildable nested module.
1414
- Update case on resource README files.
15+
- Converted Unit tests to Pester 5 [issue #42](https://github.com/dsccommunity/SChannelDsc/issues/42).
16+
- Renamed MSFT prefix to DSC [issue #43](https://github.com/dsccommunity/SChannelDsc/issues/43).
17+
- Unit test on both 2022 and 2025.
18+
19+
### Removed
20+
21+
- SChannelDsc.Common
22+
- Convert-SCDscArrayToString
23+
- Convert-SCDscCIMInstanceToString
24+
- Convert-SCDscHashtableToString
25+
- Test-SCDscObjectHasProperty
1526

1627
## [1.5.0] - 2026-01-27
1728

RequiredModules.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
InvokeBuild = 'latest'
1111
PSScriptAnalyzer = 'latest'
12-
Pester = '4.10.1'
12+
Pester = 'latest'
1313
Plaster = 'latest'
1414
ModuleBuilder = 'latest'
1515
ChangelogManagement = 'latest'

azure-pipelines.yml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ stages:
5353
publishLocation: 'pipeline'
5454
parallel: true
5555

56-
- stage: Test
56+
- stage: Quality_Test_and_Unit_Test
57+
displayName: 'Quality Test and Unit Test'
5758
dependsOn: Build
5859
jobs:
5960
- job: Test_HQRM
@@ -67,58 +68,65 @@ stages:
6768
inputs:
6869
buildType: 'current'
6970
artifactName: $(buildArtifactName)
70-
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
71+
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
72+
7173
- task: PowerShell@2
7274
name: test
7375
displayName: 'Run HQRM Test'
7476
inputs:
7577
filePath: './build.ps1'
7678
arguments: '-Tasks hqrmtest'
7779
pwsh: false
80+
7881
- task: PublishTestResults@2
7982
displayName: 'Publish Test Results'
80-
condition: succeededOrFailed()
8183
inputs:
8284
testResultsFormat: 'NUnit'
83-
testResultsFiles: 'output/testResults/NUnit*.xml'
85+
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
8486
testRunTitle: 'HQRM'
87+
condition: succeededOrFailed()
88+
8589

86-
# If several pipeline jobs are running test, consider renaming this job:
8790
- job: Test_Unit
8891
displayName: 'Unit'
92+
strategy:
93+
matrix:
94+
Windows Server 2022:
95+
vmImage: 'windows-2022'
96+
Windows Server 2025:
97+
vmImage: 'windows-2025'
8998
pool:
90-
vmImage: 'windows-latest'
99+
vmImage: $(vmImage)
91100
timeoutInMinutes: '0'
92101
steps:
93102
- task: DownloadPipelineArtifact@2
94-
displayName: 'Download Build Artifact'
103+
displayName: 'Download Pipeline Artifact'
95104
inputs:
96105
buildType: 'current'
97106
artifactName: $(buildArtifactName)
98-
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
107+
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
108+
99109
- task: PowerShell@2
100110
name: test
101111
displayName: 'Run Unit Test'
102112
inputs:
103113
filePath: './build.ps1'
104114
arguments: "-Tasks test -PesterScript 'tests/Unit'"
105115
pwsh: true
116+
106117
- task: PublishTestResults@2
107118
displayName: 'Publish Test Results'
108-
condition: succeededOrFailed()
109119
inputs:
110120
testResultsFormat: 'NUnit'
111121
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
112-
# If several pipeline jobs are generating test result, consider renaming this title:
113-
testRunTitle: 'Unit'
122+
testRunTitle: 'Unit $(vmImage)'
123+
condition: succeededOrFailed()
124+
114125
- task: PublishPipelineArtifact@1
115126
displayName: 'Publish Test Artifact'
116127
inputs:
117128
targetPath: '$(buildFolderName)/$(testResultFolderName)/'
118-
artifactName: $(testArtifactName)
119-
# If several pipeline jobs are generating code coverage, replace above with this:
120-
#artifactName: 'CodeCoverageWindows' # Can be any, in the pipeline, unique name
121-
parallel: true
129+
artifactName: '$(testArtifactName)_$(vmImage)'
122130

123131
- job: Code_Coverage
124132
displayName: 'Publish Code Coverage'
@@ -128,33 +136,40 @@ stages:
128136
timeoutInMinutes: '0'
129137
steps:
130138
- task: DownloadPipelineArtifact@2
131-
displayName: 'Download Build Artifact'
139+
displayName: 'Download Pipeline Artifact'
132140
inputs:
133141
buildType: 'current'
134142
artifactName: $(buildArtifactName)
135-
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
143+
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
136144

137145
- task: DownloadPipelineArtifact@2
138146
displayName: 'Download Test Artifact'
139147
inputs:
140148
buildType: 'current'
141-
artifactName: $(testArtifactName)
142149
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)'
150+
itemPattern: '$(testArtifactName)_*/**'
151+
152+
- task: PowerShell@2
153+
name: merge
154+
displayName: 'Merge Code Coverage files'
155+
inputs:
156+
filePath: './build.ps1'
157+
arguments: '-tasks merge'
158+
pwsh: true
143159

144160
- task: PublishCodeCoverageResults@2
145161
displayName: 'Publish Code Coverage to Azure DevOps'
146-
condition: succeededOrFailed()
147162
inputs:
148163
summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml'
149164
pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/'
150165

151166
- script: |
152167
bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml"
153168
displayName: 'Publish Code Coverage to Codecov.io'
154-
condition: succeededOrFailed()
155169
156170
- stage: Deploy
157-
dependsOn: Test
171+
dependsOn:
172+
- Quality_Test_and_Unit_Test
158173
condition: |
159174
and(
160175
succeeded(),

0 commit comments

Comments
 (0)