Search in sources :

Example 26 with KeyData

use of com.quorum.tessera.config.KeyData in project tessera by ConsenSys.

the class KeyDataUtilTest method unmarshalAwsVaultKeyPair.

@Test
public void unmarshalAwsVaultKeyPair() {
    KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
    KeyData keyData = new KeyData();
    keyData.setAwsSecretsManagerPrivateKeyId("AwsSecretsManagerPrivateKeyId");
    keyData.setAwsSecretsManagerPublicKeyId("AwsSecretsManagerPublicKeyId");
    AWSKeyPair result = (AWSKeyPair) KeyDataUtil.unmarshal(keyData, keyEncryptor);
    assertThat(result).isNotNull();
    assertThat(result.getPrivateKeyId()).isEqualTo("AwsSecretsManagerPrivateKeyId");
    assertThat(result.getPublicKeyId()).isEqualTo("AwsSecretsManagerPublicKeyId");
    verifyZeroInteractions(keyEncryptor);
}
Also used : KeyEncryptor(com.quorum.tessera.config.keys.KeyEncryptor) KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 27 with KeyData

use of com.quorum.tessera.config.KeyData in project tessera by ConsenSys.

the class KeyDataUtilTest method unmarshalInlineKeypair.

@Test
public void unmarshalInlineKeypair() {
    KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
    KeyData keyData = new KeyData();
    keyData.setPublicKey("PUBLICKEY");
    KeyDataConfig config = mock(KeyDataConfig.class);
    keyData.setConfig(config);
    InlineKeypair result = (InlineKeypair) KeyDataUtil.unmarshal(keyData, keyEncryptor);
    assertThat(result).isNotNull();
    assertThat(result.getPublicKey()).isEqualTo("PUBLICKEY");
    assertThat(result.getPrivateKeyConfig()).isSameAs(config);
    verifyZeroInteractions(keyEncryptor);
}
Also used : KeyDataConfig(com.quorum.tessera.config.KeyDataConfig) KeyEncryptor(com.quorum.tessera.config.keys.KeyEncryptor) KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 28 with KeyData

use of com.quorum.tessera.config.KeyData in project tessera by ConsenSys.

the class KeyDataUtilTest method unmarshalDirectKeyPair.

@Test
public void unmarshalDirectKeyPair() {
    KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
    KeyData keyData = new KeyData();
    keyData.setPublicKey("PUBLICKEY");
    keyData.setPrivateKey("PRIVATEKEY");
    ConfigKeyPair result = KeyDataUtil.unmarshal(keyData, keyEncryptor);
    assertThat(result).isNotNull().isExactlyInstanceOf(DirectKeyPair.class);
    assertThat(result.getPublicKey()).isEqualTo("PUBLICKEY");
    assertThat(result.getPrivateKey()).isEqualTo("PRIVATEKEY");
    verifyZeroInteractions(keyEncryptor);
}
Also used : KeyEncryptor(com.quorum.tessera.config.keys.KeyEncryptor) KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 29 with KeyData

use of com.quorum.tessera.config.KeyData in project tessera by ConsenSys.

the class KeyDataUtilTest method isAzure.

@Test
public void isAzure() {
    KeyData keyData = new KeyData();
    keyData.setAzureVaultPrivateKeyId("AzureVaultPrivateKeyId");
    keyData.setAzureVaultPublicKeyId("AzureVaultPublicKeyId");
    assertThat(KeyDataUtil.isAzure(keyData)).isTrue();
}
Also used : KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 30 with KeyData

use of com.quorum.tessera.config.KeyData in project tessera by ConsenSys.

the class KeyDataUtilTest method marshalHashicorpVaultKeyPair.

@Test
public void marshalHashicorpVaultKeyPair() {
    HashicorpVaultKeyPair keyPair = new HashicorpVaultKeyPair("HashicorpVaultPublicKeyId", "HashicorpVaultPrivateKeyId", "HashicorpVaultSecretEngineName", "HashicorpVaultSecretName", 1);
    KeyData result = KeyDataUtil.marshal(keyPair);
    assertThat(result.getHashicorpVaultPublicKeyId()).isEqualTo("HashicorpVaultPublicKeyId");
    assertThat(result.getHashicorpVaultPrivateKeyId()).isEqualTo("HashicorpVaultPrivateKeyId");
    assertThat(result.getHashicorpVaultSecretEngineName()).isEqualTo("HashicorpVaultSecretEngineName");
    assertThat(result.getHashicorpVaultSecretName()).isEqualTo("HashicorpVaultSecretName");
    assertThat(result.getHashicorpVaultSecretVersion()).isEqualTo("1");
}
Also used : KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Aggregations

KeyData (com.quorum.tessera.config.KeyData)34 Test (org.junit.Test)32 PrivateKeyData (com.quorum.tessera.config.PrivateKeyData)31 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)10 KeyDataConfig (com.quorum.tessera.config.KeyDataConfig)7 Path (java.nio.file.Path)7 Config (com.quorum.tessera.config.Config)1 KeyConfiguration (com.quorum.tessera.config.KeyConfiguration)1 DirectKeyPair (com.quorum.tessera.config.keypairs.DirectKeyPair)1 FilesystemKeyPair (com.quorum.tessera.config.keypairs.FilesystemKeyPair)1 KeyPair (com.quorum.tessera.encryption.KeyPair)1 ArrayList (java.util.ArrayList)1