Search in sources :

Example 1 with KeyData

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

the class KeyDataUtilTest method getKeyPairTypeForInlineKeyPair.

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

Example 2 with KeyData

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

the class KeyDataUtilTest method unmarshalHashicorpVaultKeyPair.

@Test
public void unmarshalHashicorpVaultKeyPair() {
    KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
    KeyData keyData = new KeyData();
    keyData.setHashicorpVaultPrivateKeyId("HashicorpVaultPrivateKeyId");
    keyData.setHashicorpVaultPublicKeyId("HashicorpVaultPublicKeyId");
    keyData.setHashicorpVaultSecretVersion("99");
    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()).isEqualTo(99);
    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 3 with KeyData

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

the class KeyDataUtilTest method unmarshalUnknownKeyPair.

@Test
public void unmarshalUnknownKeyPair() {
    KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
    KeyData keyData = new KeyData();
    UnsupportedKeyPair result = (UnsupportedKeyPair) KeyDataUtil.unmarshal(keyData, keyEncryptor);
    assertThat(result).isNotNull();
    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 4 with KeyData

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

the class KeyDataUtilTest method getKeyPairTypeForFileSystemKeyPair.

@Test
public void getKeyPairTypeForFileSystemKeyPair() {
    KeyData keyData = new KeyData();
    keyData.setPublicKeyPath(mock(Path.class));
    keyData.setPrivateKeyPath(mock(Path.class));
    Class<? extends ConfigKeyPair> result = KeyDataUtil.getKeyPairTypeFor(keyData);
    assertThat(result).isEqualTo(FilesystemKeyPair.class);
}
Also used : Path(java.nio.file.Path) KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 5 with KeyData

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

the class KeyDataUtilTest method isUnsupported.

@Test
public void isUnsupported() {
    KeyData keyData = new KeyData();
    assertThat(KeyDataUtil.isUnsupported(keyData)).isTrue();
}
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