package gobblin.crypto;

import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;
import org.testng.annotations.Test;

import gobblin.codec.StreamCodec;


public class GobblinEncryptionProviderTest {
  @Test
  public void testCanBuildAes() {
    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());
    properties.put(EncryptionConfigParser.ENCRYPTION_KEYSTORE_PASSWORD_KEY, "abcd");

    StreamCodec c = EncryptionFactory.buildStreamCryptoProvider(properties);
    Assert.assertNotNull(c);
  }
}

@@ -18,16 +18,153 @@
 rypto;%0A%0A
+import java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.nio.charset.StandardCharsets;%0A
 import j
@@ -181,16 +181,16 @@
 ashMap;%0A
-
 import j
@@ -386,16 +386,35 @@
 ildAes()
+ throws IOException
  %7B%0A    M
@@ -856,16 +856,16 @@
 rties);%0A
-
     Asse
@@ -884,15 +884,366 @@
 Null(c);
+%0A%0A    byte%5B%5D toEncrypt = %22Hello!%22.getBytes(StandardCharsets.UTF_8);%0A%0A    ByteArrayOutputStream cipherOut = new ByteArrayOutputStream();%0A    OutputStream cipherStream = c.encodeOutputStream(cipherOut);%0A    cipherStream.write(toEncrypt);%0A    cipherStream.close();%0A%0A    Assert.assertTrue(%22Expected to be able to write ciphertext!%22, cipherOut.size() %3E 0);
 %0A  %7D%0A%7D%0A

make sure we test the encryption actually works