use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class KeyGenFileUpdateOptionsTest method configFileAndConfigoutAndPwout.
@Test
public void configFileAndConfigoutAndPwout() 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", "--configout=myconfigout", "--pwdout=mypwdout");
assertThat(result).isNotNull();
verify(converter).convert("myfile");
assertThat(keyGenFileUpdateOptions.getConfig()).isSameAs(config);
assertThat(keyGenFileUpdateOptions.getConfigOut()).isEqualTo(Paths.get("myconfigout"));
assertThat(keyGenFileUpdateOptions.getPwdOut()).isEqualTo(Paths.get("mypwdout"));
assertThat(result.unmatched()).isEmpty();
assertThat(result.matchedArgs()).hasSize(3);
assertThat(result.hasMatchedOption("--configfile")).isTrue();
assertThat(result.hasMatchedOption("--configout")).isTrue();
assertThat(result.hasMatchedOption("--pwdout")).isTrue();
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class CliResultTest method getConfig.
@Test
public void getConfig() {
Config config = new Config();
CliResult result = new CliResult(1, false, config);
assertThat(result.getConfig()).isNotEmpty();
assertThat(result.getConfig().get()).isEqualTo(config);
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class MigrationTest method beforeTest.
@Before
public void beforeTest() throws IOException {
Config primaryConfig = new Config();
primaryConfig.setJdbcConfig(new JdbcConfig());
primaryConfig.getJdbcConfig().setUsername("junit");
primaryConfig.getJdbcConfig().setPassword("junit");
String primaryJdbcUrl = "jdbc:h2:" + workDir.getRoot().toPath().resolve("primary.db").toString();
primaryConfig.getJdbcConfig().setUrl(primaryJdbcUrl);
Config secondaryConfig = new Config();
secondaryConfig.setJdbcConfig(new JdbcConfig());
secondaryConfig.getJdbcConfig().setUsername("junit");
secondaryConfig.getJdbcConfig().setPassword("junit");
String secondaryJdbcUrl = "jdbc:h2:" + workDir.getRoot().toPath().resolve("secondary.db").toString();
secondaryConfig.getJdbcConfig().setUrl(secondaryJdbcUrl);
primaryConfigPath = workDir.getRoot().toPath().toAbsolutePath().resolve("primary-confg.json");
try (OutputStream outputStream = Files.newOutputStream(primaryConfigPath)) {
JaxbUtil.marshalWithNoValidation(primaryConfig, outputStream);
}
secondaryConfigPath = workDir.getRoot().toPath().toAbsolutePath().resolve("secondary-confg.json");
try (OutputStream outputStream = Files.newOutputStream(secondaryConfigPath)) {
JaxbUtil.marshalWithNoValidation(secondaryConfig, outputStream);
}
args = List.of("--primary", primaryConfigPath.toString(), "--secondary", secondaryConfigPath.toString());
primaryEntityManagerFactory = Optional.of(primaryConfig).map(Config::getJdbcConfig).map(JdbcConfigUtil::toMap).map(m -> new HashMap(m)).map(p -> {
p.put("jakarta.persistence.schema-generation.database.action", "drop-and-create");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("tessera", p);
emf.createEntityManager();
return emf;
}).get();
secondaryEntityManagerFactory = Optional.of(secondaryConfig).map(Config::getJdbcConfig).map(JdbcConfigUtil::toMap).map(m -> new HashMap(m)).map(p -> {
p.put("jakarta.persistence.schema-generation.database.action", "create");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("tessera", p);
return emf;
}).get();
EntityManager secondaryEntityManager = secondaryEntityManagerFactory.createEntityManager();
secondaryEntityManager.getTransaction().begin();
IntStream.range(0, encryptedTransactionCount).forEach(i -> {
EncryptedTransaction encryptedTransaction = generateEncryptedTransaction();
secondaryEntityManager.persist(encryptedTransaction);
});
secondaryEntityManager.getTransaction().commit();
secondaryEntityManager.getTransaction().begin();
IntStream.range(0, encryptedRawTransactionCount).forEach(i -> {
EncryptedRawTransaction encryptedRawTransaction = generateEncryptedRawTransaction();
secondaryEntityManager.persist(encryptedRawTransaction);
});
secondaryEntityManager.getTransaction().commit();
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class AzureKeyVaultServiceFactory method create.
@Override
public KeyVaultService create(Config config, EnvironmentVariableProvider envProvider) {
Objects.requireNonNull(config);
final KeyVaultConfig keyVaultConfig = Optional.ofNullable(config.getKeys()).flatMap(k -> k.getKeyVaultConfig(KeyVaultType.AZURE)).orElseThrow(() -> new ConfigException(new RuntimeException("Trying to create Azure key vault connection but no Azure configuration provided")));
final String url = keyVaultConfig.getProperty("url").orElseThrow(() -> new ConfigException(new RuntimeException("No Azure Key Vault url provided")));
final SecretClient secretClient = new SecretClientBuilder().vaultUrl(url).httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)).credential(new DefaultAzureCredentialBuilder().build()).buildClient();
return new AzureKeyVaultService(secretClient);
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class P2pClientProvider method provider.
public static P2pClient provider() {
Config config = ConfigFactory.create().getConfig();
SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
Client client = clientFactory.buildFrom(config.getP2PServerConfig());
return new RestP2pClient(client);
}
Aggregations