-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix: throw an UnauthorizedAccessException immediately when enumerating a directory without access
#860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: throw an UnauthorizedAccessException immediately when enumerating a directory without access
#860
Conversation
…ing a directory without access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where UnauthorizedAccessException was not thrown immediately when attempting to enumerate directories without proper access. The fix moves the access control check from inside the enumeration implementation to before enumeration begins, ensuring the exception is thrown synchronously rather than when the enumeration is actually consumed.
Key Changes
- Access control validation is now performed immediately when enumeration methods are called
- Refactored enumeration implementation to separate access checking from the actual enumeration logic
- Added comprehensive tests to verify the immediate exception behavior
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs | Adds new test class with tests verifying immediate UnauthorizedAccessException for directory enumeration methods |
| Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs | Refactors enumeration logic to check access permissions immediately rather than during lazy enumeration |
Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs
Show resolved
Hide resolved
Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs
Show resolved
Hide resolved
Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs
Show resolved
Hide resolved
Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs
Outdated
Show resolved
Hide resolved
Test Results 37 files ± 0 37 suites ±0 20m 58s ⏱️ -25s For more details on these failures, see this check. Results for commit a5e501e. ± Comparison against base commit b16c3ce. This pull request removes 36327 and adds 36331 tests. Note that renamed tests count towards both.This pull request removes 1784 skipped tests and adds 1784 skipped tests. Note that renamed tests count towards both. |
|
|
This is addressed in release v4.3.7. |



This PR fixes a bug where
UnauthorizedAccessExceptionwas not thrown immediately when attempting to enumerate directories without proper access. The fix moves the access control check from inside the enumeration implementation to before enumeration begins, ensuring the exception is thrown synchronously rather than when the enumeration is actually consumed.Key Changes