From 460dad6ece5001c0447d79f02d5668b26836673b Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Mon, 11 Mar 2024 15:11:19 -0700 Subject: [PATCH] Testing against latest Carbon.Security release candidate. --- Carbon.Registry/Carbon.Registry.psm1 | 4 +++- ...ApplyTo.ps1 => ConvertTo-CarbonSecurityApplyTo.ps1} | 2 +- .../Functions/Grant-CRegistryPermission.ps1 | 2 +- Carbon.Registry/Functions/Test-CRegistryPermission.ps1 | 2 +- Carbon.Registry/prism.json | 2 +- Carbon.Registry/prism.lock.json | 4 ++-- Tests/Grant-CRegistryPermission.Tests.ps1 | 10 +++++----- Tests/Test-CRegistryPermission.Tests.ps1 | 3 ++- 8 files changed, 16 insertions(+), 13 deletions(-) rename Carbon.Registry/Functions/{ConvertTo-CarbonPermissionsApplyTo.ps1 => ConvertTo-CarbonSecurityApplyTo.ps1} (89%) diff --git a/Carbon.Registry/Carbon.Registry.psm1 b/Carbon.Registry/Carbon.Registry.psm1 index db4c31e..c41001e 100644 --- a/Carbon.Registry/Carbon.Registry.psm1 +++ b/Carbon.Registry/Carbon.Registry.psm1 @@ -24,7 +24,9 @@ Set-StrictMode -Version 'Latest' # module in development has its functions in the Functions directory. $moduleRoot = $PSScriptRoot -Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'Modules\Carbon.Permissions' -Resolve) +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'Modules\Carbon.Security' -Resolve) ` + -Function @('Get-CPermission', 'Grant-CPermission', 'Revoke-CPermission', 'Test-CPermission') ` + -Verbose:$false # Store each of your module's functions in its own file in the Functions # directory. On the build server, your module's functions will be appended to diff --git a/Carbon.Registry/Functions/ConvertTo-CarbonPermissionsApplyTo.ps1 b/Carbon.Registry/Functions/ConvertTo-CarbonSecurityApplyTo.ps1 similarity index 89% rename from Carbon.Registry/Functions/ConvertTo-CarbonPermissionsApplyTo.ps1 rename to Carbon.Registry/Functions/ConvertTo-CarbonSecurityApplyTo.ps1 index 4371cf4..73481bd 100644 --- a/Carbon.Registry/Functions/ConvertTo-CarbonPermissionsApplyTo.ps1 +++ b/Carbon.Registry/Functions/ConvertTo-CarbonSecurityApplyTo.ps1 @@ -1,5 +1,5 @@ -function ConvertTo-CarbonPermissionsApplyTo +function ConvertTo-CarbonSecurityApplyTo { [CmdletBinding()] param( diff --git a/Carbon.Registry/Functions/Grant-CRegistryPermission.ps1 b/Carbon.Registry/Functions/Grant-CRegistryPermission.ps1 index 68b8c7a..08a8769 100644 --- a/Carbon.Registry/Functions/Grant-CRegistryPermission.ps1 +++ b/Carbon.Registry/Functions/Grant-CRegistryPermission.ps1 @@ -128,7 +128,7 @@ function Grant-CRegistryPermission $ApplyTo = 'KeyAndSubkeys' } - $PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonPermissionsApplyTo + $PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonSecurityApplyTo $PSBoundParameters.Remove('OnlyApplyToChildKeys') | Out-Null if ($OnlyApplyToChildKeys) diff --git a/Carbon.Registry/Functions/Test-CRegistryPermission.ps1 b/Carbon.Registry/Functions/Test-CRegistryPermission.ps1 index 3e59b33..4355c12 100644 --- a/Carbon.Registry/Functions/Test-CRegistryPermission.ps1 +++ b/Carbon.Registry/Functions/Test-CRegistryPermission.ps1 @@ -80,7 +80,7 @@ function Test-CRegistryPermission if ($PSCmdlet.ParameterSetName -eq 'TestAppliesToFlags') { - $PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonPermissionsApplyTo + $PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonSecurityApplyTo $PSBoundParameters.Remove('OnlyApplyToChildKeys') | Out-Null if ($OnlyApplyToChildKeys) diff --git a/Carbon.Registry/prism.json b/Carbon.Registry/prism.json index 3a35a18..ef783ef 100644 --- a/Carbon.Registry/prism.json +++ b/Carbon.Registry/prism.json @@ -1,7 +1,7 @@ { "PSModules": [ { - "Name": "Carbon.Permissions", + "Name": "Carbon.Security", "Version": "1.*-*" } ], diff --git a/Carbon.Registry/prism.lock.json b/Carbon.Registry/prism.lock.json index f5709a4..da9ad0a 100644 --- a/Carbon.Registry/prism.lock.json +++ b/Carbon.Registry/prism.lock.json @@ -1,8 +1,8 @@ { "PSModules": [ { - "name": "Carbon.Permissions", - "version": "1.0.0-rc5", + "name": "Carbon.Security", + "version": "1.0.0-rc6", "repositorySourceLocation": "https://www.powershellgallery.com/api/v2" } ] diff --git a/Tests/Grant-CRegistryPermission.Tests.ps1 b/Tests/Grant-CRegistryPermission.Tests.ps1 index abac093..c58d59c 100644 --- a/Tests/Grant-CRegistryPermission.Tests.ps1 +++ b/Tests/Grant-CRegistryPermission.Tests.ps1 @@ -258,10 +258,10 @@ Describe 'Grant-CRegistryPermission' { It 'does not change permission' { Invoke-GrantPermissions -Identity $script:user -Permission FullControl -Path $script:testKeyPath - Mock -CommandName 'Set-Acl' -Verifiable -ModuleName 'Carbon.Permissions' + Mock -CommandName 'Set-Acl' -Verifiable -ModuleName 'Carbon.Security' Invoke-GrantPermissions -Identity $script:user -Permission FullControl -Path $script:testKeyPath - Assert-MockCalled -CommandName 'Set-Acl' -Times 0 -ModuleName 'Carbon.Permissions' + Assert-MockCalled -CommandName 'Set-Acl' -Times 0 -ModuleName 'Carbon.Security' } It 'when changing applies to' { @@ -278,7 +278,7 @@ Describe 'Grant-CRegistryPermission' { -Path $script:testKeyPath ` -ApplyTo KeyAndSubkeys - Mock -CommandName 'Set-Acl' -Verifiable -ModuleName 'Carbon.Permissions' + Mock -CommandName 'Set-Acl' -Verifiable -ModuleName 'Carbon.Security' Grant-CRegistryPermission -Identity $script:user ` -Permission FullControl ` @@ -286,7 +286,7 @@ Describe 'Grant-CRegistryPermission' { -Apply KeyAndSubkeys ` -Force - Assert-MockCalled -CommandName 'Set-Acl' -Times 1 -Exactly -ModuleName 'Carbon.Permissions' + Assert-MockCalled -CommandName 'Set-Acl' -Times 1 -Exactly -ModuleName 'Carbon.Security' } It 'validates path exists' { @@ -297,7 +297,7 @@ Describe 'Grant-CRegistryPermission' { -ErrorAction SilentlyContinue $result | Should -BeNullOrEmpty $Global:Error.Count | Should -BeGreaterThan 0 - $Global:Error[0] | Should -Match 'Cannot find path' + $Global:Error[0] | Should -Match 'path does not exist' } It 'clears existing Permission' { diff --git a/Tests/Test-CRegistryPermission.Tests.ps1 b/Tests/Test-CRegistryPermission.Tests.ps1 index 8ec4573..5f85c5b 100644 --- a/Tests/Test-CRegistryPermission.Tests.ps1 +++ b/Tests/Test-CRegistryPermission.Tests.ps1 @@ -45,7 +45,8 @@ Describe 'Test-CRegistryPermission' { -Permission FullControl ` -ErrorAction SilentlyContinue | Should -BeNullOrEmpty - $Global:Error | Should -HaveCount 2 + $Global:Error | Should -HaveCount 1 + $Global:Error | Should -Match 'path does not exist' } It 'checks ungranted permission' {