Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
Signed-off-by: Umer Saleem <[email protected]>
  • Loading branch information
usaleem-ix committed Jul 27, 2023
1 parent b16eae9 commit 6efbc1a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
41 changes: 39 additions & 2 deletions lib/libzfsacl/zfsacltests/test_nfsv4acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
import pwd
import shutil
import libzfsacl
from subprocess import run, PIPE

def run_as_user(cmd, user):
command = ["/usr/bin/su", "-", user, "-c", cmd]
print(" ".join(command))
proc = run(command, stdout=PIPE, stderr=PIPE,
universal_newlines=True, timeout=30)
output = proc.stdout
error = proc.stderr
if proc.returncode != 0:
return {"result": False, "output": output, "error": error,
"returncode": proc.returncode}
else:
return {"result": False, "output": output, "error": error,
"returncode": proc.returncode}


class TestNFSAcl(unittest.TestCase):
Expand Down Expand Up @@ -384,8 +399,30 @@ def test_flagset_no_propagate_dir(self):
self.assertEqual(tdentry0.who, (libzfsacl.WHOTYPE_USER, self.ZFS_ACL_STAFF1_UID), "Inherited ACE who is not correct")
self.assertEqual(tdentry0.flagset, libzfsacl.FLAG_INHERITED, "Flagset on inherited ACE are not correct")
self.assertEqual(tdentry0.permset, libzfsacl.PERM_READ_DATA | libzfsacl.PERM_WRITE_DATA, "Permse of inherited ACE at index 0 are not correct")
os.rmdir(tddir)

shutil.rmtree(self.TDIR)

def test_run_as_user(self):
os.makedirs(self.TDIR)
ls_path = shutil.which("ls")
cmd = f"{ls_path} -lh {self.MOUNTPT}"
res = run_as_user(cmd, self.ZFS_ACL_STAFF2)
os.rmdir(self.TDIR)
print(res["returncode"])
print(res["output"])
print(res["error"])

zfs_path = shutil.which("zfs")
cmd = f"{zfs_path} --version"
res = run_as_user(cmd, self.ZFS_ACL_STAFF1)
print(res["returncode"])
print(res["output"])
print(res["error"])

zpool_path = shutil.which("zpool")
cmd = f"{zpool_path} --version"
res = run_as_user(cmd, self.ZFS_ACL_STAFF2)
print(res["returncode"])
print(res["output"])
print(res["error"])


4 changes: 4 additions & 0 deletions tests/zfs-tests/tests/functional/acl/nfsv4/cleanup.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
cleanup_user_group

default_cleanup

if is_freebsd; then
mv /usr/bin/fortune_bak /usr/bin/fortune
fi
5 changes: 5 additions & 0 deletions tests/zfs-tests/tests/functional/acl/nfsv4/setup.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ log_must add_group $ZFS_ACL_STAFF_GROUP
log_must add_user $ZFS_ACL_STAFF_GROUP $ZFS_ACL_STAFF1
log_must add_user $ZFS_ACL_STAFF_GROUP $ZFS_ACL_STAFF2

if is_freebsd; then
mv /usr/bin/fortune /usr/bin/fortune_bak
cp /usr/bin/true /usr/bin/fortune
fi

DISK=${DISKS%% *}
default_setup_noexit $DISK
log_must chmod 777 $TESTDIR
Expand Down

0 comments on commit 6efbc1a

Please sign in to comment.