Skip to content

Commit d836d68

Browse files
authored
Merge pull request #2320 from adobe/it-correctness-and-refactoring-removing-v1-sdk
IT correctness, refactoring, remove V1 SDK
2 parents 71bff5d + b8d7147 commit d836d68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4607
-6990
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,13 @@ Version 4.x is JDK17 LTS bytecode compatible, with Docker and JUnit / direct Jav
156156
* Support Browser-Based Uploads Using POST (fixes #2200)
157157
* https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-UsingHTTPPOST.html
158158
* Refactorings
159-
* TBD
159+
* Validate all integration tests against S3, fix S3Mock where necessary
160+
* These were corner cases where error messages were incorrect, or proper validations were missing.
161+
* Migrate all integration tests to AWS SDK v2, remove AWS SDK v1 tests from the integration-tests module
160162
* Version updates (deliverable dependencies)
161163
* TBD
162164
* Version updates (build dependencies)
163-
* TBD
165+
* Bump actions/setup-java from 4.7.0 to 4.7.1
164166

165167
## 4.0.0
166168
Version 4.x is JDK17 LTS bytecode compatible, with Docker and JUnit / direct Java integration.
@@ -170,6 +172,7 @@ Version 4.x is JDK17 LTS bytecode compatible, with Docker and JUnit / direct Jav
170172
* Allow overriding headers in head object
171173
* Implement If-(Un)modified-Since handling (fixes #829)
172174
* Close all InputStreams and OutputStreams
175+
* Checksums are returned for MultipartUploads as part of the response body
173176
* Add AWS SDK V1 deprecation notice
174177
* AWS has deprecated SDK for Java v1, and will remove support EOY 2025.
175178
* S3Mock will remove usage of Java v1 early 2026.
@@ -178,7 +181,7 @@ Version 4.x is JDK17 LTS bytecode compatible, with Docker and JUnit / direct Jav
178181
* "FROM" in Dockerfile did not match "as"
179182
* Delete files on shutdown using a `DisposableBean` instead of `File#deleteOnExit()`
180183
* Version updates (deliverable dependencies)
181-
* Bump spring-boot.version from 3.3.5 to 3.4.4
184+
* Bump spring-boot.version from 3.3.3 to 3.4.4
182185
* Jackson 2.18.2 to 2.17.2 (remove override, use Spring-Boot supplied version)
183186
* Bump aws-v2.version from 2.29.29 to 2.31.17
184187
* Bump aws.version from 1.12.779 to 1.12.780

integration-tests/pom.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,6 @@
4848
</exclusion>
4949
</exclusions>
5050
</dependency>
51-
<dependency>
52-
<groupId>com.amazonaws</groupId>
53-
<artifactId>aws-java-sdk-core</artifactId>
54-
<scope>test</scope>
55-
</dependency>
56-
<dependency>
57-
<groupId>com.amazonaws</groupId>
58-
<artifactId>aws-java-sdk-s3</artifactId>
59-
<scope>test</scope>
60-
</dependency>
61-
<dependency>
62-
<groupId>org.apache.commons</groupId>
63-
<artifactId>commons-lang3</artifactId>
64-
<scope>test</scope>
65-
</dependency>
6651
<dependency>
6752
<groupId>org.assertj</groupId>
6853
<artifactId>assertj-core</artifactId>

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/AclITV2.kt renamed to integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/AclIT.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,34 @@ import software.amazon.awssdk.services.s3.model.ObjectOwnership
2727
import software.amazon.awssdk.services.s3.model.Permission.FULL_CONTROL
2828
import software.amazon.awssdk.services.s3.model.Type.CANONICAL_USER
2929

30-
internal class AclITV2 : S3TestBase() {
31-
private val s3ClientV2: S3Client = createS3ClientV2()
30+
internal class AclIT : S3TestBase() {
31+
private val s3Client: S3Client = createS3Client()
3232

3333
@Test
34-
@S3VerifiedSuccess(year = 2024)
35-
fun testPutCannedAcl_OK(testInfo: TestInfo) {
34+
@S3VerifiedSuccess(year = 2025)
35+
fun `put canned ACL returns OK, get ACL returns the ACL`(testInfo: TestInfo) {
3636
val sourceKey = UPLOAD_FILE_NAME
3737
val bucketName = bucketName(testInfo)
3838

3939
//create bucket that sets ownership to non-default to allow setting ACLs.
40-
s3ClientV2.createBucket {
40+
s3Client.createBucket {
4141
it.bucket(bucketName)
4242
it.objectOwnership(ObjectOwnership.OBJECT_WRITER)
4343
}.also {
4444
assertThat(it.sdkHttpResponse().isSuccessful).isTrue()
4545
}
4646

47-
givenObjectV2(bucketName, sourceKey)
47+
givenObject(bucketName, sourceKey)
4848

49-
s3ClientV2.putObjectAcl {
49+
s3Client.putObjectAcl {
5050
it.bucket(bucketName)
5151
it.key(sourceKey)
5252
it.acl(ObjectCannedACL.PRIVATE)
5353
}.also {
5454
assertThat(it.sdkHttpResponse().isSuccessful).isTrue()
5555
}
5656

57-
s3ClientV2.getObjectAcl {
57+
s3Client.getObjectAcl {
5858
it.bucket(bucketName)
5959
it.key(sourceKey)
6060
}.also {
@@ -69,11 +69,11 @@ internal class AclITV2 : S3TestBase() {
6969
@Test
7070
@S3VerifiedFailure(year = 2022,
7171
reason = "Owner and Grantee not available on test AWS account.")
72-
fun testGetAcl_noAcl(testInfo: TestInfo) {
72+
fun `get ACL returns canned 'private' ACL`(testInfo: TestInfo) {
7373
val sourceKey = UPLOAD_FILE_NAME
74-
val (bucketName, _) = givenBucketAndObjectV2(testInfo, sourceKey)
74+
val (bucketName, _) = givenBucketAndObject(testInfo, sourceKey)
7575

76-
val acl = s3ClientV2.getObjectAcl {
76+
val acl = s3Client.getObjectAcl {
7777
it.bucket(bucketName)
7878
it.key(sourceKey)
7979
}
@@ -100,16 +100,16 @@ internal class AclITV2 : S3TestBase() {
100100
@Test
101101
@S3VerifiedFailure(year = 2022,
102102
reason = "Owner and Grantee not available on test AWS account.")
103-
fun testPutAndGetAcl(testInfo: TestInfo) {
103+
fun `put ACL returns OK, get ACL returns the ACL`(testInfo: TestInfo) {
104104
val sourceKey = UPLOAD_FILE_NAME
105-
val (bucketName, _) = givenBucketAndObjectV2(testInfo, sourceKey)
105+
val (bucketName, _) = givenBucketAndObject(testInfo, sourceKey)
106106

107107
val userId = "79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2ab"
108108
val userName = "John Doe"
109109
val granteeId = "79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2ef"
110110
val granteeName = "Jane Doe"
111111
val granteeEmail = "jane@doe.com"
112-
s3ClientV2.putObjectAcl {
112+
s3Client.putObjectAcl {
113113
it.bucket(bucketName)
114114
it.key(sourceKey)
115115
it.accessControlPolicy {
@@ -129,7 +129,7 @@ internal class AclITV2 : S3TestBase() {
129129
}
130130
}
131131

132-
val acl = s3ClientV2.getObjectAcl {
132+
val acl = s3Client.getObjectAcl {
133133
it.bucket(bucketName)
134134
it.key(sourceKey)
135135
}

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/AwsChunkedEndcodingITV2.kt renamed to integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/AwsChunkedEndcodingIT.kt

Lines changed: 26 additions & 32 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.
@@ -23,18 +23,16 @@ import org.junit.jupiter.api.TestInfo
2323
import software.amazon.awssdk.core.checksums.Algorithm
2424
import software.amazon.awssdk.core.sync.RequestBody
2525
import software.amazon.awssdk.services.s3.model.ChecksumAlgorithm
26-
import software.amazon.awssdk.services.s3.model.GetObjectRequest
27-
import software.amazon.awssdk.services.s3.model.PutObjectRequest
2826
import java.io.File
2927
import java.io.FileInputStream
3028
import java.io.InputStream
3129

3230
/**
3331
* Chunked encoding with signing is only active in AWS SDK v2 when endpoint is http
3432
*/
35-
internal class AwsChunkedEndcodingITV2 : S3TestBase() {
33+
internal class AwsChunkedEndcodingIT : S3TestBase() {
3634

37-
private val s3ClientV2 = createS3ClientV2(serviceEndpointHttp)
35+
private val s3Client = createS3Client(serviceEndpointHttp)
3836

3937
/**
4038
* Unfortunately the S3 API does not persist or return data that would let us verify if signed and chunked encoding
@@ -46,19 +44,19 @@ internal class AwsChunkedEndcodingITV2 : S3TestBase() {
4644
year = 2023,
4745
reason = "Only works with http endpoints"
4846
)
49-
fun testPutObject_checksum(testInfo: TestInfo) {
50-
val bucket = givenBucketV2(testInfo)
47+
fun `put object with checksum returns correct checksum, get object returns checksum`(testInfo: TestInfo) {
48+
val bucket = givenBucket(testInfo)
5149
val uploadFile = File(UPLOAD_FILE_NAME)
5250
val uploadFileIs: InputStream = FileInputStream(uploadFile)
5351
val expectedEtag = "\"${DigestUtil.hexDigest(uploadFileIs)}\""
5452
val expectedChecksum = DigestUtil.checksumFor(uploadFile.toPath(), Algorithm.SHA256)
5553

56-
val putObjectResponse = s3ClientV2.putObject(
57-
PutObjectRequest.builder()
58-
.bucket(bucket)
59-
.key(UPLOAD_FILE_NAME)
60-
.checksumAlgorithm(ChecksumAlgorithm.SHA256)
61-
.build(),
54+
val putObjectResponse = s3Client.putObject(
55+
{
56+
it.bucket(bucket)
57+
it.key(UPLOAD_FILE_NAME)
58+
it.checksumAlgorithm(ChecksumAlgorithm.SHA256)
59+
},
6260
RequestBody.fromFile(uploadFile)
6361
)
6462

@@ -67,12 +65,10 @@ internal class AwsChunkedEndcodingITV2 : S3TestBase() {
6765
assertThat(it).isEqualTo(expectedChecksum)
6866
}
6967

70-
s3ClientV2.getObject(
71-
GetObjectRequest.builder()
72-
.bucket(bucket)
73-
.key(UPLOAD_FILE_NAME)
74-
.build()
75-
).also { getObjectResponse ->
68+
s3Client.getObject {
69+
it.bucket(bucket)
70+
it.key(UPLOAD_FILE_NAME)
71+
}.also { getObjectResponse ->
7672
assertThat(getObjectResponse.response().eTag()).isEqualTo(expectedEtag)
7773
assertThat(getObjectResponse.response().contentLength()).isEqualTo(uploadFile.length())
7874

@@ -93,26 +89,24 @@ internal class AwsChunkedEndcodingITV2 : S3TestBase() {
9389
year = 2023,
9490
reason = "Only works with http endpoints"
9591
)
96-
fun testPutObject_etagCreation(testInfo: TestInfo) {
97-
val bucket = givenBucketV2(testInfo)
92+
fun `put object creates correct etag, get object returns etag`(testInfo: TestInfo) {
93+
val bucket = givenBucket(testInfo)
9894
val uploadFile = File(UPLOAD_FILE_NAME)
9995
val uploadFileIs: InputStream = FileInputStream(uploadFile)
10096
val expectedEtag = "\"${DigestUtil.hexDigest(uploadFileIs)}\""
10197

102-
s3ClientV2.putObject(
103-
PutObjectRequest.builder()
104-
.bucket(bucket)
105-
.key(UPLOAD_FILE_NAME)
106-
.build(),
98+
s3Client.putObject(
99+
{
100+
it.bucket(bucket)
101+
it.key(UPLOAD_FILE_NAME)
102+
},
107103
RequestBody.fromFile(uploadFile)
108104
)
109105

110-
s3ClientV2.getObject(
111-
GetObjectRequest.builder()
112-
.bucket(bucket)
113-
.key(UPLOAD_FILE_NAME)
114-
.build()
115-
).also {
106+
s3Client.getObject {
107+
it.bucket(bucket)
108+
it.key(UPLOAD_FILE_NAME)
109+
}.also {
116110
assertThat(it.response().eTag()).isEqualTo(expectedEtag)
117111
assertThat(it.response().contentLength()).isEqualTo(uploadFile.length())
118112
}

0 commit comments

Comments
 (0)