use of com.aliyun.oss.model.GenericRequest in project aliyun-oss-java-sdk by aliyun.
the class OSSClientRequestTest method testBucketAclRequests.
@SuppressWarnings("serial")
@Test
public void testBucketAclRequests() {
// Put Bucket ACL
// expected acl: private
TestAction test1 = new TestAction() {
public void run() throws Exception {
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, null));
}
};
executeTest(test1, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {
{
}
});
// expected acl: public-read
TestAction test2 = new TestAction() {
public void run() throws Exception {
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.PublicRead));
}
};
executeTest(test2, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {
{
put("x-oss-acl", "public-read");
}
});
// expected acl: public-read-write
TestAction test3 = new TestAction() {
public void run() throws Exception {
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.PublicReadWrite));
}
};
executeTest(test3, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {
{
put("x-oss-acl", "public-read-write");
}
});
// expected acl: private
TestAction test4 = new TestAction() {
public void run() throws Exception {
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.Private));
}
};
executeTest(test4, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {
{
put("x-oss-acl", "private");
}
});
// Get Bucket ACL
// expected acl: private
TestAction test5 = new TestAction() {
public void run() throws Exception {
bucketOp.getBucketAcl(new GenericRequest(bucketName));
}
};
executeTest(test5, HttpMethod.GET, bucketName + "." + endpoint.getHost(), "?acl", null);
}
Aggregations