Skip to content

Instantly share code, notes, and snippets.

@duffney
Created August 10, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duffney/793d33d5e603b1d5a7c36aae9f1ce80b to your computer and use it in GitHub Desktop.
Save duffney/793d33d5e603b1d5a7c36aae9f1ce80b to your computer and use it in GitHub Desktop.
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
Describe "Add-ACLAccessRule Tests" {
New-Item -Name Logs -Path 'TestDrive:' -ItemType Directory
$application = 'DevOpsTest'
$splat = @{
Path = 'TestDrive:\Logs'
IdentityReference = 'Everyone'
AccessControlType = 'Allow'
FileSystemRights = 'Modify'
InheritanceFlags = 'ObjectInherit,ContainerInherit'
PropagationFlags = 'None'
}
Add-AclAccessRule @splat
$ACL = (Get-Item $($splat.Path)).GetAccessControl('Access').Access | Where-Object IdentityReference -Match $($splat.IdentityReference)
it "Logs dir should exist" {
Test-Path 'TestDrive:\Logs' | should be $true
}
it "should Not BeNullorEmpty" {
$ACL | should not BeNullorEmpty
}
it "IdentityReference should be [$application]" {
$ACL.IdentityReference | should belike "*$($splat.IdentityReference)*"
}
it "FileSystemRights should be Modify" {
$ACL.FileSystemRights | should be 'Modify, Synchronize'
}
it "AccessControlType should be Allow" {
$ACL.AccessControlType | should be 'Allow'
}
it "IsInherited shoud be False" {
$ACL.IsInherited | should be 'False'
}
it "InheritanceFlags should be ContainerInherit, ObjectInherit" {
$ACL.InheritanceFlags | should be 'ContainerInherit, ObjectInherit'
}
it "PropagationFlags should be None" {
$ACL.PropagationFlags | should be 'None'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment