private static Optional<TimeLockClientConfig> addFallbackSslConfigurationToTimeLockClientConfig( Optional<TimeLockClientConfig> config, Optional<SslConfiguration> sslConfiguration) { //noinspection ConstantConditions - function returns an existing ServerListConfig, maybe with different SSL. return config.map(clientConfig -> ImmutableTimeLockClientConfig.builder() .from(clientConfig) .serversList(addSslConfigurationToServerListFunction(sslConfiguration) .apply(clientConfig.serversList())) .build()); }
@Test public void tmelockClientCannotBeAnEmptyString() { assertThatThrownBy(() -> ImmutableTimeLockClientConfig .builder() .client("") .serversList(SERVERS_LIST) .build()) .isInstanceOf(IllegalArgumentException.class) .satisfies((exception) -> assertThat(exception.getMessage(), containsString("Timelock client string cannot be empty"))); }
@Test public void throwsWhenReadingClientWithoutClientSpecified() { TimeLockClientConfig config = ImmutableTimeLockClientConfig.builder() .serversList(SERVERS_LIST) .build(); assertThatThrownBy(config::getClientOrThrow).isInstanceOf(IllegalStateException.class); }
private static AtlasDbConfig convertRuntimeConfigWithTimeLock(AtlasDbConfig installConfig, AtlasDbRuntimeConfig runtimeConfig) { TimeLockRuntimeConfig timeLockRuntimeConfig = runtimeConfig.timelockRuntime().get(); ImmutableTimeLockClientConfig timeLockClientConfig = ImmutableTimeLockClientConfig.builder() .client(installConfig.getNamespaceString()) .serversList(timeLockRuntimeConfig.serversList()) .build(); return ImmutableAtlasDbConfig.builder() .from(installConfig) .timelock(timeLockClientConfig) .build(); }
private static Optional<TimeLockClientConfig> addFallbackSslConfigurationToTimeLockClientConfig( Optional<TimeLockClientConfig> config, Optional<SslConfiguration> sslConfiguration) { //noinspection ConstantConditions - function returns an existing ServerListConfig, maybe with different SSL. return config.map(clientConfig -> ImmutableTimeLockClientConfig.builder() .from(clientConfig) .serversList(addSslConfigurationToServerListFunction(sslConfiguration) .apply(clientConfig.serversList())) .build()); }
@Before public void setUp() { when(invalidator.backupAndInvalidate()).thenReturn(BACKUP_TIMESTAMP); wireMockRule.stubFor(PING_MAPPING.willReturn(aResponse() .withStatus(200) .withBody(TimestampManagementService.PING_RESPONSE) .withHeader("Content-Type", "text/plain")) .inScenario(SCENARIO) .whenScenarioStateIs(Scenario.STARTED) .willSetStateTo(Scenario.STARTED)); String serverUri = String.format("http://%s:%s", WireMockConfiguration.DEFAULT_BIND_ADDRESS, wireMockRule.port()); ServerListConfig defaultServerListConfig = ImmutableServerListConfig.builder().addServers(serverUri).build(); timelockConfig = ImmutableTimeLockClientConfig.builder() .client("testClient") .serversList(defaultServerListConfig) .build(); }
@Test(expected = IllegalStateException.class) public void timelockBlockNotPermittedWithLockAndTimestampBlocks() { ImmutableAtlasDbConfig.builder() .keyValueService(KVS_CONFIG_WITH_NAMESPACE) .timelock(ImmutableTimeLockClientConfig.builder() .client("testClient") .serversList(SINGLETON_SERVER_LIST).build()) .lock(SINGLETON_SERVER_LIST) .timestamp(SINGLETON_SERVER_LIST) .build(); }
private static TimeLockClientConfig getTimelockConfigForServers(List<String> servers) { return ImmutableTimeLockClientConfig.builder() .client(CLIENT) .serversList(ImmutableServerListConfig.builder() .addAllServers(servers) .build()) .build(); } }
private static TimeLockClientConfig getTimelockConfigForServers(List<String> servers) { return ImmutableTimeLockClientConfig.builder() .client(CLIENT) .serversList(ImmutableServerListConfig.builder() .addAllServers(servers) .build()) .build(); }
@Test public void canSpecifyZeroServersIfUsingTimelockBlock() { ImmutableAtlasDbConfig.builder() .keyValueService(KVS_CONFIG_WITHOUT_NAMESPACE) .namespace(CLIENT_NAMESPACE) .timelock(ImmutableTimeLockClientConfig.builder() .serversList(ImmutableServerListConfig.builder().build()) .build()) .build(); } }
@Test public void canCreateWithoutClientSpecified() { ImmutableTimeLockClientConfig.builder() .serversList(SERVERS_LIST) .build(); }