Search in sources :

Example 31 with KeyData

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

the class KeyDataUtilTest method marshalAWSKeyPair.

@Test
public void marshalAWSKeyPair() {
    AWSKeyPair configKeyPair = new AWSKeyPair("PUBLIC_KEY_ID", "PRIVATE_KEY_ID");
    KeyData result = KeyDataUtil.marshal(configKeyPair);
    assertThat(result.getAwsSecretsManagerPublicKeyId()).isEqualTo("PUBLIC_KEY_ID");
    assertThat(result.getAwsSecretsManagerPrivateKeyId()).isEqualTo("PRIVATE_KEY_ID");
}
Also used : KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 32 with KeyData

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

the class KeyDataUtilTest method marshalFilesystemKeyPair.

@Test
public void marshalFilesystemKeyPair() {
    KeyEncryptor keyEncryptor = mock(KeyEncryptor.class);
    Path pubicKeyPath = mock(Path.class);
    Path privateKeyPath = mock(Path.class);
    FilesystemKeyPair keyPair = new FilesystemKeyPair(pubicKeyPath, privateKeyPath, keyEncryptor);
    KeyData result = KeyDataUtil.marshal(keyPair);
    assertThat(result.getPublicKeyPath()).isSameAs(pubicKeyPath);
    assertThat(result.getPrivateKeyPath()).isSameAs(privateKeyPath);
}
Also used : Path(java.nio.file.Path) KeyEncryptor(com.quorum.tessera.config.keys.KeyEncryptor) KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 33 with KeyData

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

the class KeyDataUtilTest method marshalUnsupportedKeyPair.

@Test
public void marshalUnsupportedKeyPair() {
    UnsupportedKeyPair keyPair = new UnsupportedKeyPair();
    KeyData result = KeyDataUtil.marshal(keyPair);
    assertThat(result).isNotNull();
}
Also used : KeyData(com.quorum.tessera.config.KeyData) PrivateKeyData(com.quorum.tessera.config.PrivateKeyData) Test(org.junit.Test)

Example 34 with KeyData

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

the class PasswordFileUpdaterWriterTest method newPasswordsWrittenToNewFileIncludingEmptyLinesForExistingKeys.

@Test
public void newPasswordsWrittenToNewFileIncludingEmptyLinesForExistingKeys() throws Exception {
    final Config config = mock(Config.class);
    final KeyConfiguration keyConfiguration = mock(KeyConfiguration.class);
    final List<KeyData> existingKeys = Arrays.asList(mock(KeyData.class), mock(KeyData.class));
    when(config.getKeys()).thenReturn(keyConfiguration);
    when(keyConfiguration.getKeyData()).thenReturn(existingKeys);
    final Path pwdFile = mock(Path.class);
    final String path = "somepath";
    when(pwdFile.toString()).thenReturn(path);
    final List<String> existingAndNewPasswords = new ArrayList<>(Arrays.asList("", "", "pwd1", "pwd2"));
    final List<char[]> newPasswords = new ArrayList<>(Arrays.asList("pwd1".toCharArray(), "pwd2".toCharArray()));
    writer.updateAndWrite(newPasswords, config, pwdFile);
    verify(filesDelegate).exists(pwdFile);
    verify(filesDelegate).createFile(pwdFile);
    verify(filesDelegate).setPosixFilePermissions(pwdFile, Stream.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE).collect(Collectors.toSet()));
    verify(filesDelegate).write(pwdFile, existingAndNewPasswords, APPEND);
}
Also used : Path(java.nio.file.Path) KeyConfiguration(com.quorum.tessera.config.KeyConfiguration) Config(com.quorum.tessera.config.Config) ArrayList(java.util.ArrayList) KeyData(com.quorum.tessera.config.KeyData) 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