forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Directory.Delete works fine even if user has no ListDirectory …
…permissions (dotnet#56996)
- Loading branch information
1 parent
e543859
commit 27059fb
Showing
4 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/libraries/System.IO.FileSystem/tests/Directory/Delete.Windows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Text; | ||
using Xunit; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
using System.Security.Principal; | ||
using System.Security.AccessControl; | ||
|
||
namespace System.IO.Tests | ||
{ | ||
public partial class Directory_Delete_str_bool : Directory_Delete_str | ||
{ | ||
[Fact] | ||
[PlatformSpecific(TestPlatforms.Windows)] | ||
public void RecursiveDelete_NoListDirectoryPermission() // https://github.com/dotnet/runtime/issues/56922 | ||
{ | ||
string parentPath = GetTestFilePath(); | ||
var parent = Directory.CreateDirectory(parentPath); | ||
var ac = parent.GetAccessControl(); | ||
ac.SetAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().User, FileSystemRights.ListDirectory, AccessControlType.Deny)); | ||
parent.SetAccessControl(ac); | ||
|
||
var subDir = parent.CreateSubdirectory("subdir"); | ||
File.Create(Path.Combine(subDir.FullName, GetTestFileName())).Dispose(); | ||
Delete(subDir.FullName, recursive: true); | ||
Assert.False(subDir.Exists); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters