use of com.quorum.tessera.config.KeyDataConfig 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);
}
use of com.quorum.tessera.config.KeyDataConfig in project tessera by ConsenSys.
the class KeyDataUtilTest method isLocked.
@Test
public void isLocked() {
KeyData keyData = new KeyData();
keyData.setPublicKey("PUBLIC_KEY");
KeyDataConfig keyDataConfig = new KeyDataConfig(mock(PrivateKeyData.class), PrivateKeyType.LOCKED);
keyData.setConfig(keyDataConfig);
assertThat(KeyDataUtil.isLocked(keyData)).isTrue();
keyData.setConfig(null);
assertThat(KeyDataUtil.isLocked(keyData)).isFalse();
keyData.setConfig(new KeyDataConfig());
assertThat(KeyDataUtil.isLocked(keyData)).isFalse();
}
use of com.quorum.tessera.config.KeyDataConfig in project tessera by ConsenSys.
the class KeyDataUtilTest method marshalInlineKeypair.
@Test
public void marshalInlineKeypair() {
KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
KeyDataConfig keyDataConfig = mock(KeyDataConfig.class);
InlineKeypair keyPair = new InlineKeypair("PUBLIC_KEY", keyDataConfig, keyEncryptor);
KeyData result = KeyDataUtil.marshal(keyPair);
assertThat(result.getPublicKey()).isEqualTo("PUBLIC_KEY");
assertThat(result.getConfig()).isSameAs(keyDataConfig);
}
use of com.quorum.tessera.config.KeyDataConfig in project tessera by ConsenSys.
the class UnsupportedKeyPairValidatorTest method directViolationIsDefaultIfNoDirectPublicEvenIfMultipleIncompleteKeyPairTypesProvided.
@Test
public void directViolationIsDefaultIfNoDirectPublicEvenIfMultipleIncompleteKeyPairTypesProvided() {
KeyDataConfig keyDataConfig = mock(KeyDataConfig.class);
Path path = mock(Path.class);
keyPair.setPrivateKey("private");
keyPair.setConfig(keyDataConfig);
keyPair.setPrivateKeyPath(path);
keyPair.setAzureVaultPrivateKeyId("privAzure");
keyPair.setHashicorpVaultPrivateKeyId("privHashicorp");
keyPair.setAwsSecretsManagerPrivateKeyId(("privAWS"));
validator.isValid(keyPair, context);
verify(context).buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothDirectKeysRequired.message}");
}
use of com.quorum.tessera.config.KeyDataConfig in project tessera by ConsenSys.
the class UnsupportedKeyPairValidatorTest method inlineViolationIfNoPublicEvenIfVaultAndFilesystemAreIncomplete.
@Test
public void inlineViolationIfNoPublicEvenIfVaultAndFilesystemAreIncomplete() {
KeyDataConfig keyDataConfig = mock(KeyDataConfig.class);
Path path = mock(Path.class);
keyPair.setConfig(keyDataConfig);
keyPair.setPublicKeyPath(path);
keyPair.setAzureVaultPublicKeyId("pubId");
keyPair.setHashicorpVaultPublicKeyId("pubId");
keyPair.setAwsSecretsManagerPublicKeyId("pubId");
validator.isValid(keyPair, context);
verify(context).buildConstraintViolationWithTemplate("{UnsupportedKeyPair.bothInlineKeysRequired.message}");
}
Aggregations