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");
}
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);
}
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();
}
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);
}
Aggregations