Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed Dec 23, 2024
1 parent 15f412c commit fe3b7b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/globaleaks_eph_fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def open(self, flags, mode=0o660):
"""
with self.mutex:
self.fd = os.open(self.filepath, os.O_RDWR | os.O_CREAT | os.O_APPEND, mode)
os.chmod(self.filepath, mode)
return self

def write(self, data):
Expand Down
11 changes: 3 additions & 8 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,15 @@ def test_readdir(self):
@patch("os.chmod")
def test_chmod_success(self, mock_chmod):
self.fs.create(TEST_PATH, 0o660)
self.fs.chmod(TEST_PATH, 0o644)
mock_chmod.assert_called_once_with(self.fs.files[TEST_PATH].filepath, 0o644)
mock_chmod.assert_called_with(self.fs.files[TEST_PATH].filepath, 0o660)
self.fs.chmod(TEST_PATH, 0o640)
mock_chmod.assert_called_with(self.fs.files[TEST_PATH].filepath, 0o640)

def test_chmod_file_not_found(self):
with self.assertRaises(FuseOSError) as context:
self.fs.chmod("/nonexistent", 0o644)
self.assertEqual(context.exception.errno, errno.ENOENT)

@patch("os.chmod", side_effect=PermissionError)
def test_chmod_permission_error(self, mock_chmod):
self.fs.create(TEST_PATH, 0o660)
with self.assertRaises(PermissionError):
self.fs.chmod(TEST_PATH, 0o644)

@patch("os.chown")
def test_chown_success(self, mock_chown):
self.fs.create(TEST_PATH, 0o660)
Expand Down

0 comments on commit fe3b7b0

Please sign in to comment.