Search in sources :

Example 1 with KeyDataConfig

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);
}
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 KeyDataConfig

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();
}
Also used : KeyDataConfig(com.quorum.tessera.config.KeyDataConfig) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 3 with KeyDataConfig

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);
}
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 4 with 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}");
}
Also used : Path(java.nio.file.Path) KeyDataConfig(com.quorum.tessera.config.KeyDataConfig) Test(org.junit.Test)

Example 5 with KeyDataConfig

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}");
}
Also used : Path(java.nio.file.Path) KeyDataConfig(com.quorum.tessera.config.KeyDataConfig) Test(org.junit.Test)

Aggregations

KeyDataConfig (com.quorum.tessera.config.KeyDataConfig)18 Test (org.junit.Test)17 PrivateKeyData (com.quorum.tessera.config.PrivateKeyData)13 Path (java.nio.file.Path)7 KeyData (com.quorum.tessera.config.KeyData)6 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)3 PrivateKey (com.quorum.tessera.encryption.PrivateKey)3 FilesystemKeyPair (com.quorum.tessera.config.keypairs.FilesystemKeyPair)2 EncryptorException (com.quorum.tessera.encryption.EncryptorException)2 CliResult (com.quorum.tessera.cli.CliResult)1 ArgonOptions (com.quorum.tessera.config.ArgonOptions)1 KeyPair (com.quorum.tessera.encryption.KeyPair)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1