From abaf5cf55cf2db8314399a92263017dc3b80870b Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Tue, 24 Jul 2018 23:20:53 +0200 Subject: [PATCH] Tests: fix symlink testing On Linux, non-root users are not allowed to set extended attributes, so normal testing has hidden this. A fix to the Mac OS support proposed in #14 uncovered this problem, which led to investigation and this fix. Manual testing on Linux with root and namespace=trusted now passes the tests. --- test/test_xattr.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/test/test_xattr.py b/test/test_xattr.py index a9378b7..3d8b3f2 100644 --- a/test/test_xattr.py +++ b/test/test_xattr.py @@ -140,10 +140,14 @@ class xattrTest(unittest.TestCase): """check list, set, get operations against an item""" self.checkList(xattr.list(item, symlink), []) self.assertRaises(EnvironmentError, xattr.set, item, - self.USER_ATTR, self.USER_VAL, flags=XATTR_REPLACE) + self.USER_ATTR, self.USER_VAL, + flags=XATTR_REPLACE, + nofollow=symlink) self.assertRaises(EnvironmentError, xattr.set, item, - self.USER_NN, self.USER_VAL, flags=XATTR_REPLACE, - namespace=NAMESPACE) + self.USER_NN, self.USER_VAL, + flags=XATTR_REPLACE, + namespace=NAMESPACE, + nofollow=symlink) try: if use_ns: xattr.set(item, self.USER_NN, self.USER_VAL, @@ -162,14 +166,18 @@ class xattrTest(unittest.TestCase): return raise self.assertRaises(EnvironmentError, xattr.set, item, - self.USER_ATTR, self.USER_VAL, flags=XATTR_CREATE) + self.USER_ATTR, self.USER_VAL, + flags=XATTR_CREATE, + nofollow=symlink) self.assertRaises(EnvironmentError, xattr.set, item, self.USER_NN, self.USER_VAL, - flags=XATTR_CREATE, namespace=NAMESPACE) + flags=XATTR_CREATE, + namespace=NAMESPACE, + nofollow=symlink) self.checkList(xattr.list(item, nofollow=symlink), [self.USER_ATTR]) self.checkList(xattr.list(item, nofollow=symlink, - namespace=EMPTY_NS), - [self.USER_ATTR]) + namespace=EMPTY_NS), + [self.USER_ATTR]) self.assertEqual(xattr.list(item, namespace=NAMESPACE, nofollow=symlink), [self.USER_NN]) self.assertEqual(xattr.get(item, self.USER_ATTR, nofollow=symlink), @@ -182,10 +190,10 @@ class xattrTest(unittest.TestCase): namespace=NAMESPACE), [(self.USER_NN, self.USER_VAL)]) if use_ns: - xattr.remove(item, self.USER_NN, namespace=NAMESPACE) + xattr.remove(item, self.USER_NN, namespace=NAMESPACE, nofollow=symlink) else: - xattr.remove(item, self.USER_ATTR) - self.checkList(xattr.list(item, symlink), []) + xattr.remove(item, self.USER_ATTR, nofollow=symlink) + self.checkList(xattr.list(item, nofollow=symlink), []) self.checkTuples(xattr.get_all(item, nofollow=symlink), []) self.assertRaises(EnvironmentError, xattr.remove, -- 2.39.5