fixing config field names

This commit is contained in:
Sergey Skrobotov 2023-01-25 16:17:28 -08:00
parent b8d922fcb7
commit c934405a3e
3 changed files with 16 additions and 13 deletions

View File

@ -5,8 +5,6 @@
package org.whispersystems.textsecuregcm.configuration; package org.whispersystems.textsecuregcm.configuration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
import java.util.List; import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@ -17,15 +15,16 @@ import org.apache.commons.codec.binary.Hex;
public record SecureStorageServiceConfiguration(@NotEmpty String userAuthenticationTokenSharedSecret, public record SecureStorageServiceConfiguration(@NotEmpty String userAuthenticationTokenSharedSecret,
@NotBlank String uri, @NotBlank String uri,
@NotEmpty List<@NotBlank String> storageCaCertificates, @NotEmpty List<@NotBlank String> storageCaCertificates,
@Valid @JsonProperty("circuitBreaker") CircuitBreakerConfiguration circuitBreakerConfig, @Valid CircuitBreakerConfiguration circuitBreaker,
@Valid @JsonProperty("retry") RetryConfiguration retryConfig) { @Valid RetryConfiguration retry) {
@VisibleForTesting public SecureStorageServiceConfiguration {
public SecureStorageServiceConfiguration( if (circuitBreaker == null) {
final @NotEmpty String userAuthenticationTokenSharedSecret, circuitBreaker = new CircuitBreakerConfiguration();
final @NotBlank String uri, }
final @NotEmpty List<@NotBlank String> storageCaCertificates) { if (retry == null) {
this(userAuthenticationTokenSharedSecret, uri, storageCaCertificates, new CircuitBreakerConfiguration(), new RetryConfiguration()); retry = new RetryConfiguration();
}
} }
public byte[] decodeUserAuthenticationTokenSharedSecret() throws DecoderException { public byte[] decodeUserAuthenticationTokenSharedSecret() throws DecoderException {

View File

@ -40,8 +40,8 @@ public class SecureStorageClient {
this.storageServiceCredentialsGenerator = storageServiceCredentialsGenerator; this.storageServiceCredentialsGenerator = storageServiceCredentialsGenerator;
this.deleteUri = URI.create(configuration.uri()).resolve(DELETE_PATH); this.deleteUri = URI.create(configuration.uri()).resolve(DELETE_PATH);
this.httpClient = FaultTolerantHttpClient.newBuilder() this.httpClient = FaultTolerantHttpClient.newBuilder()
.withCircuitBreaker(configuration.circuitBreakerConfig()) .withCircuitBreaker(configuration.circuitBreaker())
.withRetry(configuration.retryConfig()) .withRetry(configuration.retry())
.withVersion(HttpClient.Version.HTTP_1_1) .withVersion(HttpClient.Version.HTTP_1_1)
.withConnectTimeout(Duration.ofSeconds(10)) .withConnectTimeout(Duration.ofSeconds(10))
.withRedirect(HttpClient.Redirect.NEVER) .withRedirect(HttpClient.Redirect.NEVER)

View File

@ -29,6 +29,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.extension.RegisterExtension;
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentials; import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentials;
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialsGenerator; import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialsGenerator;
import org.whispersystems.textsecuregcm.configuration.CircuitBreakerConfiguration;
import org.whispersystems.textsecuregcm.configuration.RetryConfiguration;
import org.whispersystems.textsecuregcm.configuration.SecureStorageServiceConfiguration; import org.whispersystems.textsecuregcm.configuration.SecureStorageServiceConfiguration;
class SecureStorageClientTest { class SecureStorageClientTest {
@ -98,7 +100,9 @@ class SecureStorageClientTest {
WIOjZOKGW690ESKCKOnFjUHVO0HpuWnT81URTuY62FXsYdVc2wE4v0E04mEbqQ0P WIOjZOKGW690ESKCKOnFjUHVO0HpuWnT81URTuY62FXsYdVc2wE4v0E04mEbqQ0P
lY6ZKNA81Lm3YADYtObmK1IUrOPo9BeIaPy0UM08SmN880Vunqa91Q== lY6ZKNA81Lm3YADYtObmK1IUrOPo9BeIaPy0UM08SmN880Vunqa91Q==
-----END CERTIFICATE----- -----END CERTIFICATE-----
""")); """),
new CircuitBreakerConfiguration(),
new RetryConfiguration());
secureStorageClient = new SecureStorageClient(credentialsGenerator, httpExecutor, config); secureStorageClient = new SecureStorageClient(credentialsGenerator, httpExecutor, config);
} }