This file is indexed.

/usr/share/pyshared/txaws/s3/tests/test_acls.py is in python-txaws 0.2.3-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from twisted.trial.unittest import TestCase

from txaws.testing import payload
from txaws.s3 import acls


class ACLTestCase(TestCase):

    def test_owner_to_xml(self):
        owner = acls.Owner(id='8a6925ce4adf588a4f21c32aa379004fef',
                           display_name='BucketOwnersEmail@amazon.com')
        xml_bytes = owner.to_xml()
        self.assertEquals(xml_bytes, """\
<Owner>
  <ID>8a6925ce4adf588a4f21c32aa379004fef</ID>
  <DisplayName>BucketOwnersEmail@amazon.com</DisplayName>
</Owner>
""")

    def test_grantee_canonical_missing_parameter(self):
        self.assertRaises(
            ValueError, acls.Grantee,
            {'id': '8a6925ce4adf588a4f21c32aa379004fef'})
        self.assertRaises(
            ValueError, acls.Grantee,
            {'display_name': 'BucketOwnersEmail@amazon.com'})

    def test_grantee_canonical_to_xml(self):
        grantee = acls.Grantee(id='8a6925ce4adf588a4f21c32aa379004fef',
                               display_name='BucketOwnersEmail@amazon.com')
        xml_bytes = grantee.to_xml()
        self.assertEquals(xml_bytes, """\
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\
 xsi:type="CanonicalUser">
  <ID>8a6925ce4adf588a4f21c32aa379004fef</ID>
  <DisplayName>BucketOwnersEmail@amazon.com</DisplayName>
</Grantee>
""")

    def test_grantee_email_to_xml(self):
        grantee = acls.Grantee(email_address="BucketOwnersEmail@amazon.com")
        xml_bytes = grantee.to_xml()
        self.assertEquals(xml_bytes, """\
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\
 xsi:type="AmazonCustomerByEmail">
  <EmailAddress>BucketOwnersEmail@amazon.com</EmailAddress>
</Grantee>
""")

    def test_grantee_uri_to_xml(self):
        grantee = acls.Grantee(
            uri='http://acs.amazonaws.com/groups/global/AuthenticatedUsers')
        xml_bytes = grantee.to_xml()
        self.assertEquals(xml_bytes, """\
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\
 xsi:type="Group">
  <URI>http://acs.amazonaws.com/groups/global/AuthenticatedUsers</URI>
</Grantee>
""")

    def test_grant_to_xml(self):
        grantee = acls.Grantee(id='8a6925ce4adf588a4f21c32aa379004fef',
                               display_name='BucketOwnersEmail@amazon.com')
        grant = acls.Grant(grantee, 'FULL_CONTROL')
        xml_bytes = grant.to_xml()
        self.assertEquals(xml_bytes, """\
<Grant>
  <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\
 xsi:type="CanonicalUser">
    <ID>8a6925ce4adf588a4f21c32aa379004fef</ID>
    <DisplayName>BucketOwnersEmail@amazon.com</DisplayName>
  </Grantee>
  <Permission>FULL_CONTROL</Permission>
</Grant>
""")

    def test_access_control_policy_to_xml(self):
        grantee = acls.Grantee(id='8a6925ce4adf588a4f21c32aa379004fef',
                               display_name='foo@example.net')
        grant1 = acls.Grant(grantee, 'FULL_CONTROL')
        grantee = acls.Grantee(id='8a6925ce4adf588a4f21c32aa37900feed',
                               display_name='bar@example.net')
        grant2 = acls.Grant(grantee, 'READ')
        owner = acls.Owner(id='8a6925ce4adf588a4f21c32aa37900beef',
                           display_name='baz@example.net')
        acp = acls.AccessControlPolicy(owner=owner,
                                       access_control_list=[grant1, grant2])
        xml_bytes = acp.to_xml()
        self.assertEquals(xml_bytes,
                          payload.sample_access_control_policy_result)

    def test_permission_enum(self):
        grantee = acls.Grantee(id='8a6925ce4adf588a4f21c32aa379004fef',
                               display_name='BucketOwnersEmail@amazon.com')
        acls.Grant(grantee, 'FULL_CONTROL')
        acls.Grant(grantee, 'WRITE')
        acls.Grant(grantee, 'WRITE_ACP')
        acls.Grant(grantee, 'READ')
        acls.Grant(grantee, 'READ_ACP')
        self.assertRaises(ValueError, acls.Grant, grantee, 'GO_HOG_WILD')

    def test_from_xml(self):
        policy = acls.AccessControlPolicy.from_xml(
            payload.sample_access_control_policy_result)
        self.assertEquals(policy.owner.id,
                          '8a6925ce4adf588a4f21c32aa37900beef')
        self.assertEquals(policy.owner.display_name, 'baz@example.net')
        self.assertEquals(len(policy.access_control_list), 2)
        grant1 = policy.access_control_list[0]
        self.assertEquals(grant1.grantee.id,
                          '8a6925ce4adf588a4f21c32aa379004fef')
        self.assertEquals(grant1.grantee.display_name, 'foo@example.net')
        self.assertEquals(grant1.permission, 'FULL_CONTROL')
        grant2 = policy.access_control_list[1]
        self.assertEquals(grant2.grantee.id,
                          '8a6925ce4adf588a4f21c32aa37900feed')
        self.assertEquals(grant2.grantee.display_name, 'bar@example.net')
        self.assertEquals(grant2.permission, 'READ')