Remove vestiges of per-country sender ID logic/configuration.
This commit is contained in:
parent
fb2fc2335a
commit
efe7f2e4c1
|
@ -14,22 +14,6 @@ twilio: # Twilio gateway configuration
|
|||
androidNgVerificationText: # Text to use for the verification message on android-ng client types. Will be passed to String.format with the verification code as argument 1.
|
||||
android202001VerificationText: # Text to use for the verification message on android-2020-01 client types. Will be passed to String.format with the verification code as argument 1.
|
||||
genericVerificationText: # Text to use when the client type is unrecognized. Will be passed to String.format with the verification code as argument 1.
|
||||
senderId:
|
||||
defaultSenderId: # Sender ID to use for country codes not found in either the overrides or omitted lists.
|
||||
countryCodesWithoutSenderId:
|
||||
- # First country code
|
||||
- # Second country code
|
||||
- # ...
|
||||
- # Nth country code
|
||||
countrySpecificSenderIds:
|
||||
- countryCode: # First country code
|
||||
senderId: # Sender ID to use for this country
|
||||
- countryCode: # Second country code
|
||||
senderId: # Sender ID to use for this country
|
||||
- countryCode: # ...
|
||||
senderId: # ...
|
||||
- countryCode: # Nth country code
|
||||
senderId: # Sender ID to use for this country
|
||||
|
||||
push:
|
||||
queueSize: # Size of push pending queue
|
||||
|
|
|
@ -39,10 +39,6 @@ public class TwilioConfiguration {
|
|||
@Valid
|
||||
private RetryConfiguration retry = new RetryConfiguration();
|
||||
|
||||
@NotNull
|
||||
@Valid
|
||||
private TwilioSenderIdConfiguration senderId = new TwilioSenderIdConfiguration();
|
||||
|
||||
@NotEmpty
|
||||
private String iosVerificationText;
|
||||
|
||||
|
@ -127,15 +123,6 @@ public class TwilioConfiguration {
|
|||
this.retry = retry;
|
||||
}
|
||||
|
||||
public TwilioSenderIdConfiguration getSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setSenderId(TwilioSenderIdConfiguration senderId) {
|
||||
this.senderId = senderId;
|
||||
}
|
||||
|
||||
public String getIosVerificationText() {
|
||||
return iosVerificationText;
|
||||
}
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright 2013-2020 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.configuration;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TwilioSenderIdConfiguration {
|
||||
@NotEmpty
|
||||
private String defaultSenderId;
|
||||
|
||||
@NotNull
|
||||
@Valid
|
||||
private List<TwilioCountrySenderIdConfiguration> countrySpecificSenderIds = new ArrayList<>();
|
||||
|
||||
@NotNull
|
||||
@Valid
|
||||
private Set<String> countryCodesWithoutSenderId = new HashSet<>();
|
||||
|
||||
public String getDefaultSenderId() {
|
||||
return defaultSenderId;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setDefaultSenderId(String defaultSenderId) {
|
||||
this.defaultSenderId = defaultSenderId;
|
||||
}
|
||||
|
||||
public List<TwilioCountrySenderIdConfiguration> getCountrySpecificSenderIds() {
|
||||
return countrySpecificSenderIds;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setCountrySpecificSenderIds(List<TwilioCountrySenderIdConfiguration> countrySpecificSenderIds) {
|
||||
this.countrySpecificSenderIds = countrySpecificSenderIds;
|
||||
}
|
||||
|
||||
public Set<String> getCountryCodesWithoutSenderId() {
|
||||
return countryCodesWithoutSenderId;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setCountryCodesWithoutSenderId(Set<String> countryCodesWithoutSenderId) {
|
||||
this.countryCodesWithoutSenderId = countryCodesWithoutSenderId;
|
||||
}
|
||||
}
|
|
@ -5,23 +5,6 @@
|
|||
|
||||
package org.whispersystems.textsecuregcm.tests.sms;
|
||||
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.textsecuregcm.configuration.TwilioConfiguration;
|
||||
import org.whispersystems.textsecuregcm.configuration.TwilioCountrySenderIdConfiguration;
|
||||
import org.whispersystems.textsecuregcm.configuration.TwilioSenderIdConfiguration;
|
||||
import org.whispersystems.textsecuregcm.sms.TwilioSmsSender;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
|
||||
|
@ -32,6 +15,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.verify;
|
|||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.textsecuregcm.configuration.TwilioConfiguration;
|
||||
import org.whispersystems.textsecuregcm.sms.TwilioSmsSender;
|
||||
|
||||
public class TwilioSmsSenderTest {
|
||||
|
||||
private static final String ACCOUNT_ID = "test_account_id";
|
||||
|
@ -190,67 +182,6 @@ public class TwilioSmsSenderTest {
|
|||
assertThat(success).isFalse();
|
||||
}
|
||||
|
||||
private void runSenderIdTest(String destination,
|
||||
String expectedSenderId,
|
||||
Supplier<TwilioSenderIdConfiguration> senderIdConfigurationSupplier) {
|
||||
setupSuccessStubForSms();
|
||||
|
||||
TwilioConfiguration configuration = createTwilioConfiguration();
|
||||
configuration.setSenderId(senderIdConfigurationSupplier.get());
|
||||
|
||||
TwilioSmsSender sender = new TwilioSmsSender("http://localhost:" + wireMockRule.port(), configuration);
|
||||
boolean success = sender.deliverSmsVerification(destination, Optional.of("android-ng"), "987-654").join();
|
||||
|
||||
assertThat(success).isTrue();
|
||||
|
||||
final String requestBodyToParam = "To=" + URLEncoder.encode(destination, StandardCharsets.UTF_8);
|
||||
final String requestBodySuffix = "&Body=%3C%23%3E+Verify+on+AndroidNg%3A+987-654%0A%0Acharacters";
|
||||
final String expectedRequestBody;
|
||||
if (expectedSenderId != null) {
|
||||
expectedRequestBody = requestBodyToParam + "&From=" + expectedSenderId + requestBodySuffix;
|
||||
} else {
|
||||
expectedRequestBody = "MessagingServiceSid=" + MESSAGING_SERVICE_SID + "&" + requestBodyToParam + requestBodySuffix;
|
||||
}
|
||||
verify(1, postRequestedFor(urlEqualTo("/2010-04-01/Accounts/" + ACCOUNT_ID + "/Messages.json"))
|
||||
.withHeader("Content-Type", equalTo("application/x-www-form-urlencoded"))
|
||||
.withRequestBody(equalTo(expectedRequestBody)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSendAlphaIdByCountryCode() {
|
||||
runSenderIdTest("+85278675309", "SIGNAL", () -> {
|
||||
TwilioSenderIdConfiguration senderIdConfiguration = new TwilioSenderIdConfiguration();
|
||||
TwilioCountrySenderIdConfiguration twilioCountrySenderIdConfiguration = new TwilioCountrySenderIdConfiguration();
|
||||
twilioCountrySenderIdConfiguration.setCountryCode("852");
|
||||
twilioCountrySenderIdConfiguration.setSenderId("SIGNAL");
|
||||
senderIdConfiguration.setCountrySpecificSenderIds(List.of(twilioCountrySenderIdConfiguration));
|
||||
return senderIdConfiguration;
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSenderIdWithAllFieldsPopulated() {
|
||||
final Supplier<TwilioSenderIdConfiguration> senderIdConfigurationSupplier = () -> {
|
||||
TwilioSenderIdConfiguration senderIdConfiguration = new TwilioSenderIdConfiguration();
|
||||
TwilioCountrySenderIdConfiguration twilioCountrySenderIdConfiguration1 = new TwilioCountrySenderIdConfiguration();
|
||||
TwilioCountrySenderIdConfiguration twilioCountrySenderIdConfiguration2 = new TwilioCountrySenderIdConfiguration();
|
||||
twilioCountrySenderIdConfiguration1.setCountryCode("1");
|
||||
twilioCountrySenderIdConfiguration1.setSenderId("KNOWYOUREOUTTHERE");
|
||||
twilioCountrySenderIdConfiguration2.setCountryCode("61");
|
||||
twilioCountrySenderIdConfiguration2.setSenderId("SOMEWHERE");
|
||||
senderIdConfiguration.setDefaultSenderId("SOMEHOW");
|
||||
senderIdConfiguration.setCountrySpecificSenderIds(List.of(twilioCountrySenderIdConfiguration1, twilioCountrySenderIdConfiguration2));
|
||||
senderIdConfiguration.setCountryCodesWithoutSenderId(Set.of("7"));
|
||||
return senderIdConfiguration;
|
||||
};
|
||||
runSenderIdTest("+15128675309", "KNOWYOUREOUTTHERE", senderIdConfigurationSupplier);
|
||||
runSenderIdTest("+610998765432", "SOMEWHERE", senderIdConfigurationSupplier);
|
||||
runSenderIdTest("+74991234567", null, senderIdConfigurationSupplier);
|
||||
runSenderIdTest("+85278675309", "SOMEHOW", senderIdConfigurationSupplier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetrySmsOnUnreachableErrorCodeIsTriedOnlyOnceWithoutSenderId() {
|
||||
wireMockRule.stubFor(post(urlEqualTo("/2010-04-01/Accounts/" + ACCOUNT_ID + "/Messages.json"))
|
||||
|
|
Loading…
Reference in New Issue