Skip to content

Commit 65b3856

Browse files
committed
DTO and test consistency 2025/04
Checking AWS APIs for changes and S3Mock for implementations and tests.
1 parent c24a16a commit 65b3856

File tree

13 files changed

+92
-79
lines changed

13 files changed

+92
-79
lines changed

server/src/main/java/com/adobe/testing/s3mock/dto/AbortIncompleteMultipartUpload.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020

2121
/**
22+
* Last validation: 2025-04.
2223
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortIncompleteMultipartUpload.html">API Reference</a>.
2324
*/
2425
public record AbortIncompleteMultipartUpload(

server/src/main/java/com/adobe/testing/s3mock/dto/AccessControlPolicy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import java.util.Objects;
2626

2727
/**
28+
* Last validation: 2025-04.
2829
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_AccessControlPolicy.html">API Reference</a>.
2930
* This class is a POJO instead of a record because jackson-databind-xml as of now does not support
3031
* record classes with @JacksonXmlElementWrapper:

server/src/main/java/com/adobe/testing/s3mock/dto/AmazonCustomerByEmail.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,21 +18,15 @@
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.annotation.JsonTypeInfo;
21-
import java.net.URI;
2221

2322
/**
23+
* Last validation: 2025-04.
2424
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_Grantee.html">API Reference</a>.
2525
*/
2626
@JsonTypeInfo(use = JsonTypeInfo.Id.SIMPLE_NAME, property = "xsi:type")
2727
public record AmazonCustomerByEmail(
28-
@JsonProperty("ID")
29-
String id,
30-
@JsonProperty("DisplayName")
31-
String displayName,
3228
@JsonProperty("EmailAddress")
33-
String emailAddress,
34-
@JsonProperty("URI")
35-
URI uri
29+
String emailAddress
3630
) implements Grantee {
3731

3832
}

server/src/main/java/com/adobe/testing/s3mock/dto/CanonicalUser.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,21 +18,17 @@
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.annotation.JsonTypeInfo;
21-
import java.net.URI;
2221

2322
/**
23+
* Last validation: 2025-04.
2424
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_Grantee.html">API Reference</a>.
2525
*/
2626
@JsonTypeInfo(use = JsonTypeInfo.Id.SIMPLE_NAME, property = "xsi:type")
2727
public record CanonicalUser(
2828
@JsonProperty("ID")
2929
String id,
3030
@JsonProperty("DisplayName")
31-
String displayName,
32-
@JsonProperty("EmailAddress")
33-
String emailAddress,
34-
@JsonProperty("URI")
35-
URI uri
31+
String displayName
3632
) implements Grantee {
3733

3834
}

server/src/main/java/com/adobe/testing/s3mock/dto/Grantee.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@
1919
import com.fasterxml.jackson.annotation.JsonSubTypes;
2020
import com.fasterxml.jackson.annotation.JsonTypeInfo;
2121
import com.fasterxml.jackson.annotation.OptBoolean;
22-
import java.net.URI;
2322

2423
/**
24+
* Last validation: 2025-04.
2525
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_Grantee.html">API Reference</a>.
2626
*/
2727
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "xsi:type",
@@ -33,16 +33,4 @@
3333
})
3434
public interface Grantee {
3535

36-
URI AUTHENTICATED_USERS_URI = URI.create("http://acs.amazonaws.com/groups/global/AuthenticatedUsers");
37-
URI ALL_USERS_URI = URI.create("http://acs.amazonaws.com/groups/global/AllUsers");
38-
URI LOG_DELIVERY_URI = URI.create("http://acs.amazonaws.com/groups/s3/LogDelivery");
39-
40-
String id();
41-
42-
String displayName();
43-
44-
String emailAddress();
45-
46-
URI uri();
47-
4836
}

server/src/main/java/com/adobe/testing/s3mock/dto/Group.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,18 +21,17 @@
2121
import java.net.URI;
2222

2323
/**
24+
* Last validation: 2025-04.
2425
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_Grantee.html">API Reference</a>.
2526
*/
2627
@JsonTypeInfo(use = JsonTypeInfo.Id.SIMPLE_NAME, property = "xsi:type")
2728
public record Group(
28-
@JsonProperty("ID")
29-
String id,
30-
@JsonProperty("DisplayName")
31-
String displayName,
32-
@JsonProperty("EmailAddress")
33-
String emailAddress,
3429
@JsonProperty("URI")
3530
URI uri
3631
) implements Grantee {
3732

33+
public static URI AUTHENTICATED_USERS_URI = URI.create("http://acs.amazonaws.com/groups/global/AuthenticatedUsers");
34+
public static URI ALL_USERS_URI = URI.create("http://acs.amazonaws.com/groups/global/AllUsers");
35+
public static URI LOG_DELIVERY_URI = URI.create("http://acs.amazonaws.com/groups/s3/LogDelivery");
36+
3837
}

server/src/main/java/com/adobe/testing/s3mock/store/ObjectStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public S3ObjectMetadata storeS3ObjectMetadata(BucketMetadata bucket,
156156
}
157157

158158
private AccessControlPolicy privateCannedAcl(Owner owner) {
159-
var grant = new Grant(new CanonicalUser(owner.id(), owner.displayName(), null, null),
159+
var grant = new Grant(new CanonicalUser(owner.id(), owner.displayName()),
160160
Grant.Permission.FULL_CONTROL);
161161
return new AccessControlPolicy(owner, Collections.singletonList(grant));
162162
}

server/src/main/java/com/adobe/testing/s3mock/util/CannedAclUtil.java

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import com.adobe.testing.s3mock.dto.AccessControlPolicy;
2323
import com.adobe.testing.s3mock.dto.CanonicalUser;
2424
import com.adobe.testing.s3mock.dto.Grant;
25-
import com.adobe.testing.s3mock.dto.Grantee;
2625
import com.adobe.testing.s3mock.dto.Group;
2726
import java.util.List;
2827
import software.amazon.awssdk.services.s3.model.ObjectCannedACL;
@@ -57,14 +56,12 @@ private static AccessControlPolicy bucketOwnerFulleControlAcl() {
5756
List.of(
5857
new Grant(
5958
new CanonicalUser(DEFAULT_OWNER.id(),
60-
DEFAULT_OWNER.displayName(),
61-
null, null),
59+
DEFAULT_OWNER.displayName()),
6260
Grant.Permission.FULL_CONTROL
6361
),
6462
new Grant(
6563
new CanonicalUser(DEFAULT_OWNER_BUCKET.id(),
66-
DEFAULT_OWNER_BUCKET.displayName(),
67-
null, null),
64+
DEFAULT_OWNER_BUCKET.displayName()),
6865
Grant.Permission.READ
6966
)
7067
)
@@ -77,14 +74,12 @@ private static AccessControlPolicy bucketOwnerReadAcl() {
7774
List.of(
7875
new Grant(
7976
new CanonicalUser(DEFAULT_OWNER.id(),
80-
DEFAULT_OWNER.displayName(),
81-
null, null),
77+
DEFAULT_OWNER.displayName()),
8278
Grant.Permission.FULL_CONTROL
8379
),
8480
new Grant(
8581
new CanonicalUser(DEFAULT_OWNER_BUCKET.id(),
86-
DEFAULT_OWNER_BUCKET.displayName(),
87-
null, null),
82+
DEFAULT_OWNER_BUCKET.displayName()),
8883
Grant.Permission.READ
8984
)
9085
)
@@ -97,13 +92,11 @@ private static AccessControlPolicy authenticatedReadAcl() {
9792
List.of(
9893
new Grant(
9994
new CanonicalUser(DEFAULT_OWNER.id(),
100-
DEFAULT_OWNER.displayName(),
101-
null, null),
95+
DEFAULT_OWNER.displayName()),
10296
Grant.Permission.FULL_CONTROL
10397
),
10498
new Grant(
105-
new Group(null, null,
106-
null, Grantee.AUTHENTICATED_USERS_URI),
99+
new Group(Group.AUTHENTICATED_USERS_URI),
107100
Grant.Permission.READ
108101
)
109102
)
@@ -119,8 +112,7 @@ private static AccessControlPolicy awsExecReadAcl() {
119112
List.of(
120113
new Grant(
121114
new CanonicalUser(DEFAULT_OWNER.id(),
122-
DEFAULT_OWNER.displayName(),
123-
null, null),
115+
DEFAULT_OWNER.displayName()),
124116
Grant.Permission.FULL_CONTROL
125117
)
126118
)
@@ -133,18 +125,15 @@ private static AccessControlPolicy publicReadWriteAcl() {
133125
List.of(
134126
new Grant(
135127
new CanonicalUser(DEFAULT_OWNER.id(),
136-
DEFAULT_OWNER.displayName(),
137-
null, null),
128+
DEFAULT_OWNER.displayName()),
138129
Grant.Permission.FULL_CONTROL
139130
),
140131
new Grant(
141-
new Group(null, null,
142-
null, Grantee.ALL_USERS_URI),
132+
new Group(Group.ALL_USERS_URI),
143133
Grant.Permission.READ
144134
),
145135
new Grant(
146-
new Group(null, null,
147-
null, Grantee.ALL_USERS_URI),
136+
new Group(Group.ALL_USERS_URI),
148137
Grant.Permission.WRITE
149138
)
150139
)
@@ -157,13 +146,11 @@ private static AccessControlPolicy publicReadAcl() {
157146
List.of(
158147
new Grant(
159148
new CanonicalUser(DEFAULT_OWNER.id(),
160-
DEFAULT_OWNER.displayName(),
161-
null, null),
149+
DEFAULT_OWNER.displayName()),
162150
Grant.Permission.FULL_CONTROL
163151
),
164152
new Grant(
165-
new Group(null, null,
166-
null, Grantee.ALL_USERS_URI),
153+
new Group(Group.ALL_USERS_URI),
167154
Grant.Permission.READ
168155
)
169156
)
@@ -176,8 +163,7 @@ private static AccessControlPolicy privateAcl() {
176163
List.of(
177164
new Grant(
178165
new CanonicalUser(DEFAULT_OWNER.id(),
179-
DEFAULT_OWNER.displayName(),
180-
null, null),
166+
DEFAULT_OWNER.displayName()),
181167
Grant.Permission.FULL_CONTROL
182168
)
183169
)

