Search in sources :

Example 6 with EncryptorConfig

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");
}
Also used : CommandLine(picocli.CommandLine) EncryptorConfig(com.quorum.tessera.config.EncryptorConfig) Test(org.junit.Test)

Example 7 with EncryptorConfig

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();
}
Also used : CommandLine(picocli.CommandLine) EncryptorConfig(com.quorum.tessera.config.EncryptorConfig) Test(org.junit.Test)

Example 8 with EncryptorConfig

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();
}
Also used : EncryptorConfig(com.quorum.tessera.config.EncryptorConfig) Test(org.junit.Test)

Example 9 with EncryptorConfig

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);
}
Also used : EnvironmentVariableProvider(com.quorum.tessera.config.util.EnvironmentVariableProvider) EncryptorConfig(com.quorum.tessera.config.EncryptorConfig) Test(org.junit.Test)

Example 10 with EncryptorConfig

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));
}
Also used : EncryptorConfig(com.quorum.tessera.config.EncryptorConfig) Config(com.quorum.tessera.config.Config) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EncryptorConfig(com.quorum.tessera.config.EncryptorConfig) Test(org.junit.Test)

Aggregations

EncryptorConfig (com.quorum.tessera.config.EncryptorConfig)12 Test (org.junit.Test)9 Config (com.quorum.tessera.config.Config)3 CommandLine (picocli.CommandLine)3 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)2 KeyEncryptorFactory (com.quorum.tessera.config.keys.KeyEncryptorFactory)2 EnvironmentVariableProvider (com.quorum.tessera.config.util.EnvironmentVariableProvider)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DefaultKeyVaultConfig (com.quorum.tessera.config.DefaultKeyVaultConfig)1 ServerConfig (com.quorum.tessera.config.ServerConfig)1 ConfigKeyPair (com.quorum.tessera.config.keypairs.ConfigKeyPair)1 KeyDataUtil (com.quorum.tessera.config.util.KeyDataUtil)1 PublicKey (com.quorum.tessera.encryption.PublicKey)1 ClientFactory (com.quorum.tessera.jaxrs.client.ClientFactory)1 KeyVaultService (com.quorum.tessera.key.vault.KeyVaultService)1 KeyVaultServiceFactory (com.quorum.tessera.key.vault.KeyVaultServiceFactory)1 PartyInfoParser (com.quorum.tessera.p2p.partyinfo.PartyInfoParser)1 PartyInfo (com.quorum.tessera.partyinfo.model.PartyInfo)1 Recipient (com.quorum.tessera.partyinfo.model.Recipient)1 JsonObject (jakarta.json.JsonObject)1