2018-02-13 18:23:53 +01:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# Licensed under the MIT License.
|
2016-08-22 23:56:04 +02:00
|
|
|
Describe "Acl cmdlets are available and operate properly" -Tag CI {
|
|
|
|
It "Get-Acl returns an ACL object" -pending:(!$IsWindows) {
|
|
|
|
$ACL = get-acl $TESTDRIVE
|
2020-01-24 20:00:37 +01:00
|
|
|
$ACL | Should -BeOfType System.Security.AccessControl.DirectorySecurity
|
2016-08-22 23:56:04 +02:00
|
|
|
}
|
|
|
|
It "Set-Acl can set the ACL of a directory" -pending {
|
|
|
|
Setup -d testdir
|
|
|
|
$directory = "$TESTDRIVE/testdir"
|
|
|
|
$acl = get-acl $directory
|
|
|
|
$accessRule = [System.Security.AccessControl.FileSystemAccessRule]::New("Everyone","FullControl","ContainerInherit,ObjectInherit","None","Allow")
|
|
|
|
$acl.AddAccessRule($accessRule)
|
2018-03-23 18:41:14 +01:00
|
|
|
{ $acl | Set-Acl $directory } | Should -Not -Throw
|
2017-01-16 22:31:14 +01:00
|
|
|
|
2016-08-22 23:56:04 +02:00
|
|
|
$newacl = get-acl $directory
|
2017-07-22 06:03:49 +02:00
|
|
|
$newrule = $newacl.Access | Where-Object { $accessrule.FileSystemRights -eq $_.FileSystemRights -and $accessrule.AccessControlType -eq $_.AccessControlType -and $accessrule.IdentityReference -eq $_.IdentityReference }
|
2018-03-23 18:41:14 +01:00
|
|
|
$newrule | Should -Not -BeNullOrEmpty
|
2016-08-22 23:56:04 +02:00
|
|
|
}
|
|
|
|
}
|