mirror of https://github.com/raandree/NTFSSecurity
committed by
GitHub
15 changed files with 223 additions and 66 deletions
@ -0,0 +1,24 @@ |
|||
--- |
|||
status: accepted |
|||
date: 2026-10-04 |
|||
last-verified: 2026-10-04 |
|||
owner: shared |
|||
source: maintainer decisions in work package 4 |
|||
--- |
|||
|
|||
# Decision 10: One version for the manifest, assemblies, and changelog |
|||
|
|||
- Choice: `ModuleVersion` in `NTFSSecurity.psd1`, `AssemblyVersion` and |
|||
`AssemblyFileVersion` of `NTFSSecurity`, `Security2`, and |
|||
`PrivilegeControl` (as `x.y.z.0`), and the latest version section of |
|||
`CHANGELOG.md` carry the same version. The vendored `ProcessPrivileges` |
|||
and the unshipped `Log` keep their own versions. |
|||
`Tests\Manifest.Tests.ps1` enforces this. |
|||
- Rationale: Before, the manifest said 4.2.5, the release 4.2.6, and the |
|||
assemblies 4.2.1.0, 3.2.3.0, and 1.0.0.0; releases bumped the version |
|||
only in the published copy. One version, set in the repository before |
|||
the release, identifies a build. |
|||
- Consequence: A version bump changes all five places in one commit. The |
|||
date of the version section is the release date; update it when you tag. |
|||
- Context: 5.0.0 is major because the minimum PowerShell version rose to |
|||
5.1. `Remove-Item2 -PassThur` stays as a deprecated alias of `-PassThru`. |
|||
@ -0,0 +1,73 @@ |
|||
<# |
|||
Tests the module manifest of the module built in NTFSSecurity\bin\Release: it passes Test-ModuleManifest, |
|||
exports exactly the cmdlets of the module, and carries the same version as the assemblies and CHANGELOG.md. |
|||
#> |
|||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute( |
|||
'PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Pester shares variables between blocks.' |
|||
)] |
|||
param () |
|||
|
|||
BeforeDiscovery { |
|||
# The first-party assemblies of the module carry the module version; ProcessPrivileges is a vendored library. |
|||
$versionedAssemblies = 'NTFSSecurity', 'Security2', 'PrivilegeControl' |
|||
} |
|||
|
|||
Describe 'Module manifest of NTFSSecurity' { |
|||
BeforeAll { |
|||
$manifestPath = Join-Path -Path $PSScriptRoot -ChildPath '..\NTFSSecurity\bin\Release\NTFSSecurity.psd1' |
|||
$manifest = Import-PowerShellDataFile -Path $manifestPath |
|||
$module = Import-Module -Name $manifestPath -Force -PassThru -ErrorAction Stop | |
|||
Where-Object -Property Name -EQ -Value 'NTFSSecurity' |
|||
} |
|||
|
|||
AfterAll { |
|||
Remove-Module -Name NTFSSecurity -Force -ErrorAction SilentlyContinue |
|||
} |
|||
|
|||
It 'Should pass Test-ModuleManifest without errors or warnings' { |
|||
$testParameters = @{ |
|||
Path = $manifestPath |
|||
ErrorVariable = 'manifestErrors' |
|||
WarningVariable = 'manifestWarnings' |
|||
ErrorAction = 'SilentlyContinue' |
|||
WarningAction = 'SilentlyContinue' |
|||
} |
|||
$null = Test-ModuleManifest @testParameters |
|||
|
|||
@($manifestErrors) + @($manifestWarnings) | ForEach-Object -Process { "$_" } | Should -BeNullOrEmpty |
|||
} |
|||
|
|||
It 'Should list each cmdlet only once in CmdletsToExport' { |
|||
$duplicates = $manifest.CmdletsToExport | Group-Object | Where-Object -Property Count -GT -Value 1 |
|||
|
|||
$duplicates.Name | Should -BeNullOrEmpty |
|||
} |
|||
|
|||
It 'Should list only cmdlets of the module in CmdletsToExport' { |
|||
$manifest.CmdletsToExport | Where-Object -FilterScript { -not $module.ExportedCmdlets.ContainsKey($_) } | |
|||
Should -BeNullOrEmpty |
|||
} |
|||
|
|||
It 'Should export exactly 36 cmdlets' { |
|||
@($manifest.CmdletsToExport) | Should -HaveCount 36 |
|||
$module.ExportedCmdlets.Keys | Should -HaveCount 36 |
|||
} |
|||
|
|||
Context 'Version' { |
|||
It 'Should give <_>.dll the module version' -ForEach $versionedAssemblies { |
|||
$assemblyPath = Join-Path -Path $module.ModuleBase -ChildPath "$_.dll" |
|||
$assemblyVersion = [Reflection.AssemblyName]::GetAssemblyName($assemblyPath).Version |
|||
$fileVersion = [version] (Get-Item -LiteralPath $assemblyPath).VersionInfo.FileVersion |
|||
|
|||
$assemblyVersion.ToString(3) | Should -BeExactly $manifest.ModuleVersion |
|||
$fileVersion.ToString(3) | Should -BeExactly $manifest.ModuleVersion |
|||
} |
|||
|
|||
It 'Should describe the module version in the latest section of CHANGELOG.md' { |
|||
$changelog = Get-Content -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath '..\CHANGELOG.md') -Raw |
|||
$latestVersion = [regex]::Match($changelog, '(?m)^## \[(?<Version>\d+\.\d+\.\d+)\]').Groups['Version'].Value |
|||
|
|||
$latestVersion | Should -BeExactly $manifest.ModuleVersion |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<# |
|||
Tests Remove-Item2 of the module built in NTFSSecurity\bin\Release. |
|||
#> |
|||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute( |
|||
'PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Pester shares variables between blocks.' |
|||
)] |
|||
param () |
|||
|
|||
Describe 'Remove-Item2' { |
|||
BeforeAll { |
|||
$modulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\NTFSSecurity\bin\Release\NTFSSecurity.psd1' |
|||
Import-Module -Name $modulePath -Force -ErrorAction Stop |
|||
} |
|||
|
|||
AfterAll { |
|||
Remove-Module -Name NTFSSecurity -Force -ErrorAction SilentlyContinue |
|||
} |
|||
|
|||
Context 'When called with -PassThur, the parameter name in 4.2.6 and earlier' { |
|||
BeforeAll { |
|||
$path = Join-Path -Path $TestDrive -ChildPath 'PassThur.txt' |
|||
Set-Content -LiteralPath $path -Value 'Remove-Item2 test' |
|||
|
|||
$removedItem = Remove-Item2 -Path $path -PassThur |
|||
} |
|||
|
|||
It 'Should delete the file' { |
|||
$path | Should -Not -Exist |
|||
} |
|||
|
|||
It 'Should return the deleted file, like -PassThru' { |
|||
$removedItem.Name | Should -BeExactly 'PassThur.txt' |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue