@@ -511,29 +511,6 @@ public void s3EncryptionClientFromAESKeyringUsesDifferentSecureRandomThanKeyring
511
511
v3Client .close ();
512
512
}
513
513
514
- /**
515
- * A simple, reusable round-trip (encryption + decryption) using a given
516
- * S3Client. Useful for testing client configuration.
517
- *
518
- * @param v3Client the client under test
519
- */
520
- private void simpleV3RoundTrip (final S3Client v3Client , final String objectKey ) {
521
- final String input = "SimpleTestOfV3EncryptionClient" ;
522
-
523
- v3Client .putObject (builder -> builder
524
- .bucket (BUCKET )
525
- .key (objectKey )
526
- .build (),
527
- RequestBody .fromString (input ));
528
-
529
- ResponseBytes <GetObjectResponse > objectResponse = v3Client .getObjectAsBytes (builder -> builder
530
- .bucket (BUCKET )
531
- .key (objectKey )
532
- .build ());
533
- String output = objectResponse .asUtf8String ();
534
- assertEquals (input , output );
535
- }
536
-
537
514
@ Test
538
515
public void cryptoProviderV3toV3Enabled () {
539
516
final String objectKey = appendTestSuffix ("crypto-provider-enabled-v3-to-v3" );
@@ -599,4 +576,58 @@ public void cryptoProviderV2toV3Enabled() {
599
576
deleteObject (BUCKET , objectKey , v3Client );
600
577
v3Client .close ();
601
578
}
579
+
580
+ @ Test
581
+ public void contentLengthRequest () {
582
+ final String objectKey = appendTestSuffix ("content-length" );
583
+
584
+ S3Client s3EncryptionClient = S3EncryptionClient .builder ()
585
+ .kmsKeyId (KMS_KEY_ID )
586
+ .build ();
587
+
588
+ final String input = "SimpleTestOfV3EncryptionClientCopyObject" ;
589
+ final int inputLength = input .length ();
590
+
591
+ s3EncryptionClient .putObject (builder -> builder
592
+ .bucket (BUCKET )
593
+ .key (objectKey )
594
+ .contentLength ((long ) inputLength )
595
+ .build (),
596
+ RequestBody .fromString (input ));
597
+
598
+ ResponseBytes <GetObjectResponse > objectResponse = s3EncryptionClient .getObjectAsBytes (builder -> builder
599
+ .bucket (BUCKET )
600
+ .key (objectKey )
601
+ .build ());
602
+ String output = objectResponse .asUtf8String ();
603
+ assertEquals (input , output );
604
+
605
+ // Cleanup
606
+ deleteObject (BUCKET , objectKey , s3EncryptionClient );
607
+ s3EncryptionClient .close ();
608
+ }
609
+
610
+ /**
611
+ * A simple, reusable round-trip (encryption + decryption) using a given
612
+ * S3Client. Useful for testing client configuration.
613
+ *
614
+ * @param v3Client the client under test
615
+ */
616
+ private void simpleV3RoundTrip (final S3Client v3Client , final String objectKey ) {
617
+ final String input = "SimpleTestOfV3EncryptionClient" ;
618
+
619
+ v3Client .putObject (builder -> builder
620
+ .bucket (BUCKET )
621
+ .key (objectKey )
622
+ .build (),
623
+ RequestBody .fromString (input ));
624
+
625
+ ResponseBytes <GetObjectResponse > objectResponse = v3Client .getObjectAsBytes (builder -> builder
626
+ .bucket (BUCKET )
627
+ .key (objectKey )
628
+ .build ());
629
+ String output = objectResponse .asUtf8String ();
630
+ assertEquals (input , output );
631
+ }
632
+
602
633
}
0 commit comments