make sure we test the encryption actually works
package gobblin.crypto;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -11,7 +15,7 @@ import gobblin.codec.StreamCodec;
public class GobblinEncryptionProviderTest {
@Test
- public void testCanBuildAes() {
+ public void testCanBuildAes() throws IOException {
Map<String, Object> properties = new HashMap<>();
properties.put(EncryptionConfigParser.ENCRYPTION_ALGORITHM_KEY, "aes_rotating");
properties.put(EncryptionConfigParser.ENCRYPTION_KEYSTORE_PATH_KEY, getClass().getResource("/encryption_provider_test_keystore").toString());
@@ -19,5 +23,14 @@ public class GobblinEncryptionProviderTest {
StreamCodec c = EncryptionFactory.buildStreamCryptoProvider(properties);
Assert.assertNotNull(c);
+
+ byte[] toEncrypt = "Hello!".getBytes(StandardCharsets.UTF_8);
+
+ ByteArrayOutputStream cipherOut = new ByteArrayOutputStream();
+ OutputStream cipherStream = c.encodeOutputStream(cipherOut);
+ cipherStream.write(toEncrypt);
+ cipherStream.close();
+
+ Assert.assertTrue("Expected to be able to write ciphertext!", cipherOut.size() > 0);
}
}
