Skip to content

chore: cleanup some test code #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,25 @@

public class S3EncryptionClientMultipartUploadTest {
private static SecretKey AES_KEY;
private static Provider PROVIDER;

@BeforeAll
public static void setUp() throws NoSuchAlgorithmException {
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(256);
AES_KEY = keyGen.generateKey();

Security.addProvider(new BouncyCastleProvider());
PROVIDER = Security.getProvider("BC");
}

@Test
public void failsMultipartPutObjectWhenWrappedClientIsEnabled() throws IOException {
final String objectKey = appendTestSuffix("multipart-put-object");
public void failsMultipartPutObjectWhenWrappedClientIsEnabled() {
final String objectKey = appendTestSuffix("multipart-put-object-fails");

final long fileSizeLimit = 1024 * 1024 * 100;
final InputStream inputStream = new BoundedZerosInputStream(fileSizeLimit);

Security.addProvider(new BouncyCastleProvider());
Provider provider = Security.getProvider("BC");

S3AsyncClient wrappedClient = S3AsyncClient.create();

Expand All @@ -68,7 +70,7 @@ public void failsMultipartPutObjectWhenWrappedClientIsEnabled() throws IOExcepti
.wrappedClient(wrappedClient)
.enableMultipartPutObject(true)
.enableDelayedAuthenticationMode(true)
.cryptoProvider(provider)
.cryptoProvider(PROVIDER)
.build();

Map<String, String> encryptionContext = new HashMap<>();
Expand All @@ -91,14 +93,11 @@ public void multipartPutObject() throws IOException {
final InputStream inputStream = new BoundedZerosInputStream(fileSizeLimit);
final InputStream objectStreamForResult = new BoundedZerosInputStream(fileSizeLimit);

Security.addProvider(new BouncyCastleProvider());
Provider provider = Security.getProvider("BC");

S3Client v3Client = S3EncryptionClient.builder()
.kmsKeyId(KMS_KEY_ID)
.enableMultipartPutObject(true)
.enableDelayedAuthenticationMode(true)
.cryptoProvider(provider)
.cryptoProvider(PROVIDER)
.build();

Map<String, String> encryptionContext = new HashMap<>();
Expand All @@ -123,20 +122,17 @@ public void multipartPutObject() throws IOException {

@Test
public void multipartPutObjectAsync() throws IOException {
final String objectKey = appendTestSuffix("multipart-put-object");
final String objectKey = appendTestSuffix("multipart-put-object-async");

final long fileSizeLimit = 1024 * 1024 * 100;
final InputStream inputStream = new BoundedZerosInputStream(fileSizeLimit);
final InputStream objectStreamForResult = new BoundedZerosInputStream(fileSizeLimit);

Security.addProvider(new BouncyCastleProvider());
Provider provider = Security.getProvider("BC");

S3AsyncClient v3Client = S3AsyncEncryptionClient.builder()
.kmsKeyId(KMS_KEY_ID)
.enableMultipartPutObject(true)
.enableDelayedAuthenticationMode(true)
.cryptoProvider(provider)
.cryptoProvider(PROVIDER)
.build();

Map<String, String> encryptionContext = new HashMap<>();
Expand Down Expand Up @@ -168,14 +164,11 @@ public void multipartUploadV3OutputStream() throws IOException {
final int PART_SIZE = 10 * 1024 * 1024;
final InputStream inputStream = new BoundedZerosInputStream(fileSizeLimit);

Security.addProvider(new BouncyCastleProvider());
Provider provider = Security.getProvider("BC");

// V3 Client
S3Client v3Client = S3EncryptionClient.builder()
.aesKey(AES_KEY)
.enableDelayedAuthenticationMode(true)
.cryptoProvider(provider)
.cryptoProvider(PROVIDER)
.build();

// Create Multipart upload request to S3
Expand Down