]>
Commit | Line | Data |
---|---|---|
f67539c2 | 1 | from unittest.mock import Mock |
7c673cae | 2 | |
e306af50 | 3 | from tasks import radosgw_admin |
7c673cae | 4 | |
20effc67 | 5 | acl_with_version = b"""<?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> |
7c673cae FG |
6 | """ # noqa |
7 | ||
8 | ||
20effc67 | 9 | acl_without_version = b"""<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> |
7c673cae FG |
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 |