From 45b04cd3c18d3f60af4e1ec437bde9c3f3faa9b5 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 18 Oct 2015 20:54:46 +0200 Subject: [PATCH] add non-ascii ACL test (linux) still failing as the tested code does not yet work with non-ascii ACLs --- borg/testsuite/platform.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/borg/testsuite/platform.py b/borg/testsuite/platform.py index 77940655d..1dd6b31dc 100644 --- a/borg/testsuite/platform.py +++ b/borg/testsuite/platform.py @@ -72,6 +72,31 @@ class PlatformLinuxTestCase(BaseTestCase): self.assert_equal(self.get_acl(self.tmpdir)[b'acl_access'], ACCESS_ACL) self.assert_equal(self.get_acl(self.tmpdir)[b'acl_default'], DEFAULT_ACL) + def test_non_ascii_acl(self): + # Testing non-ascii ACL processing to see whether our code is robust. + # I have no idea whether non-ascii ACLs are allowed by the standard, + # but in practice they seem to be out there and must not make our code explode. + file = tempfile.NamedTemporaryFile() + self.assert_equal(self.get_acl(file.name), {}) + nothing_special = 'user::rw-\ngroup::r--\nmask::rw-\nother::---\n'.encode('ascii') + user_entry = 'user:übel:rw-:666'.encode('utf-8') + user_entry_numeric = 'user:666:rw-:666'.encode('ascii') + group_entry = 'group:übel:rw-:666'.encode('utf-8') + group_entry_numeric = 'group:666:rw-:666'.encode('ascii') + acl = b'\n'.join([nothing_special, user_entry, group_entry]) + self.set_acl(file.name, access=acl, numeric_owner=False) + acl_access = self.get_acl(file.name)[b'acl_access'] + self.assert_in(user_entry, acl_access) + self.assert_in(group_entry, acl_access) + acl_access_numeric = self.get_acl(file.name, numeric_owner=True)[b'acl_access'] + self.assert_in(user_entry_numeric, acl_access_numeric) + self.assert_in(group_entry_numeric, acl_access_numeric) + file2 = tempfile.NamedTemporaryFile() + self.set_acl(file2.name, access=acl, numeric_owner=True) + acl_access = self.get_acl(file2.name)[b'acl_access'] + self.assert_in(user_entry_numeric, acl_access) + self.assert_in(group_entry_numeric, acl_access) + @unittest.skipUnless(sys.platform.startswith('darwin'), 'OS X only test') @unittest.skipIf(fakeroot_detected(), 'not compatible with fakeroot')