use of com.quorum.tessera.config.KeyDataConfig in project tessera by ConsenSys.
the class InlineKeypairTest method incorrectPasswordGetsCorrectFailureToken.
@Test
public void incorrectPasswordGetsCorrectFailureToken() {
PrivateKeyData privateKeyData = mock(PrivateKeyData.class);
final KeyDataConfig privKeyDataConfig = mock(KeyDataConfig.class);
when(privKeyDataConfig.getPrivateKeyData()).thenReturn(privateKeyData);
when(privKeyDataConfig.getType()).thenReturn(PrivateKeyType.LOCKED);
when(keyEncryptor.decryptPrivateKey(privateKeyData, "wrong-password".toCharArray())).thenThrow(new EncryptorException("WHAT YOU TALKING ABOUT WILLIS"));
final InlineKeypair inlineKeypair = new InlineKeypair("public", privKeyDataConfig, keyEncryptor);
inlineKeypair.withPassword("wrong-password".toCharArray());
String result = inlineKeypair.getPrivateKey();
assertThat(String.valueOf(inlineKeypair.getPassword())).isEqualTo("wrong-password");
assertThat(result).isEqualTo("NACL_FAILURE");
}
use of com.quorum.tessera.config.KeyDataConfig in project tessera by ConsenSys.
the class KeyDataUtilTest method unmarshalAzureVaultKeyPair.
@Test
public void unmarshalAzureVaultKeyPair() {
KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
KeyData keyData = new KeyData();
keyData.setAzureVaultPrivateKeyId("AzureVaultPrivateKeyId");
keyData.setAzureVaultPublicKeyId("AzureVaultPublicKeyId");
KeyDataConfig config = mock(KeyDataConfig.class);
keyData.setConfig(config);
AzureVaultKeyPair result = (AzureVaultKeyPair) KeyDataUtil.unmarshal(keyData, keyEncryptor);
assertThat(result).isNotNull();
assertThat(result.getPrivateKeyId()).isEqualTo("AzureVaultPrivateKeyId");
assertThat(result.getPublicKeyId()).isEqualTo("AzureVaultPublicKeyId");
verifyZeroInteractions(keyEncryptor);
}
use of com.quorum.tessera.config.KeyDataConfig 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);
}
Aggregations