use of alluxio.proxy.s3.ListAllMyBucketsResult in project alluxio by Alluxio.
the class S3ClientRestApiTest method listAllMyBuckets.
@Test
public void listAllMyBuckets() throws Exception {
Mode mode = ModeParser.parse("777");
SetAttributePOptions options = SetAttributePOptions.newBuilder().setMode(mode.toProto()).setRecursive(true).build();
mFileSystem.setAttribute(new AlluxioURI("/"), options);
Subject subject = new Subject();
subject.getPrincipals().add(new User("user0"));
AlluxioURI bucketPath = new AlluxioURI("/bucket0");
FileSystem fs1 = sResource.get().getClient(FileSystemContext.create(subject, ServerConfiguration.global()));
fs1.createDirectory(bucketPath);
SetAttributePOptions setAttributeOptions = SetAttributePOptions.newBuilder().setOwner("user0").build();
mFileSystem.setAttribute(new AlluxioURI("/bucket0"), setAttributeOptions);
URIStatus bucket0Status = fs1.getStatus(bucketPath);
subject = new Subject();
subject.getPrincipals().add(new User("user1"));
AlluxioURI bucket1Path = new AlluxioURI("/bucket1");
FileSystem fs2 = sResource.get().getClient(FileSystemContext.create(subject, ServerConfiguration.global()));
fs2.createDirectory(bucket1Path);
setAttributeOptions = SetAttributePOptions.newBuilder().setOwner("user1").build();
mFileSystem.setAttribute(new AlluxioURI("/bucket1"), setAttributeOptions);
URIStatus bucket1Status = fs2.getStatus(bucket1Path);
ListAllMyBucketsResult expected = new ListAllMyBucketsResult(Collections.emptyList());
final TestCaseOptions requestOptions = TestCaseOptions.defaults().setContentType(TestCaseOptions.XML_CONTENT_TYPE);
new TestCase(mHostname, mPort, S3_SERVICE_PREFIX + "/", NO_PARAMS, HttpMethod.GET, expected, requestOptions).run();
expected = new ListAllMyBucketsResult(Lists.newArrayList(bucket0Status));
requestOptions.setAuthorization("AWS4-HMAC-SHA256 Credential=user0/20210631");
new TestCase(mHostname, mPort, S3_SERVICE_PREFIX + "/", NO_PARAMS, HttpMethod.GET, expected, requestOptions).run();
expected = new ListAllMyBucketsResult(Lists.newArrayList(bucket1Status));
requestOptions.setAuthorization("AWS4-HMAC-SHA256 Credential=user1/20210631");
new TestCase(mHostname, mPort, S3_SERVICE_PREFIX + "/", NO_PARAMS, HttpMethod.GET, expected, requestOptions).run();
}
Aggregations