python: tests: Add tests for samba.posix_eadb module
authorLumir Balhar <lbalhar@redhat.com>
Tue, 24 Oct 2017 07:01:16 +0000 (09:01 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 8 Nov 2017 20:54:59 +0000 (21:54 +0100)
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Nov  8 21:54:59 CET 2017 on sn-devel-144

python/samba/tests/xattr.py

index 63874523f00c33d7db53aa3db12b009ec00b3d07..b024175a8d6b1720c62b1b0d17d7e43a008ed855 100644 (file)
@@ -17,7 +17,7 @@
 
 """Tests for samba.xattr_native and samba.xattr_tdb."""
 
-import samba.xattr_native, samba.xattr_tdb
+import samba.xattr_native, samba.xattr_tdb, samba.posix_eadb
 from samba.xattr import copytree_with_xattrs
 from samba.dcerpc import xattr
 from samba.ndr import ndr_pack
@@ -108,6 +108,34 @@ class XattrTests(TestCase):
             os.unlink(tempf)
         os.unlink(eadb_path)
 
+    def test_set_posix_eadb(self):
+        tempf = self._tmpfilename()
+        eadb_path = self._eadbpath()
+        ntacl = xattr.NTACL()
+        ntacl.version = 1
+        open(tempf, 'w').write("empty")
+        try:
+            samba.posix_eadb.wrap_setxattr(eadb_path,
+                tempf, "user.unittests", ndr_pack(ntacl))
+        finally:
+            os.unlink(tempf)
+        os.unlink(eadb_path)
+
+    def test_set_and_get_posix_eadb(self):
+        tempf = self._tmpfilename()
+        eadb_path = self._eadbpath()
+        reftxt = "this is a test"
+        open(tempf, 'w').write("empty")
+        try:
+            samba.posix_eadb.wrap_setxattr(eadb_path, tempf, "user.unittests",
+                reftxt)
+            text = samba.posix_eadb.wrap_getxattr(eadb_path, tempf,
+                "user.unittests")
+            self.assertEquals(text, reftxt)
+        finally:
+            os.unlink(tempf)
+        os.unlink(eadb_path)
+
 
 class TestCopyTreeWithXattrs(TestCaseInTempDir):