Skip to content

Commit

Permalink
Merge pull request #5 from webmd-health-services/feature/switch-to-ca…
Browse files Browse the repository at this point in the history
…rbon.security

Use latest Carbon.Security (née Carbon.Permissions) release candidate
  • Loading branch information
splatteredbits authored Mar 12, 2024
2 parents 43ac11f + 2299b36 commit cae1ff9
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Carbon.Registry/Carbon.Registry.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function ConvertTo-CarbonPermissionsApplyTo
function ConvertTo-CarbonSecurityApplyTo
{
[CmdletBinding()]
param(
Expand Down
2 changes: 1 addition & 1 deletion Carbon.Registry/Functions/Grant-CRegistryPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Carbon.Registry/Functions/Test-CRegistryPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Carbon.Registry/prism.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"PSModules": [
{
"Name": "Carbon.Permissions",
"Name": "Carbon.Security",
"Version": "1.*-*"
}
],
Expand Down
4 changes: 2 additions & 2 deletions Carbon.Registry/prism.lock.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
Expand Down
10 changes: 5 additions & 5 deletions Tests/Grant-CRegistryPermission.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand All @@ -278,15 +278,15 @@ 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 `
-Path $script:testKeyPath `
-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' {
Expand All @@ -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' {
Expand Down
3 changes: 2 additions & 1 deletion Tests/Test-CRegistryPermission.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down
1 change: 1 addition & 0 deletions whiskey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Build:
Prerelease:
- main: ""
- "*": rc1
IncrementPrereleaseVersion: true

- PowerShell:
WorkingDirectory: Carbon.Registry
Expand Down

0 comments on commit cae1ff9

Please sign in to comment.