use of com.quorum.tessera.config.EncryptorConfig in project tessera by ConsenSys.
the class EncryptorOptionsTest method ellipticalCurveWithDefinedProperties.
@Test
public void ellipticalCurveWithDefinedProperties() {
EncryptorOptions encryptorOptions = new EncryptorOptions();
String[] args = new String[] { "--encryptor.type=EC", "--encryptor.symmetricCipher=somecipher", "--encryptor.ellipticCurve=somecurve", "--encryptor.nonceLength=3", "--encryptor.sharedKeyLength=2" };
new CommandLine(encryptorOptions).parseArgs(args);
EncryptorConfig result = encryptorOptions.parseEncryptorConfig();
assertThat(result.getType()).isEqualTo(EncryptorType.EC);
assertThat(result.getProperties()).containsOnlyKeys("symmetricCipher", "ellipticCurve", "nonceLength", "sharedKeyLength");
assertThat(result.getProperties().get("symmetricCipher")).isEqualTo("somecipher");
assertThat(result.getProperties().get("ellipticCurve")).isEqualTo("somecurve");
assertThat(result.getProperties().get("nonceLength")).isEqualTo("3");
assertThat(result.getProperties().get("sharedKeyLength")).isEqualTo("2");
}
use of com.quorum.tessera.config.EncryptorConfig in project tessera by ConsenSys.
the class EncryptorOptionsTest method encryptorTypeCUSTOM.
@Test
public void encryptorTypeCUSTOM() {
EncryptorOptions encryptorOptions = new EncryptorOptions();
String[] args = new String[] { "--encryptor.type=CUSTOM" };
new CommandLine(encryptorOptions).parseArgs(args);
EncryptorConfig result = encryptorOptions.parseEncryptorConfig();
assertThat(result).isNotNull();
assertThat(result.getType()).isEqualTo(EncryptorType.CUSTOM);
assertThat(result.getProperties()).isEmpty();
}
use of com.quorum.tessera.config.EncryptorConfig in project tessera by ConsenSys.
the class EncryptorOptionsTest method encryptorTypeDefaultsToNACL.
@Test
public void encryptorTypeDefaultsToNACL() {
EncryptorOptions encryptorOptions = new EncryptorOptions();
EncryptorConfig result = encryptorOptions.parseEncryptorConfig();
assertThat(result.getType()).isEqualTo(EncryptorType.NACL);
assertThat(result.getProperties()).isEmpty();
}
use of com.quorum.tessera.config.EncryptorConfig in project tessera by ConsenSys.
the class KeyGeneratorFactoryTest method fileKeyGeneratorWhenKeyVaultConfigNotProvided.
@Test
public void fileKeyGeneratorWhenKeyVaultConfigNotProvided() {
final EnvironmentVariableProvider envProvider = mock(EnvironmentVariableProvider.class);
EncryptorConfig encryptorConfig = mock(EncryptorConfig.class);
when(encryptorConfig.getType()).thenReturn(EncryptorType.EC);
when(encryptorConfig.getProperties()).thenReturn(Collections.EMPTY_MAP);
final KeyGenerator keyGenerator = KeyGeneratorFactory.create().create(null, encryptorConfig);
when(envProvider.getEnv(anyString())).thenReturn("env");
assertThat(keyGenerator).isNotNull();
assertThat(keyGenerator).isExactlyInstanceOf(FileKeyGenerator.class);
}
use of com.quorum.tessera.config.EncryptorConfig in project tessera by ConsenSys.
the class JaxbConfigFactoryTest method createMinimal.
@Test
public void createMinimal() {
final EncryptorConfig encryptorConfig = new EncryptorConfig() {
{
setType(EncryptorType.NACL);
}
};
Config config = new Config();
config.setEncryptor(encryptorConfig);
InputStream in = Optional.of(config).map(JaxbUtil::marshalToStringNoValidation).map(String::getBytes).map(ByteArrayInputStream::new).get();
JaxbUtil.marshalToStringNoValidation(config);
Config result = factory.create(in);
assertThat(result).isNotNull();
verify(keyEncryptorFactory).create(any(EncryptorConfig.class));
}
Aggregations