Skip to content

Commit

Permalink
HADOOP-18965. ITestS3AHugeFilesEncryption failure
Browse files Browse the repository at this point in the history
Change-Id: I0e826af64f09992f385ed8f5f8064f016a9084c6
  • Loading branch information
steveloughran committed Nov 8, 2023
1 parent f58945d commit 09eeb45
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.s3a.Constants;
import org.apache.hadoop.fs.s3a.EncryptionTestUtils;
import org.apache.hadoop.fs.s3a.S3AEncryptionMethods;
import org.apache.hadoop.fs.s3a.S3AFileSystem;

import static org.apache.hadoop.fs.s3a.Constants.S3_ENCRYPTION_ALGORITHM;
import static org.apache.hadoop.fs.s3a.S3AEncryptionMethods.DSSE_KMS;
import static org.apache.hadoop.fs.s3a.S3AEncryptionMethods.SSE_KMS;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.getTestBucketName;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfEncryptionNotSet;
import static org.apache.hadoop.fs.s3a.S3AUtils.getEncryptionAlgorithm;
import static org.apache.hadoop.fs.s3a.S3AUtils.getS3EncryptionKey;

/**
Expand Down Expand Up @@ -68,13 +70,16 @@ protected boolean isEncrypted(S3AFileSystem fileSystem) {
@Override
protected void assertEncrypted(Path hugeFile) throws IOException {
Configuration c = new Configuration();
String kmsKey = getS3EncryptionKey(getTestBucketName(c), c);
if (SSE_KMS.getMethod().equals(c.get(S3_ENCRYPTION_ALGORITHM))) {

final String bucket = getTestBucketName(c);
String kmsKey = getS3EncryptionKey(bucket, c);
final S3AEncryptionMethods algorithm = getEncryptionAlgorithm(bucket, c);
if (SSE_KMS.equals(algorithm)) {
EncryptionTestUtils.assertEncrypted(getFileSystem(), hugeFile, SSE_KMS, kmsKey);
} else if (DSSE_KMS.getMethod().equals(c.get(S3_ENCRYPTION_ALGORITHM))) {
} else if (DSSE_KMS.equals(algorithm)) {
EncryptionTestUtils.assertEncrypted(getFileSystem(), hugeFile, DSSE_KMS, kmsKey);
} else {
throw new AssertionError("Invalid encryption configured");
throw new AssertionError("Invalid encryption configured: " + algorithm);
}
}
}

0 comments on commit 09eeb45

Please sign in to comment.