Skip to content

Commit

Permalink
Merge pull request #19 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 1.3.0.0 of xSystemSecurity
  • Loading branch information
kwirkykat authored Dec 20, 2017
2 parents 84b485c + c6abbd0 commit f43f49c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function Set-TargetResource
throw "Unable to get ACL for '$Path' as it does not exist"
}

$acl = Get-Acl -Path $Path
$acl = Get-ACLAccess -Path $Path
$accessRules = $acl.Access

if ($Ensure -eq "Present")
Expand Down Expand Up @@ -230,5 +230,9 @@ function Test-TargetResource

return $true
}
Function Get-ACLAccess($Path)
{
return (Get-Item -Path $Path).GetAccessControl('Access')
}

Export-ModuleMember -Function *-TargetResource
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ Please refer to [this article](http://technet.microsoft.com/en-us/library/dd8832

### Unreleased

### 1.3.0.0

* Updated FileSystemACL Set

### 1.2.0.0
* Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.
* Added xFileSystemAccessRule resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ try

It 'New rule - Should compile without throwing' {
{
Invoke-Expression -Command "$($script:DSCResourceName)_NewRule -OutputPath `$TestEnvironment.WorkingFolder"
Invoke-Expression -Command "$($script:DSCResourceName)_NewRule -OutputPath `$TestDrive"
} | Should not throw
}

It "New rule - Should apply without throwing" {
{
Start-DscConfiguration -Path $TestEnvironment.WorkingFolder `
Start-DscConfiguration -Path $TestDrive `
-ComputerName localhost -Wait -Verbose -Force
} | Should not throw
}
Expand All @@ -41,19 +41,19 @@ try
}

It 'New rule - Should have set the resource and all the parameters should match' {
Test-DscConfiguration -Path $TestEnvironment.WorkingFolder | Should Be $true
Test-DscConfiguration -Path $TestDrive | Should Be $true
}


It 'Update rule - Should compile without throwing' {
{
Invoke-Expression -Command "$($script:DSCResourceName)_UpdateRule -OutputPath `$TestEnvironment.WorkingFolder"
Invoke-Expression -Command "$($script:DSCResourceName)_UpdateRule -OutputPath `$TestDrive"
} | Should not throw
}

It "Update rule - Should apply without throwing" {
{
Start-DscConfiguration -Path $TestEnvironment.WorkingFolder `
Start-DscConfiguration -Path $TestDrive `
-ComputerName localhost -Wait -Verbose -Force
} | Should not throw
}
Expand All @@ -64,18 +64,18 @@ try
}

It 'Remove rule - Should have set the resource and all the parameters should match' {
Test-DscConfiguration -Path $TestEnvironment.WorkingFolder | Should Be $true
Test-DscConfiguration -Path $TestDrive | Should Be $true
}

It 'Remove rule - Should compile without throwing' {
{
Invoke-Expression -Command "$($script:DSCResourceName)_RemoveRule -OutputPath `$TestEnvironment.WorkingFolder"
Invoke-Expression -Command "$($script:DSCResourceName)_RemoveRule -OutputPath `$TestDrive"
} | Should not throw
}

It "Remove rule - Should apply without throwing" {
{
Start-DscConfiguration -Path $TestEnvironment.WorkingFolder `
Start-DscConfiguration -Path $TestDrive `
-ComputerName localhost -Wait -Verbose -Force
} | Should not throw
}
Expand All @@ -85,7 +85,7 @@ try
}

It 'New rule - Should have set the resource and all the parameters should match' {
Test-DscConfiguration -Path $TestEnvironment.WorkingFolder | Should Be $true
Test-DscConfiguration -Path $TestDrive | Should Be $true
}


Expand Down
31 changes: 31 additions & 0 deletions Tests/Unit/MSFT_xFileSystemAccessRule.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ try
| Add-Member -MemberType ScriptMethod -Name "RemoveAccessRule" -Value {} -PassThru
}

Mock Get-ACLAccess {
return @{
Access = @()
} | Add-Member -MemberType ScriptMethod -Name "SetAccessRule" -Value {} -PassThru `
| Add-Member -MemberType ScriptMethod -Name "RemoveAccessRule" -Value {} -PassThru
}

It "should return absent from the get method" {
(Get-TargetResource @testParams).Ensure | Should Be "Absent"
}
Expand Down Expand Up @@ -70,6 +77,18 @@ try
| Add-Member -MemberType ScriptMethod -Name "RemoveAccessRule" -Value {} -PassThru
}

Mock Get-ACLAccess {
return @{
Access = @(
@{
IdentityReference = $testParams.Identity
FileSystemRights = [System.Security.AccessControl.FileSystemRights]::FullControl
}
)
} | Add-Member -MemberType ScriptMethod -Name "SetAccessRule" -Value {} -PassThru `
| Add-Member -MemberType ScriptMethod -Name "RemoveAccessRule" -Value {} -PassThru
}

It "should return present from the get method" {
(Get-TargetResource @testParams).Ensure | Should Be "Present"
}
Expand Down Expand Up @@ -129,6 +148,18 @@ try
| Add-Member -MemberType ScriptMethod -Name "RemoveAccessRule" -Value {} -PassThru
}

Mock Get-ACLAccess {
return @{
Access = @(
@{
IdentityReference = $testParams.Identity
FileSystemRights = [System.Security.AccessControl.FileSystemRights]::FullControl
}
)
} | Add-Member -MemberType ScriptMethod -Name "SetAccessRule" -Value {} -PassThru `
| Add-Member -MemberType ScriptMethod -Name "RemoveAccessRule" -Value {} -PassThru
}

It "should return present from the get method" {
(Get-TargetResource @testParams).Ensure | Should Be "Present"
}
Expand Down
9 changes: 6 additions & 3 deletions xSystemSecurity.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@{

# Version number of this module.
ModuleVersion = '1.2.0.0'
ModuleVersion = '1.3.0.0'

# ID used to uniquely identify this module
GUID = 'e30107af-a22a-48fb-b7bc-7d2b98489ac5'
Expand Down Expand Up @@ -36,6 +36,9 @@ VariablesToExport = '*'
# Aliases to export from this module
AliasesToExport = '*'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '4.0'

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

Expand All @@ -54,8 +57,7 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.
* Added xFileSystemAccessRule resource
ReleaseNotes = '* Updated FileSystemACL Set
'

Expand All @@ -65,3 +67,4 @@ PrivateData = @{
}



0 comments on commit f43f49c

Please sign in to comment.