예제 #1
0
    def test_from_headers_x_amz_acl(self):
        canned_acls = [
            'public-read', 'public-read-write', 'authenticated-read',
            'bucket-owner-read', 'bucket-owner-full-control',
            'log-delivery-write'
        ]

        owner = Owner('test:tester', 'test:tester')
        grantee_map = canned_acl_grantees(owner)

        for acl_str in canned_acls:
            acl = ACL.from_headers({'x-amz-acl': acl_str}, owner)
            expected = grantee_map[acl_str]

            self.assertEquals(len(acl.grants), len(expected))  # sanity

            # parse Grant object to permission and grantee
            actual_grants = [(grant.permission, grant.grantee)
                             for grant in acl.grants]

            assertions = zip(sorted(expected), sorted(actual_grants))

            for (expected_permission, expected_grantee), \
                    (permission, grantee) in assertions:
                self.assertEquals(expected_permission, permission)
                self.assertTrue(isinstance(grantee,
                                           expected_grantee.__class__))
                if isinstance(grantee, User):
                    self.assertEquals(expected_grantee.id, grantee.id)
                    self.assertEquals(expected_grantee.display_name,
                                      grantee.display_name)
예제 #2
0
    def test_from_headers_x_amz_acl(self):
        canned_acls = ['public-read', 'public-read-write',
                       'authenticated-read', 'bucket-owner-read',
                       'bucket-owner-full-control', 'log-delivery-write']

        owner = Owner('test:tester', 'test:tester')
        grantee_map = canned_acl_grantees(owner)

        for acl_str in canned_acls:
            acl = ACL.from_headers({'x-amz-acl': acl_str}, owner)
            expected = grantee_map[acl_str]

            self.assertEquals(len(acl.grants), len(expected))  # sanity

            # parse Grant object to permission and grantee
            actual_grants = [(grant.permission, grant.grantee)
                             for grant in acl.grants]

            assertions = zip(sorted(expected), sorted(actual_grants))

            for (expected_permission, expected_grantee), \
                    (permission, grantee) in assertions:
                self.assertEquals(expected_permission, permission)
                self.assertTrue(
                    isinstance(grantee, expected_grantee.__class__))
                if isinstance(grantee, User):
                    self.assertEquals(expected_grantee.id, grantee.id)
                    self.assertEquals(expected_grantee.display_name,
                                      grantee.display_name)
예제 #3
0
 def test_canned_acl_grantees(self):
     grantee_map = canned_acl_grantees(Owner('test:tester', 'test:tester'))
     canned_acls = ['private', 'public-read', 'public-read-write',
                    'authenticated-read', 'bucket-owner-read',
                    'bucket-owner-full-control', 'log-delivery-write']
     for canned_acl in canned_acls:
         self.assertTrue(canned_acl in grantee_map)
     self.assertEquals(len(canned_acls), len(grantee_map))  # sanity