diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java index 6e465fd5e..b70c747ca 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java @@ -7,9 +7,11 @@ package org.whispersystems.textsecuregcm; import com.fasterxml.jackson.annotation.JsonProperty; import io.dropwizard.Configuration; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import javax.validation.Valid; import javax.validation.constraints.NotNull; import org.whispersystems.textsecuregcm.configuration.AccountDatabaseCrawlerConfiguration; @@ -45,7 +47,6 @@ import org.whispersystems.textsecuregcm.configuration.SecureValueRecovery2Config import org.whispersystems.textsecuregcm.configuration.SpamFilterConfiguration; import org.whispersystems.textsecuregcm.configuration.StripeConfiguration; import org.whispersystems.textsecuregcm.configuration.SubscriptionConfiguration; -import org.whispersystems.textsecuregcm.configuration.TestDeviceConfiguration; import org.whispersystems.textsecuregcm.configuration.UnidentifiedDeliveryConfiguration; import org.whispersystems.textsecuregcm.configuration.ZkConfig; import org.whispersystems.textsecuregcm.limits.RateLimiterConfig; @@ -152,7 +153,7 @@ public class WhisperServerConfiguration extends Configuration { @Valid @NotNull @JsonProperty - private List testDevices = new LinkedList<>(); + private Set testDevices = new HashSet<>(); @Valid @NotNull @@ -371,15 +372,8 @@ public class WhisperServerConfiguration extends Configuration { return unidentifiedDelivery; } - public Map getTestDevices() { - Map results = new HashMap<>(); - - for (TestDeviceConfiguration testDeviceConfiguration : testDevices) { - results.put(testDeviceConfiguration.getNumber(), - testDeviceConfiguration.getCode()); - } - - return results; + public Set getTestDevices() { + return testDevices; } public Map getMaxDevices() { diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/captcha/RegistrationCaptchaManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/captcha/RegistrationCaptchaManager.java index 044c70048..471fb66fa 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/captcha/RegistrationCaptchaManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/captcha/RegistrationCaptchaManager.java @@ -11,8 +11,9 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.SharedMetricRegistries; import java.io.IOException; -import java.util.Map; import java.util.Optional; +import java.util.Set; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicCaptchaConfiguration; @@ -37,12 +38,12 @@ public class RegistrationCaptchaManager { private final CaptchaChecker captchaChecker; private final RateLimiters rateLimiters; - private final Map testDevices; + private final Set testDevices; private final DynamicConfigurationManager dynamicConfigurationManager; public RegistrationCaptchaManager(final CaptchaChecker captchaChecker, final RateLimiters rateLimiters, - final Map testDevices, + final Set testDevices, final DynamicConfigurationManager dynamicConfigurationManager) { this.captchaChecker = captchaChecker; this.rateLimiters = rateLimiters; @@ -60,7 +61,7 @@ public class RegistrationCaptchaManager { public boolean requiresCaptcha(final String number, final String forwardedFor, String sourceHost, final boolean pushChallengeMatch) { - if (testDevices.containsKey(number)) { + if (testDevices.contains(number)) { return false; } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/TestDeviceConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/TestDeviceConfiguration.java deleted file mode 100644 index 82b2fbf35..000000000 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/TestDeviceConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013-2020 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only - */ - -package org.whispersystems.textsecuregcm.configuration; - -import com.fasterxml.jackson.annotation.JsonProperty; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -public class TestDeviceConfiguration { - - @JsonProperty - @NotEmpty - private String number; - - @JsonProperty - @NotNull - private int code; - - public String getNumber() { - return number; - } - - public int getCode() { - return code; - } -} diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java index 32267e238..a36476f7f 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java @@ -221,7 +221,7 @@ class AccountControllerTest { accountsManager, clientPresenceManager, svr1CredentialsGenerator, svr2CredentialsGenerator, registrationRecoveryPasswordsManager, pushNotificationManager, rateLimiters); private static final RegistrationCaptchaManager registrationCaptchaManager = new RegistrationCaptchaManager( - captchaChecker, rateLimiters, Map.of(TEST_NUMBER, 123456), dynamicConfigurationManager); + captchaChecker, rateLimiters, Set.of(TEST_NUMBER), dynamicConfigurationManager); private static final ResourceExtension resources = ResourceExtension.builder() .addProvider(AuthHelper.getAuthFilter())