mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 04:28:01 +01:00
Be permissive in account-create accept-language
Currently, if we fail to parse a user's accept-language in account creation, creation will fail. While it's a suboptimal experience to get a verify code in the wrong language, it might be better than not being able to sign up at all.
This commit is contained in:
committed by
Jon Chambers
parent
0fdfdabf2a
commit
a45d95905e
@@ -636,8 +636,17 @@ class AccountControllerTest {
|
||||
verify(abusiveHostRules).isBlocked(eq(NICE_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSendCodeVoiceInvalidLocale() throws Exception {
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {false, true})
|
||||
void testSendCodeVoiceInvalidLocale(boolean enrolledInVerifyExperiment) throws Exception {
|
||||
when(verifyExperimentEnrollmentManager.isEnrolled(any(), anyString(), anyList(), anyString()))
|
||||
.thenReturn(enrolledInVerifyExperiment);
|
||||
|
||||
if (enrolledInVerifyExperiment) {
|
||||
when(smsSender.deliverVoxVerificationWithTwilioVerify(anyString(), anyString(), anyList()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of("VerificationSid")));
|
||||
}
|
||||
|
||||
Response response =
|
||||
resources.getJerseyTest()
|
||||
.target(String.format("/v1/accounts/voice/code/%s", SENDER))
|
||||
@@ -647,11 +656,14 @@ class AccountControllerTest {
|
||||
.header("X-Forwarded-For", NICE_HOST)
|
||||
.get();
|
||||
|
||||
assertThat(response.getStatus()).isEqualTo(400);
|
||||
// Should still send a code, just with no accept language
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
|
||||
verify(smsSender, never()).deliverVoxVerification(eq(SENDER), anyString(), any());
|
||||
verify(smsSender, never()).deliverVoxVerificationWithTwilioVerify(eq(SENDER), anyString(), any());
|
||||
verify(abusiveHostRules).isBlocked(eq(NICE_HOST));
|
||||
if (enrolledInVerifyExperiment) {
|
||||
verify(smsSender).deliverVoxVerificationWithTwilioVerify(eq(SENDER), anyString(), eq(Collections.emptyList()));
|
||||
} else {
|
||||
verify(smsSender).deliverVoxVerification(eq(SENDER), anyString(), eq(Collections.emptyList()));
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
Reference in New Issue
Block a user