use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class PasswordFileUpdaterWriterTest method newPasswordsAppendedToExistingPasswordsAndWrittenToFile.
@Test
public void newPasswordsAppendedToExistingPasswordsAndWrittenToFile() throws Exception {
final Config config = mock(Config.class);
final KeyConfiguration keyConfiguration = mock(KeyConfiguration.class);
final Path existingPwdFile = mock(Path.class);
when(config.getKeys()).thenReturn(keyConfiguration);
when(keyConfiguration.getPasswordFile()).thenReturn(existingPwdFile);
final Path pwdFile = mock(Path.class);
final String path = "somepath";
when(pwdFile.toString()).thenReturn(path);
final List<String> existingPasswords = new ArrayList<>(Arrays.asList("pwd1", "pwd2"));
final List<String> existingAndNewPasswords = new ArrayList<>(Arrays.asList("pwd1", "pwd2", "pwd3", "pwd4"));
final List<char[]> newPasswords = new ArrayList<>(Arrays.asList("pwd3".toCharArray(), "pwd4".toCharArray()));
when(filesDelegate.readAllLines(any())).thenReturn(existingPasswords);
writer.updateAndWrite(newPasswords, config, pwdFile);
verify(filesDelegate).readAllLines(existingPwdFile);
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);
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method isValidWhenServerConfigsIsNull.
@Test
public void isValidWhenServerConfigsIsNull() {
Config config = new Config();
config.setServerConfigs(null);
assertThat(validator.isValid(config, cvc)).isTrue();
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method isNotValidWhenNoQ2TServersAreDefined.
@Test
public void isNotValidWhenNoQ2TServersAreDefined() {
List<ServerConfig> serverConfigList = serverConfigList().stream().filter(s -> s.getApp() != AppType.Q2T).collect(Collectors.toList());
Config config = new Config();
config.setServerConfigs(serverConfigList);
assertThat(validator.isValid(config, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("At least one Q2T server must be configured or bootstrap mode enabled."));
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method isNotValidWhenQ2TServersAreDefinedOnBootstrapNode.
@Test
public void isNotValidWhenQ2TServersAreDefinedOnBootstrapNode() {
List<ServerConfig> serverConfigList = serverConfigList();
Config config = new Config();
config.setBootstrapNode(true);
config.setServerConfigs(serverConfigList);
assertThat(validator.isValid(config, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("Q2T server cannot be specified on a bootstrap node."));
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method isValidWhenValidDataIsSupplied.
@Test
public void isValidWhenValidDataIsSupplied() {
List<ServerConfig> serverConfigList = serverConfigList();
Config config = new Config();
config.setServerConfigs(serverConfigList);
assertThat(validator.isValid(config, cvc)).isTrue();
}
Aggregations