]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/tests/test_radosgw_admin.py
59f357891ca71b373e4e521696b039eaf3966f59
[ceph.git] / ceph / qa / tasks / tests / test_radosgw_admin.py
1 from mock import Mock
2
3 from .. import radosgw_admin
4
5 acl_with_version = """<?xml version="1.0" encoding="UTF-8"?><AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>foo</ID><DisplayName>Foo</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>foo</ID><DisplayName>Foo</DisplayName></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>
6 """ # noqa
7
8
9 acl_without_version = """<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>foo</ID><DisplayName>Foo</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>foo</ID><DisplayName>Foo</DisplayName></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>
10 """ # noqa
11
12
13 class TestGetAcl(object):
14
15 def setup(self):
16 self.key = Mock()
17
18 def test_removes_xml_version(self):
19 self.key.get_xml_acl = Mock(return_value=acl_with_version)
20 result = radosgw_admin.get_acl(self.key)
21 assert result.startswith('<AccessControlPolicy')
22
23 def test_xml_version_is_already_removed(self):
24 self.key.get_xml_acl = Mock(return_value=acl_without_version)
25 result = radosgw_admin.get_acl(self.key)
26 assert result.startswith('<AccessControlPolicy')
27
28 def test_newline_gets_trimmed(self):
29 self.key.get_xml_acl = Mock(return_value=acl_without_version)
30 result = radosgw_admin.get_acl(self.key)
31 assert result.endswith('\n') is False