Skip to content

Commit c96fd86

Browse files
committed
Add test for unquoted if-none-match header
1 parent 48c63fd commit c96fd86

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/GetPutDeleteObjectIT.kt

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -226,24 +226,6 @@ internal class GetPutDeleteObjectIT : S3TestBase() {
226226
// .hasMessageContaining(NO_SUCH_KEY)
227227
}
228228

229-
@Test
230-
@S3VerifiedSuccess(year = 2025)
231-
fun `GET object succeeds with unquoted if-match header`(testInfo: TestInfo) {
232-
val (bucketName, putObjectResponse) = givenBucketAndObject(testInfo, UPLOAD_FILE_NAME)
233-
val matchingEtag = putObjectResponse.eTag()
234-
// TODO: should work with both quoted and unquoted etags
235-
val unquotedEtag = matchingEtag.substring(1, matchingEtag.length - 1)
236-
s3Client
237-
.getObject {
238-
it.bucket(bucketName)
239-
it.key(UPLOAD_FILE_NAME)
240-
it.ifMatch(matchingEtag)
241-
}.use {
242-
assertThat(it.response().eTag()).isEqualTo(matchingEtag)
243-
assertThat(it.response().contentLength()).isEqualTo(UPLOAD_FILE_LENGTH)
244-
}
245-
}
246-
247229
@Test
248230
@S3VerifiedSuccess(year = 2025)
249231
fun copyObjectToNonExistingDestination_noSuchBucket(testInfo: TestInfo) {
@@ -1354,6 +1336,24 @@ internal class GetPutDeleteObjectIT : S3TestBase() {
13541336
}
13551337
}
13561338

1339+
@Test
1340+
@S3VerifiedSuccess(year = 2025)
1341+
fun `GET object succeeds with unquoted if-match=true`(testInfo: TestInfo) {
1342+
val (bucketName, putObjectResponse) = givenBucketAndObject(testInfo, UPLOAD_FILE_NAME)
1343+
val matchingEtag = putObjectResponse.eTag()
1344+
// TODO: should work with both quoted and unquoted etags
1345+
val unquotedEtag = matchingEtag.substring(1, matchingEtag.length - 1)
1346+
s3Client
1347+
.getObject {
1348+
it.bucket(bucketName)
1349+
it.key(UPLOAD_FILE_NAME)
1350+
it.ifMatch(matchingEtag)
1351+
}.use {
1352+
assertThat(it.response().eTag()).isEqualTo(matchingEtag)
1353+
assertThat(it.response().contentLength()).isEqualTo(UPLOAD_FILE_LENGTH)
1354+
}
1355+
}
1356+
13571357
@Test
13581358
@S3VerifiedSuccess(year = 2025)
13591359
fun `GET object succeeds with if-match=true and if-unmodified-since=false`(testInfo: TestInfo) {
@@ -1425,6 +1425,24 @@ internal class GetPutDeleteObjectIT : S3TestBase() {
14251425
.hasMessageContaining("Service: S3, Status Code: 304")
14261426
}
14271427

1428+
@Test
1429+
@S3VerifiedSuccess(year = 2025)
1430+
fun `GET object fails with unquoted if-none-match=false`(testInfo: TestInfo) {
1431+
val (bucketName, putObjectResponse) = givenBucketAndObject(testInfo, UPLOAD_FILE_NAME)
1432+
val matchingEtag = putObjectResponse.eTag()
1433+
// TODO: should work with both quoted and unquoted etags
1434+
val unquotedEtag = matchingEtag.substring(1, matchingEtag.length - 1)
1435+
1436+
assertThatThrownBy {
1437+
s3Client.getObject {
1438+
it.bucket(bucketName)
1439+
it.key(UPLOAD_FILE_NAME)
1440+
it.ifNoneMatch(matchingEtag)
1441+
}
1442+
}.isInstanceOf(S3Exception::class.java)
1443+
.hasMessageContaining("Service: S3, Status Code: 304")
1444+
}
1445+
14281446
@Test
14291447
@S3VerifiedSuccess(year = 2025)
14301448
fun `GET object succeeds with if-modified-since=true`(testInfo: TestInfo) {

0 commit comments

Comments
 (0)