Search in sources :

Example 6 with KeyData

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

the class KeyDataUtilTest method getKeyPairTypeForDirectKeyPair.

@Test
public void getKeyPairTypeForDirectKeyPair() {
    KeyData keyData = new KeyData();
    keyData.setPrivateKey("PRIVATE_KEY");
    keyData.setPublicKey("PUBLIC_KEY");
    Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData);
    assertThat(result).isEqualTo(DirectKeyPair.class);
}
Also used : KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 7 with KeyData

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

the class KeyDataUtilTest method isDirect.

@Test
public void isDirect() {
    KeyData keyData = new KeyData();
    keyData.setPublicKey("PUBLICKEY");
    keyData.setPrivateKey("PRIVATEKEY");
    assertThat(KeyDataUtil.isDirect(keyData)).isTrue();
}
Also used : KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 8 with KeyData

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

the class KeyDataUtilTest method unmarshalHashicorpVaultKeyPairNoSecretVersionDefined.

@Test
public void unmarshalHashicorpVaultKeyPairNoSecretVersionDefined() {
    KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
    KeyData keyData = new KeyData();
    keyData.setHashicorpVaultPrivateKeyId("HashicorpVaultPrivateKeyId");
    keyData.setHashicorpVaultPublicKeyId("HashicorpVaultPublicKeyId");
    keyData.setHashicorpVaultSecretName("HashicorpSecretName");
    keyData.setHashicorpVaultSecretEngineName("HashicorpVaultSecretEngineName");
    HashicorpVaultKeyPair result = (HashicorpVaultKeyPair) KeyDataUtil.unmarshal(keyData, keyEncryptor);
    assertThat(result).isNotNull();
    assertThat(result.getPrivateKeyId()).isEqualTo("HashicorpVaultPrivateKeyId");
    assertThat(result.getPublicKeyId()).isEqualTo("HashicorpVaultPublicKeyId");
    assertThat(result.getSecretVersion()).isZero();
    assertThat(result.getSecretEngineName()).isEqualTo("HashicorpVaultSecretEngineName");
    assertThat(result.getSecretName()).isEqualTo("HashicorpSecretName");
    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 9 with KeyData

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

the class KeyDataUtilTest method getKeyPairTypeForAzureVaultKeyPair.

@Test
public void getKeyPairTypeForAzureVaultKeyPair() {
    KeyData keyData = new KeyData();
    keyData.setAzureVaultPublicKeyId("AZURE_PUBLIC_ID");
    keyData.setAzureVaultPrivateKeyId("AZURE_PRIVATE_ID");
    Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData);
    assertThat(result).isEqualTo(AzureVaultKeyPair.class);
}
Also used : KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 10 with KeyData

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

the class KeyDataUtilTest method marshalAzureVaultKeyPair.

@Test
public void marshalAzureVaultKeyPair() {
    AzureVaultKeyPair configKeyPair = new AzureVaultKeyPair("PUBLIC_KEY_ID", "PRIVATE_KEY_ID", "PUBLIC_KEY_VERSION", "PRIVATE_KEY_VERSION");
    KeyData result = KeyDataUtil.marshal(configKeyPair);
    assertThat(result.getAzureVaultPrivateKeyId()).isEqualTo("PRIVATE_KEY_ID");
    assertThat(result.getAzureVaultPublicKeyId()).isEqualTo("PUBLIC_KEY_ID");
    assertThat(result.getAzureVaultPrivateKeyVersion()).isEqualTo("PRIVATE_KEY_VERSION");
    assertThat(result.getAzureVaultPublicKeyVersion()).isEqualTo("PUBLIC_KEY_VERSION");
}
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