|
25 | 25 | import org.apache.hadoop.fs.Path; |
26 | 26 | import org.apache.hadoop.fs.s3a.Constants; |
27 | 27 | import org.apache.hadoop.fs.s3a.EncryptionTestUtils; |
| 28 | +import org.apache.hadoop.fs.s3a.S3AEncryptionMethods; |
28 | 29 | import org.apache.hadoop.fs.s3a.S3AFileSystem; |
29 | 30 |
|
30 | 31 | import static org.apache.hadoop.fs.s3a.Constants.S3_ENCRYPTION_ALGORITHM; |
31 | 32 | import static org.apache.hadoop.fs.s3a.S3AEncryptionMethods.DSSE_KMS; |
32 | 33 | import static org.apache.hadoop.fs.s3a.S3AEncryptionMethods.SSE_KMS; |
33 | 34 | import static org.apache.hadoop.fs.s3a.S3ATestUtils.getTestBucketName; |
34 | 35 | import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfEncryptionNotSet; |
| 36 | +import static org.apache.hadoop.fs.s3a.S3AUtils.getEncryptionAlgorithm; |
35 | 37 | import static org.apache.hadoop.fs.s3a.S3AUtils.getS3EncryptionKey; |
36 | 38 |
|
37 | 39 | /** |
@@ -68,13 +70,16 @@ protected boolean isEncrypted(S3AFileSystem fileSystem) { |
68 | 70 | @Override |
69 | 71 | protected void assertEncrypted(Path hugeFile) throws IOException { |
70 | 72 | Configuration c = new Configuration(); |
71 | | - String kmsKey = getS3EncryptionKey(getTestBucketName(c), c); |
72 | | - if (SSE_KMS.getMethod().equals(c.get(S3_ENCRYPTION_ALGORITHM))) { |
| 73 | + |
| 74 | + final String bucket = getTestBucketName(c); |
| 75 | + String kmsKey = getS3EncryptionKey(bucket, c); |
| 76 | + final S3AEncryptionMethods algorithm = getEncryptionAlgorithm(bucket, c); |
| 77 | + if (SSE_KMS.equals(algorithm)) { |
73 | 78 | EncryptionTestUtils.assertEncrypted(getFileSystem(), hugeFile, SSE_KMS, kmsKey); |
74 | | - } else if (DSSE_KMS.getMethod().equals(c.get(S3_ENCRYPTION_ALGORITHM))) { |
| 79 | + } else if (DSSE_KMS.equals(algorithm)) { |
75 | 80 | EncryptionTestUtils.assertEncrypted(getFileSystem(), hugeFile, DSSE_KMS, kmsKey); |
76 | 81 | } else { |
77 | | - throw new AssertionError("Invalid encryption configured"); |
| 82 | + throw new AssertionError("Invalid encryption configured: " + algorithm); |
78 | 83 | } |
79 | 84 | } |
80 | 85 | } |
0 commit comments