]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/tests/test_radosgw_admin.py
3 from unittest
.mock
import Mock
7 from tasks
import radosgw_admin
9 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>
13 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>
17 class TestGetAcl(object):
22 def test_removes_xml_version(self
):
23 self
.key
.get_xml_acl
= Mock(return_value
=acl_with_version
)
24 result
= radosgw_admin
.get_acl(self
.key
)
25 assert result
.startswith('<AccessControlPolicy')
27 def test_xml_version_is_already_removed(self
):
28 self
.key
.get_xml_acl
= Mock(return_value
=acl_without_version
)
29 result
= radosgw_admin
.get_acl(self
.key
)
30 assert result
.startswith('<AccessControlPolicy')
32 def test_newline_gets_trimmed(self
):
33 self
.key
.get_xml_acl
= Mock(return_value
=acl_without_version
)
34 result
= radosgw_admin
.get_acl(self
.key
)
35 assert result
.endswith('\n') is False