Search in sources :

Example 26 with Config

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();
}
Also used : CommandLine(picocli.CommandLine) Config(com.quorum.tessera.config.Config) Test(org.junit.Test)

Example 27 with Config

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();
}
Also used : Path(java.nio.file.Path) Config(com.quorum.tessera.config.Config) Test(org.junit.Test)

Example 28 with Config

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();
}
Also used : Config(com.quorum.tessera.config.Config) Test(org.junit.Test)

Example 29 with Config

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);
}
Also used : Path(java.nio.file.Path) Config(com.quorum.tessera.config.Config) Test(org.junit.Test)

Example 30 with Config

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();
}
Also used : ResidentGroup(com.quorum.tessera.config.ResidentGroup) Config(com.quorum.tessera.config.Config) PrivacyViolationException(com.quorum.tessera.transaction.exception.PrivacyViolationException) PrivacyGroup(com.quorum.tessera.enclave.PrivacyGroup) Test(org.junit.Test)

Aggregations

Config (com.quorum.tessera.config.Config)78 Test (org.junit.Test)54 ServerConfig (com.quorum.tessera.config.ServerConfig)20 ConfigFactory (com.quorum.tessera.config.ConfigFactory)18 Path (java.nio.file.Path)11 Before (org.junit.Before)11 ResidentGroup (com.quorum.tessera.config.ResidentGroup)9 ClientFactory (com.quorum.tessera.jaxrs.client.ClientFactory)9 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)9 Client (jakarta.ws.rs.client.Client)9 JdbcConfig (com.quorum.tessera.config.JdbcConfig)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 After (org.junit.After)7 CommandLine (picocli.CommandLine)7 PrivacyViolationException (com.quorum.tessera.transaction.exception.PrivacyViolationException)6 CliResult (com.quorum.tessera.cli.CliResult)5 EncryptorConfig (com.quorum.tessera.config.EncryptorConfig)5 PublicKey (com.quorum.tessera.encryption.PublicKey)5