def test_private(self, mock_connection): content = ''' <AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Owner> <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID> <DisplayName>[email protected]</DisplayName> </Owner> <AccessControlList> <Grant> <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"> <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID> <DisplayName>[email protected]</DisplayName> </Grantee> <Permission>FULL_CONTROL</Permission> </Grant> </AccessControlList> </AccessControlPolicy> ''' mock_server = MockConnection() mock_connection.return_value = mock_server mock_server.mock_add_request(MockResponse('GET', 'http://localhost:9000/hello?acl', {}, 200, content=content)) client = minio.Minio('http://localhost:9000') acl = client.get_bucket_acl('hello') eq_(Acl.private(), acl)
def test_set_bucket_acl_works(self, mock_connection): mock_server = MockConnection() mock_connection.return_value = mock_server mock_server.mock_add_request( MockResponse("PUT", "http://localhost:9000/hello?acl", {"x-amz-acl": "private"}, 200) ) client = minio.Minio("http://localhost:9000") client.set_bucket_acl("hello", Acl.private())
def test_set_bucket_acl_invalid_name(self, mock_connection): error_xml = generate_error("code", "message", "request_id", "host_id", "resource") mock_server = MockConnection() mock_connection.return_value = mock_server mock_server.mock_add_request( MockResponse("PUT", "http://localhost:9000/1234?acl", {"x-amz-acl": "private"}, 400, content=error_xml) ) client = minio.Minio("http://localhost:9000") client.set_bucket_acl("1234", Acl.private())
def test_bucket_is_not_empty_string(self): client = minio.Minio("http://localhost:9000") client.set_bucket_acl(" \t \n ", Acl.private())
def test_bucket_is_string(self): client = minio.Minio("http://localhost:9000") client.set_bucket_acl(1234, Acl.private())