Skip to content

Commit c69157e

Browse files
HADOOP-19197. Implement testUnmarshallOldEncryptionSecrets()
The old version of EncryptionSecrets is written to serialized-objects/EncryptionSecrets-HADOOP-19197.ser. The test will marshall the object from the old version.
1 parent 1ce9d27 commit c69157e

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/TestMarshalledCredentials.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
package org.apache.hadoop.fs.s3a.auth;
2020

2121
import java.io.EOFException;
22+
import java.io.FileInputStream;
2223
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.io.ObjectInputStream;
2326
import java.net.URI;
2427
import java.net.URISyntaxException;
2528
import java.util.Optional;
@@ -40,6 +43,7 @@
4043
import org.apache.hadoop.io.Text;
4144
import org.apache.hadoop.test.HadoopTestBase;
4245

46+
import static org.apache.hadoop.fs.s3a.Constants.DEFAULT_S3_ENCRYPTION_CONTEXT;
4347
import static org.apache.hadoop.fs.s3a.S3AEncryptionMethods.SSE_S3;
4448
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
4549

@@ -165,9 +169,23 @@ public void testCredentialProviderNullURI() throws Throwable {
165169
MarshalledCredentials.CredentialTypeRequired.FullOnly));
166170
}
167171

168-
@org.junit.Test
172+
@Test
169173
public void testUnmarshallOldEncryptionSecrets() throws Throwable {
170-
174+
try (InputStream is = getClass()
175+
.getResourceAsStream("/serialized-objects/EncryptionSecrets-HADOOP-19197.ser");
176+
ObjectInputStream ois = new ObjectInputStream(is)) {
177+
EncryptionSecrets secrets = new EncryptionSecrets();
178+
secrets.readFields(ois);
179+
Assertions.assertThat(secrets.getEncryptionAlgorithm())
180+
.describedAs("encryptionAlgorithm")
181+
.isEqualTo(S3AEncryptionMethods.SSE_KMS.getMethod());
182+
Assertions.assertThat(secrets .getEncryptionKey())
183+
.describedAs("encryptionKey")
184+
.isEqualTo(KEY);
185+
Assertions.assertThat(secrets .getEncryptionContext())
186+
.describedAs("encryptionContext")
187+
.isEqualTo(DEFAULT_S3_ENCRYPTION_CONTEXT);
188+
}
171189
}
172190

173191
/**
Binary file not shown.

0 commit comments

Comments
 (0)