use of com.quorum.tessera.config.KeyConfiguration in project tessera by ConsenSys.
the class KeyConfigurationValidatorTest method fileSetIsValid.
@Test
public void fileSetIsValid() {
final KeyConfiguration configuration = new KeyConfiguration(Paths.get("anything"), null, null, null, null);
assertThat(validator.isValid(configuration, mock(ConstraintValidatorContext.class))).isTrue();
}
use of com.quorum.tessera.config.KeyConfiguration in project tessera by ConsenSys.
the class KeyConfigurationValidatorTest method bothSetIsInvalid.
@Test
public void bothSetIsInvalid() {
final KeyConfiguration configuration = new KeyConfiguration(Paths.get("anything"), emptyList(), null, null, null);
assertThat(validator.isValid(configuration, mock(ConstraintValidatorContext.class))).isFalse();
}
use of com.quorum.tessera.config.KeyConfiguration in project tessera by ConsenSys.
the class PasswordFileUpdaterWriterTest method configContainsPasswordListThrowsException.
@Test
public void configContainsPasswordListThrowsException() {
final Config config = mock(Config.class);
final KeyConfiguration keyConfiguration = mock(KeyConfiguration.class);
when(config.getKeys()).thenReturn(keyConfiguration);
when(keyConfiguration.getPasswords()).thenReturn(Collections.singletonList("pwd"));
final Throwable ex = catchThrowable(() -> writer.updateAndWrite(null, config, null));
assertThat(ex).isExactlyInstanceOf(ConfigException.class);
assertThat(ex.getMessage()).contains("Configfile must contain \"passwordFile\" field. The \"passwords\" field is no longer supported.");
}
use of com.quorum.tessera.config.KeyConfiguration 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