Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed Aug 5, 2024
1 parent 3715529 commit a825479
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/api2/test_audit_permission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os

from middlewared.test.integration.assets.pool import dataset
from middlewared.test.integration.utils import call
from middlewared.test.integration.utils.audit import expect_audit_method_calls

JENNY = 8675309


def test_audit_chown():
with dataset('audit_chown') as ds:
payload = {
'path': os.path.join('/mnt', ds),
'uid': JENNY
}

with expect_audit_method_calls([{
'method': 'filesystem.chown',
'params': [payload],
'description': 'Filesystem change owner'
}]):
call('filesystem.chown', payload, job=True)


def test_audit_setperm():
with dataset('audit_setperm') as ds:
payload = {
'path': os.path.join('/mnt', ds),
'mode': '777'
}

with expect_audit_method_calls([{
'method': 'filesystem.setperm',
'params': [payload],
'description': 'Filesystem change permission'
}]):
call('filesystem.setperm', payload, job=True)


def test_audit_setacl():
with dataset('audit_setacl', {'share_type': 'SMB') as ds:
the_acl = call('filesystem.getacl', os.path.join('/mnt', ds))['acl']
the_acl.append({
'tag': 'USER',
'id': JENNY,
'perms': {'BASIC': 'FULL_CONTROL'},
'flags': {'BASIC': 'INHERIT'},
'type': 'ALLOW'
})

payload = {
'path': os.path.join('/mnt', ds),
'dacl': the_acl
}

with expect_audit_method_calls([{
'method': 'filesystem.setacl',
'params': [payload],
'description': 'Filesystem set ACL'
}]):
call('filesystem.setacl', payload, job=True)

0 comments on commit a825479

Please sign in to comment.