use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class KeyGenFileUpdateOptionsTest method configFileAndPwout.
@Test
public void configFileAndPwout() throws Exception {
Config config = mock(Config.class);
when(converter.convert(anyString())).thenReturn(config);
CommandLine commandLine = new CommandLine(keyGenFileUpdateOptions);
CommandLine.ParseResult result = commandLine.registerConverter(Config.class, converter).parseArgs("--configfile=myfile", "--pwdout=mypwdout");
assertThat(result).isNotNull();
verify(converter).convert("myfile");
assertThat(keyGenFileUpdateOptions.getConfig()).isSameAs(config);
assertThat(keyGenFileUpdateOptions.getPwdOut()).isEqualTo(Paths.get("mypwdout"));
assertThat(keyGenFileUpdateOptions.getConfigOut()).isNull();
assertThat(result.unmatched()).isEmpty();
assertThat(result.matchedArgs()).hasSize(2);
assertThat(result.hasMatchedOption("--configfile")).isTrue();
assertThat(result.hasMatchedOption("--pwdout")).isTrue();
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ConfigurationConverterTest method configReadFromFile.
@Test
public void configReadFromFile() throws Exception {
final Path configFile = Path.of(getClass().getResource("/sample-config.json").toURI());
final Config result = configConverter.convert(configFile.toString());
assertThat(result).isNotNull();
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ServerURIOutputMixinTest method testConfigPathStaysNullWithoutSpecifiedPath.
@Test
public void testConfigPathStaysNullWithoutSpecifiedPath() {
final Config config = new Config();
assertThat(config.getOutputServerURIPath()).isNull();
serverURIOutputMixin.updateConfig(null, config);
assertThat(config.getOutputServerURIPath()).isNull();
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ServerURIOutputMixinTest method testConfigPathIsUpdatedWithSpecifiedPath.
@Test
public void testConfigPathIsUpdatedWithSpecifiedPath() {
final Path testPath = Path.of("/testPath");
final Config config = new Config();
assertThat(config.getOutputServerURIPath()).isNull();
serverURIOutputMixin.updateConfig(testPath, config);
assertThat(config.getOutputServerURIPath()).isEqualTo(testPath);
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class ResidentGroupHandlerImplTest method keyExistedInADifferentGroupInDb.
@Test
public void keyExistedInADifferentGroupInDb() {
ResidentGroup rg1 = new ResidentGroup();
rg1.setMembers(List.of(PublicKey.from("m1".getBytes()).encodeToBase64()));
rg1.setName("rg1");
ResidentGroup rg2 = new ResidentGroup();
rg2.setMembers(List.of(PublicKey.from("m2".getBytes()).encodeToBase64()));
rg2.setName("rg2");
when(privacyGroupManager.getManagedKeys()).thenReturn(Set.of(PublicKey.from("m1".getBytes()), PublicKey.from("m2".getBytes())));
Config config = mock(Config.class);
when(config.getResidentGroups()).thenReturn(List.of(rg1, rg2));
final PrivacyGroup existedGroup = mock(PrivacyGroup.class);
when(existedGroup.getMembers()).thenReturn(List.of(PublicKey.from("m2".getBytes())));
when(existedGroup.getId()).thenReturn(PrivacyGroup.Id.fromBytes("otherGroup".getBytes()));
when(privacyGroupManager.findPrivacyGroupByType(eq(PrivacyGroup.Type.RESIDENT))).thenReturn(List.of(existedGroup));
assertThatThrownBy(() -> residentGroupHandler.onCreate(config)).isInstanceOf(PrivacyViolationException.class).hasMessageContaining("Key cannot belong to more than one resident group");
verify(privacyGroupManager).findPrivacyGroupByType(eq(PrivacyGroup.Type.RESIDENT));
verify(privacyGroupManager).getManagedKeys();
}
Aggregations