From cd4a4b1dcf9d0de58de64af8d2cf1943efb07659 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Thu, 19 Jan 2023 18:44:59 -0500 Subject: [PATCH] Retire `VoiceVerificationController` --- service/config/sample.yml | 5 - .../WhisperServerConfiguration.java | 10 -- .../textsecuregcm/WhisperServerService.java | 3 - .../VoiceVerificationConfiguration.java | 35 ----- .../VoiceVerificationController.java | 131 ---------------- .../VoiceVerificationControllerTest.java | 143 ------------------ .../fixtures/voice_verification_en_us.xml | 26 ---- .../fixtures/voice_verification_pt_br.xml | 26 ---- .../fixtures/voice_verification_ru.xml | 26 ---- 9 files changed, 405 deletions(-) delete mode 100644 service/src/main/java/org/whispersystems/textsecuregcm/configuration/VoiceVerificationConfiguration.java delete mode 100644 service/src/main/java/org/whispersystems/textsecuregcm/controllers/VoiceVerificationController.java delete mode 100644 service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java delete mode 100644 service/src/test/resources/fixtures/voice_verification_en_us.xml delete mode 100644 service/src/test/resources/fixtures/voice_verification_pt_br.xml delete mode 100644 service/src/test/resources/fixtures/voice_verification_ru.xml diff --git a/service/config/sample.yml b/service/config/sample.yml index c542cb79c..7fb84930c 100644 --- a/service/config/sample.yml +++ b/service/config/sample.yml @@ -229,11 +229,6 @@ unidentifiedDelivery: privateKey: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789AAAAAAA expiresDays: 7 -voiceVerification: - url: https://cdn-ca.signal.org/verification/ - locales: - - en - recaptcha: projectPath: projects/example credentialConfigurationJson: "{ }" # service account configuration for backend authentication diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java index 0fed79779..b784c897a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java @@ -49,7 +49,6 @@ import org.whispersystems.textsecuregcm.configuration.SubscriptionConfiguration; import org.whispersystems.textsecuregcm.configuration.TestDeviceConfiguration; import org.whispersystems.textsecuregcm.configuration.UnidentifiedDeliveryConfiguration; import org.whispersystems.textsecuregcm.configuration.UsernameConfiguration; -import org.whispersystems.textsecuregcm.configuration.VoiceVerificationConfiguration; import org.whispersystems.textsecuregcm.configuration.ZkConfig; import org.whispersystems.websocket.configuration.WebSocketConfiguration; @@ -191,11 +190,6 @@ public class WhisperServerConfiguration extends Configuration { @JsonProperty private UnidentifiedDeliveryConfiguration unidentifiedDelivery; - @Valid - @NotNull - @JsonProperty - private VoiceVerificationConfiguration voiceVerification; - @Valid @NotNull @JsonProperty @@ -303,10 +297,6 @@ public class WhisperServerConfiguration extends Configuration { return hCaptcha; } - public VoiceVerificationConfiguration getVoiceVerificationConfiguration() { - return voiceVerification; - } - public WebSocketConfiguration getWebSocketConfiguration() { return webSocket; } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index 79141fae2..5e50f91fe 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -107,7 +107,6 @@ import org.whispersystems.textsecuregcm.controllers.SecureStorageController; import org.whispersystems.textsecuregcm.controllers.SecureValueRecovery2Controller; import org.whispersystems.textsecuregcm.controllers.StickerController; import org.whispersystems.textsecuregcm.controllers.SubscriptionController; -import org.whispersystems.textsecuregcm.controllers.VoiceVerificationController; import org.whispersystems.textsecuregcm.currency.CoinMarketCapClient; import org.whispersystems.textsecuregcm.currency.CurrencyConversionManager; import org.whispersystems.textsecuregcm.currency.FixerClient; @@ -650,8 +649,6 @@ public class WhisperServerService extends Application webSocketEnvironment = new WebSocketEnvironment<>(environment, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/VoiceVerificationConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/VoiceVerificationConfiguration.java deleted file mode 100644 index d0118135b..000000000 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/VoiceVerificationConfiguration.java +++ /dev/null @@ -1,35 +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 java.util.HashSet; -import java.util.List; -import java.util.Set; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -public class VoiceVerificationConfiguration { - - @JsonProperty - @Valid - @NotEmpty - private String url; - - @JsonProperty - @Valid - @NotNull - private List locales; - - public String getUrl() { - return url; - } - - public Set getLocales() { - return new HashSet<>(locales); - } -} diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/VoiceVerificationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/VoiceVerificationController.java deleted file mode 100644 index c4f73fa25..000000000 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/VoiceVerificationController.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2013-2020 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only - */ - -package org.whispersystems.textsecuregcm.controllers; - -import java.util.Collections; -import java.util.List; -import java.util.Locale.LanguageRange; -import java.util.Set; -import java.util.stream.Collectors; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.whispersystems.textsecuregcm.util.Util; - -@SuppressWarnings("OptionalUsedAsFieldOrParameterType") -@Path("/v1/voice/") -public class VoiceVerificationController { - - private static final String PLAY_TWIML = """ - - - %s - %s - %s - %s - %s - %s - %s - - %s - %s - %s - %s - %s - %s - %s - - %s - %s - %s - %s - %s - %s - %s - - """; - - private static final String DEFAULT_LOCALE = "en-US"; - - - private final String baseUrl; - private final Set supportedLocales; - - public VoiceVerificationController(String baseUrl, Set supportedLocales) { - this.baseUrl = baseUrl; - this.supportedLocales = supportedLocales; - } - - @POST - @Path("/description/{code}") - @Produces(MediaType.APPLICATION_XML) - public Response getDescription(@PathParam("code") String code, @QueryParam("l") List locales) { - code = code.replaceAll("[^0-9]", ""); - - if (code.length() != 6) { - return Response.status(400).build(); - } - - if (locales == null) { - locales = Collections.emptyList(); - } - - final List priorityList; - try { - priorityList = locales.stream() - .map(LanguageRange::new) - .collect(Collectors.toList()); - } catch (final IllegalArgumentException e) { - return Response.status(400).build(); - } - - final String localeMatch = Util.findBestLocale(priorityList, supportedLocales).orElse(DEFAULT_LOCALE); - - return getLocalizedDescription(code, localeMatch); - } - - private Response getLocalizedDescription(String code, String locale) { - String path = constructUrlForLocale(baseUrl, locale); - - return Response.ok() - .entity(String.format(PLAY_TWIML, - path + "verification.mp3", - path + code.charAt(0) + "_middle.mp3", - path + code.charAt(1) + "_middle.mp3", - path + code.charAt(2) + "_middle.mp3", - path + code.charAt(3) + "_middle.mp3", - path + code.charAt(4) + "_middle.mp3", - path + code.charAt(5) + "_falling.mp3", - path + "verification.mp3", - path + code.charAt(0) + "_middle.mp3", - path + code.charAt(1) + "_middle.mp3", - path + code.charAt(2) + "_middle.mp3", - path + code.charAt(3) + "_middle.mp3", - path + code.charAt(4) + "_middle.mp3", - path + code.charAt(5) + "_falling.mp3", - path + "verification.mp3", - path + code.charAt(0) + "_middle.mp3", - path + code.charAt(1) + "_middle.mp3", - path + code.charAt(2) + "_middle.mp3", - path + code.charAt(3) + "_middle.mp3", - path + code.charAt(4) + "_middle.mp3", - path + code.charAt(5) + "_falling.mp3")) - .build(); - } - - private String constructUrlForLocale(String baseUrl, String locale) { - if (!baseUrl.endsWith("/")) { - baseUrl += "/"; - } - - return baseUrl + locale + "/"; - } - -} diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java deleted file mode 100644 index 9ce5ce726..000000000 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2013-2021 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only - */ - -package org.whispersystems.textsecuregcm.tests.controllers; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.common.collect.ImmutableSet; -import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider; -import io.dropwizard.testing.FixtureHelpers; -import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; -import io.dropwizard.testing.junit5.ResourceExtension; -import java.util.Arrays; -import java.util.HashSet; -import javax.ws.rs.core.Response; -import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.whispersystems.textsecuregcm.auth.AuthenticatedAccount; -import org.whispersystems.textsecuregcm.auth.DisabledPermittedAuthenticatedAccount; -import org.whispersystems.textsecuregcm.controllers.VoiceVerificationController; -import org.whispersystems.textsecuregcm.mappers.RateLimitExceededExceptionMapper; -import org.whispersystems.textsecuregcm.tests.util.AuthHelper; -import org.whispersystems.textsecuregcm.util.SystemMapper; - -@ExtendWith(DropwizardExtensionsSupport.class) -class VoiceVerificationControllerTest { - - private static final ResourceExtension resources = ResourceExtension.builder() - .addProvider(AuthHelper.getAuthFilter()) - .addProvider(new PolymorphicAuthValueFactoryProvider.Binder<>( - ImmutableSet.of(AuthenticatedAccount.class, DisabledPermittedAuthenticatedAccount.class))) - .addProvider(new RateLimitExceededExceptionMapper()) - .setMapper(SystemMapper.getMapper()) - .setTestContainerFactory(new GrizzlyWebTestContainerFactory()) - .addResource(new VoiceVerificationController("https://foo.com/bar", - new HashSet<>(Arrays.asList("pt-BR", "ru")))) - .build(); - - @Test - void testTwimlLocale() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/123456") - .queryParam("l", "pt-BR") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.readEntity(String.class)).isXmlEqualTo(FixtureHelpers.fixture("fixtures/voice_verification_pt_br.xml")); - } - - @Test - void testTwimlSplitLocale() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/123456") - .queryParam("l", "ru-RU") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.readEntity(String.class)).isXmlEqualTo(FixtureHelpers.fixture("fixtures/voice_verification_ru.xml")); - } - - @Test - void testTwimlUnsupportedLocale() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/123456") - .queryParam("l", "es-MX") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.readEntity(String.class)).isXmlEqualTo(FixtureHelpers.fixture("fixtures/voice_verification_en_us.xml")); - } - - @Test - void testTwimlMultipleLocales() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/123456") - .queryParam("l", "es-MX") - .queryParam("l", "ru-RU") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.readEntity(String.class)).isXmlEqualTo(FixtureHelpers.fixture("fixtures/voice_verification_ru.xml")); - } - - @Test - void testTwimlMissingLocale() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/123456") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.readEntity(String.class)).isXmlEqualTo(FixtureHelpers.fixture("fixtures/voice_verification_en_us.xml")); - } - - - @Test - void testTwimlMalformedCode() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/1234...56") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.readEntity(String.class)).isXmlEqualTo(FixtureHelpers.fixture("fixtures/voice_verification_en_us.xml")); - } - - @Test - void testTwimlBadCodeLength() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/1234567") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(400); - - } - - @Test - void testTwimlMalformedLocale() { - Response response = - resources.getJerseyTest() - .target("/v1/voice/description/123456") - .queryParam("l", "it IT ,") - .request() - .post(null); - - assertThat(response.getStatus()).isEqualTo(400); - } -} diff --git a/service/src/test/resources/fixtures/voice_verification_en_us.xml b/service/src/test/resources/fixtures/voice_verification_en_us.xml deleted file mode 100644 index 5203a4fad..000000000 --- a/service/src/test/resources/fixtures/voice_verification_en_us.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - https://foo.com/bar/en-US/verification.mp3 - https://foo.com/bar/en-US/1_middle.mp3 - https://foo.com/bar/en-US/2_middle.mp3 - https://foo.com/bar/en-US/3_middle.mp3 - https://foo.com/bar/en-US/4_middle.mp3 - https://foo.com/bar/en-US/5_middle.mp3 - https://foo.com/bar/en-US/6_falling.mp3 - - https://foo.com/bar/en-US/verification.mp3 - https://foo.com/bar/en-US/1_middle.mp3 - https://foo.com/bar/en-US/2_middle.mp3 - https://foo.com/bar/en-US/3_middle.mp3 - https://foo.com/bar/en-US/4_middle.mp3 - https://foo.com/bar/en-US/5_middle.mp3 - https://foo.com/bar/en-US/6_falling.mp3 - - https://foo.com/bar/en-US/verification.mp3 - https://foo.com/bar/en-US/1_middle.mp3 - https://foo.com/bar/en-US/2_middle.mp3 - https://foo.com/bar/en-US/3_middle.mp3 - https://foo.com/bar/en-US/4_middle.mp3 - https://foo.com/bar/en-US/5_middle.mp3 - https://foo.com/bar/en-US/6_falling.mp3 - diff --git a/service/src/test/resources/fixtures/voice_verification_pt_br.xml b/service/src/test/resources/fixtures/voice_verification_pt_br.xml deleted file mode 100644 index fb05662a0..000000000 --- a/service/src/test/resources/fixtures/voice_verification_pt_br.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - https://foo.com/bar/pt-BR/verification.mp3 - https://foo.com/bar/pt-BR/1_middle.mp3 - https://foo.com/bar/pt-BR/2_middle.mp3 - https://foo.com/bar/pt-BR/3_middle.mp3 - https://foo.com/bar/pt-BR/4_middle.mp3 - https://foo.com/bar/pt-BR/5_middle.mp3 - https://foo.com/bar/pt-BR/6_falling.mp3 - - https://foo.com/bar/pt-BR/verification.mp3 - https://foo.com/bar/pt-BR/1_middle.mp3 - https://foo.com/bar/pt-BR/2_middle.mp3 - https://foo.com/bar/pt-BR/3_middle.mp3 - https://foo.com/bar/pt-BR/4_middle.mp3 - https://foo.com/bar/pt-BR/5_middle.mp3 - https://foo.com/bar/pt-BR/6_falling.mp3 - - https://foo.com/bar/pt-BR/verification.mp3 - https://foo.com/bar/pt-BR/1_middle.mp3 - https://foo.com/bar/pt-BR/2_middle.mp3 - https://foo.com/bar/pt-BR/3_middle.mp3 - https://foo.com/bar/pt-BR/4_middle.mp3 - https://foo.com/bar/pt-BR/5_middle.mp3 - https://foo.com/bar/pt-BR/6_falling.mp3 - diff --git a/service/src/test/resources/fixtures/voice_verification_ru.xml b/service/src/test/resources/fixtures/voice_verification_ru.xml deleted file mode 100644 index a204ad34c..000000000 --- a/service/src/test/resources/fixtures/voice_verification_ru.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - https://foo.com/bar/ru/verification.mp3 - https://foo.com/bar/ru/1_middle.mp3 - https://foo.com/bar/ru/2_middle.mp3 - https://foo.com/bar/ru/3_middle.mp3 - https://foo.com/bar/ru/4_middle.mp3 - https://foo.com/bar/ru/5_middle.mp3 - https://foo.com/bar/ru/6_falling.mp3 - - https://foo.com/bar/ru/verification.mp3 - https://foo.com/bar/ru/1_middle.mp3 - https://foo.com/bar/ru/2_middle.mp3 - https://foo.com/bar/ru/3_middle.mp3 - https://foo.com/bar/ru/4_middle.mp3 - https://foo.com/bar/ru/5_middle.mp3 - https://foo.com/bar/ru/6_falling.mp3 - - https://foo.com/bar/ru/verification.mp3 - https://foo.com/bar/ru/1_middle.mp3 - https://foo.com/bar/ru/2_middle.mp3 - https://foo.com/bar/ru/3_middle.mp3 - https://foo.com/bar/ru/4_middle.mp3 - https://foo.com/bar/ru/5_middle.mp3 - https://foo.com/bar/ru/6_falling.mp3 -