tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
906 stars 86 forks source link

fix: fix EACCES error on access by root user #369

Closed danielkatz closed 1 year ago

danielkatz commented 1 year ago

This PR comes to fix an error with the access function what does not implement a check for a root user. To fix this I'm reusing the logic already implemented in canRead, canWrite and canExecute functions (I've also added tests for those cases in item.spec.js). I've added test for the error case to bindings.spec.js.

P.S. Since, there is no mocking library currently used in the project, so i've used a manual method to mock process.getuid and process.getgid functions which can easily be replaced by any mocking library.

3cp commented 1 year ago

Thx! LGTM.

tschaub commented 1 year ago

Thanks, @danielkatz. Your fix is available in the v5.2.0 release.