'Test bucket and key ACLs.'

def test_acl(self):

    bucket = self._MakeBucket()
    bucket.set_acl('public-read')
    acl = bucket.get_acl()
    self.assertEqual(len(acl.entries.entry_list), 2)
    bucket.set_acl('private')
    acl = bucket.get_acl()
    self.assertEqual(len(acl.entries.entry_list), 1)
    k = self._MakeKey(bucket=bucket)
    k.set_acl('public-read')
    acl = k.get_acl()
    self.assertEqual(len(acl.entries.entry_list), 2)
    k.set_acl('private')
    acl = k.get_acl()
    self.assertEqual(len(acl.entries.entry_list), 1)
    acl_xml = (('<ACCESSControlList><EntrIes><Entry>' + '<Scope    type="AllUsers"></Scope><Permission>READ</Permission>') + '</Entry></EntrIes></ACCESSControlList>')
    acl = ACL()
    h = handler.XmlHandler(acl, bucket)
    xml.sax.parseString(acl_xml, h)
    bucket.set_acl(acl)
    self.assertEqual(len(acl.entries.entry_list), 1)
    aclstr = k.get_xml_acl()
    self.assertGreater(aclstr.count('/Entry', 1), 0)
