ansh0014 opened a new pull request, #6886:
URL: https://github.com/apache/camel-k/pull/6886
# Description
Previously, `TestPermissionDenied` in `pkg/cmd/source/util_test.go` was
skipped on Windows with `t.Skip("Test not reliably producing a result on a
windows OS")` for two reasons:
1. In `pkg/cmd/source/util.go`, `isExistingFile` caught any `*fs.PathError`
on Windows and returned `false, nil` (treating it as not found), which
swallowed genuine permission denied errors (`syscall.ERROR_ACCESS_DENIED`).
2. In `util_test.go`, POSIX `os.Chmod(dir, 0000)` does not restrict
directory access permissions on Windows NTFS.
### Changes:
- **`pkg/cmd/source/util.go`**: Check `errors.Is(err, fs.ErrPermission)`
before the Windows `*fs.PathError` check so permission denied errors are
correctly propagated on all platforms.
- **`pkg/cmd/source/util_test.go`**:
- Removed `t.Skip` for Windows so the test runs across all operating
systems.
- Added OS-agnostic directory access denial: uses Windows built-in `icacls
<dir> /deny *S-1-1-0:(OI)(CI)(F)` on Windows and `os.Chmod(dir, 0000)` on Unix,
restoring permissions in cleanup.
- Closed the test file handle immediately after creation to prevent
file-locking conflicts during permission tests on Windows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]