Skip to content

Commit 1d20b71

Browse files
zhuxiaolong37huiguangjun
authored andcommitted
Add authenticated read to ACL enumeration type
1 parent 6af2dfb commit 1d20b71

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/main/java/com/aliyun/oss/model/CannedAccessControlList.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@ public enum CannedAccessControlList {
5050
* Both the owner and {@link GroupGrantee#AllUsers} have
5151
* {@link Permission#FullControl}. It's not safe and thus not recommended.
5252
*/
53-
PublicReadWrite("public-read-write");
53+
PublicReadWrite("public-read-write"),
54+
55+
/**
56+
* The owner has the {@link Permission#FullControl}, other
57+
* {@link GroupGrantee#AllUsers} have authenticated-read access.
58+
*/
59+
AuthenticatedRead("authenticated-read"),
60+
61+
/**
62+
* Unknown
63+
*/
64+
Unknown("Unknown");
5465

5566
private String cannedAclString;
5667

@@ -70,6 +81,6 @@ public static CannedAccessControlList parse(String acl) {
7081
}
7182
}
7283

73-
throw new IllegalArgumentException("Unable to parse the provided acl " + acl);
84+
return Unknown;
7485
}
7586
}

src/test/java/com/aliyun/oss/integrationtests/BucketInfoTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,35 @@ public void testCreateBucket() {
121121
}
122122
}
123123

124+
@Test
125+
public void testGetBucketInfoWithAuthenticatedRead() {
126+
try {
127+
ossClient.setBucketAcl(bucketName, CannedAccessControlList.AuthenticatedRead);
128+
129+
BucketInfo info = ossClient.getBucketInfo(bucketName);
130+
Assert.assertNotNull(info.getComment());
131+
Assert.assertNotNull(info.getDataRedundancyType());
132+
Assert.assertEquals(info.getBucket().getName(), bucketName);
133+
Assert.assertEquals(info.getBucket().getLocation(), TestConfig.OSS_TEST_REGION);
134+
Assert.assertNotNull(info.getBucket().getCreationDate());
135+
Assert.assertTrue(info.getBucket().getExtranetEndpoint().length() > 0);
136+
Assert.assertTrue(info.getBucket().getIntranetEndpoint().length() > 0);
137+
Assert.assertTrue(info.getBucket().getOwner().getId().length() > 0);
138+
Assert.assertEquals(CannedAccessControlList.AuthenticatedRead, info.getCannedACL());
139+
Assert.assertEquals(info.getBucket().getOwner().getDisplayName(), info.getBucket().getOwner().getId());
140+
Assert.assertEquals(info.getRequestId().length(), REQUEST_ID_LEN);
141+
for (Grant grant : info.getGrants()) {
142+
Assert.assertEquals(grant.getGrantee(), GroupGrantee.AllUsers);
143+
Assert.assertEquals(grant.getPermission(), Permission.Read);
144+
}
145+
146+
ossClient.setBucketAcl(bucketName, CannedAccessControlList.AuthenticatedRead);
147+
info = ossClient.getBucketInfo(bucketName);
148+
Assert.assertEquals(CannedAccessControlList.AuthenticatedRead, info.getCannedACL());
149+
150+
} catch (Exception e) {
151+
Assert.fail(e.getMessage());
152+
}
153+
}
154+
124155
}

0 commit comments

Comments
 (0)