コード例 #1
0
 def test_acl_elem(self):
     acl = ACLPrivate(Owner(id='test:tester', name='test:tester'))
     elem = acl.elem()
     self.assertTrue(elem.find('./Owner') is not None)
     self.assertTrue(elem.find('./AccessControlList') is not None)
     grants = [e for e in elem.findall('./AccessControlList/Grant')]
     self.assertEqual(len(grants), 1)
     self.assertEqual(grants[0].find('./Grantee/ID').text, 'test:tester')
     self.assertEqual(grants[0].find('./Grantee/DisplayName').text,
                      'test:tester')
コード例 #2
0
 def test_acl_from_elem(self):
     # check translation from element
     acl = ACLPrivate(Owner(id='test:tester', name='test:tester'))
     elem = acl.elem()
     acl = ACL.from_elem(elem)
     self.assertTrue(self.check_permission(acl, 'test:tester', 'READ'))
     self.assertTrue(self.check_permission(acl, 'test:tester', 'WRITE'))
     self.assertTrue(self.check_permission(acl, 'test:tester', 'READ_ACP'))
     self.assertTrue(self.check_permission(acl, 'test:tester', 'WRITE_ACP'))
     self.assertFalse(self.check_permission(acl, 'test:tester2', 'READ'))
     self.assertFalse(self.check_permission(acl, 'test:tester2', 'WRITE'))
     self.assertFalse(self.check_permission(acl, 'test:tester2',
                                            'READ_ACP'))
     self.assertFalse(
         self.check_permission(acl, 'test:tester2', 'WRITE_ACP'))