From 6143545ff304bfb2d27475ab493f1f82b203f62e Mon Sep 17 00:00:00 2001 From: Raimund Andree Date: Sun, 11 Oct 2026 13:22:34 +0000 Subject: [PATCH] test(audit): claim only what the AmbiguousParameterSet rows assert The follow-up review of 7bc7925 found that the two rows added with the fix of the piped AppliesTo (an object with AppliesTo and InheritanceFlags, piped to Add-NTFSAudit and to Remove-NTFSAudit) said that they change nothing but compared the DACL, which these cmdlets never write. The older row of the named call to Add-NTFSAudit had the same title and the same comparison. A rejected call fails while the parameters bind, before ProcessRecord, so the error is the behavior under test. The three rows now say and assert the error only. The rows of the access cmdlets compare the DACL, which is what those cmdlets write, and stay as they are. The focused run of the two ParameterSets files on the package of 9783d2a passes in the four configurations (89 cases; 88, 88, 53, 53 passed). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant --- Tests/ParameterSets.Audit.Tests.ps1 | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Tests/ParameterSets.Audit.Tests.ps1 b/Tests/ParameterSets.Audit.Tests.ps1 index 75f5877..c715f1e 100644 --- a/Tests/ParameterSets.Audit.Tests.ps1 +++ b/Tests/ParameterSets.Audit.Tests.ps1 @@ -212,14 +212,11 @@ Describe 'Add-NTFSAudit' { Get-TestAuditScope -Acl (Get-Acl -LiteralPath $folder -Audit) | Should -BeExactly $Scope } - It 'Should reject a piped object that has both AppliesTo and InheritanceFlags with an AmbiguousParameterSet error and change nothing' { + It 'Should reject a piped object that has both AppliesTo and InheritanceFlags with an AmbiguousParameterSet error' { $folder = New-TestSandboxItem -Sandbox $sandbox -Name 'AddPipedAuditBoth' -Directory - $before = Get-TestDaclSddl -Path $folder $object = [pscustomobject]@{ FullName = $folder; Account = $probe; AccessRights = 'ReadData'; AppliesTo = 'ThisFolderOnly'; InheritanceFlags = 'None' } { $object | Add-NTFSAudit -ErrorAction Stop } | Should -Throw -ErrorId 'AmbiguousParameterSet*' - - Get-TestDaclSddl -Path $folder | Should -BeExactly $before } } @@ -314,14 +311,11 @@ Describe 'Add-NTFSAudit' { } Context 'Conflicting parameters' { - It 'Should reject -AppliesTo combined with -InheritanceFlags with an AmbiguousParameterSet error and change nothing' { + It 'Should reject -AppliesTo combined with -InheritanceFlags with an AmbiguousParameterSet error' { $file = New-TestSandboxItem -Sandbox $sandbox -Name 'AddAmbiguous' - $before = Get-TestDaclSddl -Path $file { Add-NTFSAudit -Path $file -Account $probe -AccessRights ReadData -AppliesTo ThisFolderOnly -InheritanceFlags None -ErrorAction Stop } | Should -Throw -ErrorId 'AmbiguousParameterSet,NTFSSecurity.AddAudit' - - Get-TestDaclSddl -Path $file | Should -BeExactly $before } } @@ -421,14 +415,11 @@ Describe 'Remove-NTFSAudit' { Get-TestAuditScope -Acl (Get-Acl -LiteralPath $folder -Audit) | Should -BeExactly $Left } - It 'Should reject a piped object that has both AppliesTo and InheritanceFlags with an AmbiguousParameterSet error and change nothing' { + It 'Should reject a piped object that has both AppliesTo and InheritanceFlags with an AmbiguousParameterSet error' { $folder = New-TestSandboxItem -Sandbox $sandbox -Name 'RemovePipedAuditBoth' -Directory - $before = Get-TestDaclSddl -Path $folder $object = [pscustomobject]@{ FullName = $folder; Account = $probe; AccessRights = 'ReadData'; AppliesTo = 'ThisFolderOnly'; InheritanceFlags = 'None' } { $object | Remove-NTFSAudit -ErrorAction Stop } | Should -Throw -ErrorId 'AmbiguousParameterSet*' - - Get-TestDaclSddl -Path $folder | Should -BeExactly $before } }