Skip to content

Commit

Permalink
Merge pull request #4 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 3c28114 + 4e4f1ea commit ec82981
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Carbon.FileSystem/Carbon.FileSystem.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) -Verbose:$false
Import-Module -Name (Join-Path -Path $moduleRoot -ChildPath 'Modules\Carbon.Security' -Resolve) `
-Function @('Get-CPermission', 'Grant-CPermission', 'Revoke-CPermission', 'Test-CPermission') `
-Verbose:$false

Add-Type @'
using System;
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.FileSystem/Functions/Grant-CNtfsPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function Grant-CNtfsPermission
$ApplyTo = 'FolderSubfoldersAndFiles'
}

$PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonPermissionsApplyTo
$PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonSecurityApplyTo

if ($PSBoundParameters.ContainsKey('OnlyApplyToChildFilesAndFolders'))
{
Expand Down
2 changes: 1 addition & 1 deletion Carbon.FileSystem/Functions/Test-CNtfsPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function Test-CNtfsPermission
{
if ($ApplyTo)
{
$PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonPermissionsApplyTo
$PSBoundParameters['ApplyTo'] = $ApplyTo | ConvertTo-CarbonSecurityApplyTo
}
$PSBoundParameters.Remove('OnlyApplyToChildFilesAndFolders') | Out-Null
$PSBoundParameters['OnlyApplyToChildren'] = $OnlyApplyToChildFilesAndFolders
Expand Down
2 changes: 1 addition & 1 deletion Carbon.FileSystem/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.FileSystem/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
6 changes: 3 additions & 3 deletions Tests/Grant-CNtfsPermission.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ Describe 'Grant-CNtfsPermission' {
-Path $script:containerPath `
-ApplyTo FolderAndFiles

Mock -CommandName 'Set-Acl' -Verifiable -ModuleName 'Carbon.Permissions'
Mock -CommandName 'Set-Acl' -Verifiable -ModuleName 'Carbon.Security'

Grant-CNtfsPermission -Identity $script:user `
-Permission FullControl `
-Path $script:containerPath `
-Apply FolderAndFiles `
-Force

Should -Invoke 'Set-Acl' -Times 1 -Exactly -ModuleName 'Carbon.Permissions'
Should -Invoke 'Set-Acl' -Times 1 -Exactly -ModuleName 'Carbon.Security'
}

It 'sets permissions on hidden items' {
Expand All @@ -400,7 +400,7 @@ Describe 'Grant-CNtfsPermission' {
-ErrorAction SilentlyContinue
$result | Should -BeNullOrEmpty
$Global:Error.Count | Should -BeGreaterThan 0
$Global:Error[0] | Should -Match 'Cannot find path'
$Global:Error[0] | Should -Match 'that path does not exist'
}

It 'clears permissions on files' {
Expand Down
3 changes: 2 additions & 1 deletion Tests/Test-CNtfsPermission.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Describe 'Test-CNtfsPermission' {
-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

0 comments on commit ec82981

Please sign in to comment.