server/src/test/kotlin/com/adobe/testing/s3mock/ObjectControllerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ internal class ObjectControllerTest : BaseControllerTest() {
396396
"75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a",
397397
"mtd@amazon.com"
398398
)
399-
val grantee = CanonicalUser(owner.id, owner.displayName, null, null)
399+
val grantee = CanonicalUser(owner.id, owner.displayName)
400400
val policy = AccessControlPolicy(
401401
owner,
402402
listOf(Grant(grantee, Grant.Permission.FULL_CONTROL))
@@ -434,7 +434,7 @@ internal class ObjectControllerTest : BaseControllerTest() {
434434
"75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a",
435435
"mtd@amazon.com"
436436
)
437-
val grantee = CanonicalUser(owner.id, owner.displayName, null, null)
437+
val grantee = CanonicalUser(owner.id, owner.displayName)
438438
val policy = AccessControlPolicy(
439439
owner,
440440
listOf(Grant(grantee, Grant.Permission.FULL_CONTROL))

server/src/test/kotlin/com/adobe/testing/s3mock/dto/AccessControlPolicyTest.kt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 Adobe.
2+
* Copyright 2017-2025 Adobe.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import org.assertj.core.api.Assertions.assertThat
1919
import org.junit.jupiter.api.Test
2020
import org.junit.jupiter.api.TestInfo
2121
import java.io.IOException
22+
import java.net.URI
2223

2324
internal class AccessControlPolicyTest {
2425
@Test
@@ -34,14 +35,30 @@ internal class AccessControlPolicyTest {
3435
"75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
3536
)
3637
assertThat(owner.displayName).isEqualTo("mtd@amazon.com")
37-
assertThat(iut.getAccessControlList()).hasSize(1)
38+
assertThat(iut.getAccessControlList()).hasSize(3)
3839

3940
iut.getAccessControlList()[0].also {
4041
assertThat(it.permission).isEqualTo(Grant.Permission.FULL_CONTROL)
4142
assertThat(it.grantee).isNotNull()
42-
assertThat(it.grantee.id()).isEqualTo("75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a")
43-
assertThat(it.grantee.displayName()).isEqualTo("mtd@amazon.com")
4443
assertThat(it.grantee).isInstanceOf(CanonicalUser::class.java)
44+
val user = it.grantee as CanonicalUser
45+
assertThat(user.id()).isEqualTo("75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a")
46+
assertThat(user.displayName()).isEqualTo("mtd@amazon.com")
47+
}
48+
49+
iut.getAccessControlList()[1].also {
50+
assertThat(it.permission).isEqualTo(Grant.Permission.WRITE)
51+
assertThat(it.grantee).isNotNull()
52+
assertThat(it.grantee).isInstanceOf(Group::class.java)
53+
val group = it.grantee as Group
54+
assertThat(group.uri()).isEqualTo(URI.create("http://acs.amazonaws.com/groups/s3/LogDelivery"))
55+
}
56+
iut.getAccessControlList()[2].also {
57+
assertThat(it.permission).isEqualTo(Grant.Permission.WRITE_ACP)
58+
assertThat(it.grantee).isNotNull()
59+
assertThat(it.grantee).isInstanceOf(AmazonCustomerByEmail::class.java)
60+
val customer = it.grantee as AmazonCustomerByEmail
61+
assertThat(customer.emailAddress()).isEqualTo("xyz@amazon.com")
4562
}
4663
}
4764

@@ -52,10 +69,17 @@ internal class AccessControlPolicyTest {
5269
"75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a",
5370
"mtd@amazon.com"
5471
)
55-
val grantee = CanonicalUser(owner.id, owner.displayName, null, null)
72+
val grantee = CanonicalUser(owner.id, owner.displayName)
73+
val group = Group(URI.create("http://acs.amazonaws.com/groups/s3/LogDelivery"))
74+
val customer = AmazonCustomerByEmail("xyz@amazon.com")
75+
5676
val iut = AccessControlPolicy(
5777
owner,
58-
listOf(Grant(grantee, Grant.Permission.FULL_CONTROL))
78+
listOf(
79+
Grant(grantee, Grant.Permission.FULL_CONTROL),
80+
Grant(group, Grant.Permission.WRITE),
81+
Grant(customer, Grant.Permission.WRITE_ACP)
82+
)
5983
)
6084
DtoTestUtil.serializeAndAssert(iut, testInfo)
6185
}

0 commit comments

Comments
 (0)