mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 16:58:04 +01:00
Update CallRoutingController to use e164, add UUID to e164 experiments
This commit is contained in:
@@ -116,7 +116,7 @@ class CallRoutingControllerTest {
|
||||
|
||||
@Test
|
||||
void testGetTurnEndpointsCloudflare() throws IOException {
|
||||
when(experimentEnrollmentManager.isEnrolled(AuthHelper.VALID_UUID, "cloudflareTurn"))
|
||||
when(experimentEnrollmentManager.isEnrolled(AuthHelper.VALID_NUMBER, AuthHelper.VALID_UUID, "cloudflareTurn"))
|
||||
.thenReturn(true);
|
||||
|
||||
when(cloudflareTurnCredentialsManager.retrieveFromCloudflare()).thenReturn(new TurnToken("ABC", "XYZ",
|
||||
|
||||
@@ -46,7 +46,9 @@ class ExperimentEnrollmentManagerTest {
|
||||
|
||||
private static final UUID ACCOUNT_UUID = UUID.randomUUID();
|
||||
private static final String UUID_EXPERIMENT_NAME = "uuid_test";
|
||||
private static final String E164_AND_UUID_EXPERIMENT_NAME = "e164_uuid_test";
|
||||
|
||||
private static final String NOT_ENROLLED_164 = "+632025551212";
|
||||
private static final String ENROLLED_164 = "+12025551212";
|
||||
private static final String EXCLUDED_164 = "+18005551212";
|
||||
private static final String E164_EXPERIMENT_NAME = "e164_test";
|
||||
@@ -71,6 +73,10 @@ class ExperimentEnrollmentManagerTest {
|
||||
.thenReturn(Optional.of(experimentEnrollmentConfiguration));
|
||||
when(dynamicConfiguration.getPreRegistrationEnrollmentConfiguration(E164_EXPERIMENT_NAME))
|
||||
.thenReturn(Optional.of(preRegistrationExperimentEnrollmentConfiguration));
|
||||
when(dynamicConfiguration.getExperimentEnrollmentConfiguration(E164_AND_UUID_EXPERIMENT_NAME))
|
||||
.thenReturn(Optional.of(experimentEnrollmentConfiguration));
|
||||
when(dynamicConfiguration.getPreRegistrationEnrollmentConfiguration(E164_AND_UUID_EXPERIMENT_NAME))
|
||||
.thenReturn(Optional.of(preRegistrationExperimentEnrollmentConfiguration));
|
||||
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACCOUNT_UUID);
|
||||
@@ -112,6 +118,29 @@ class ExperimentEnrollmentManagerTest {
|
||||
assertEquals(75, counts.get(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsEnrolled_E164AndUuidExperiment() {
|
||||
when(preRegistrationExperimentEnrollmentConfiguration.getIncludedCountryCodes()).thenReturn(Set.of("1"));
|
||||
when(preRegistrationExperimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(0);
|
||||
when(preRegistrationExperimentEnrollmentConfiguration.getEnrolledE164s()).thenReturn(Collections.emptySet());
|
||||
when(preRegistrationExperimentEnrollmentConfiguration.getExcludedE164s()).thenReturn(Collections.emptySet());
|
||||
when(preRegistrationExperimentEnrollmentConfiguration.getExcludedCountryCodes()).thenReturn(Collections.emptySet());
|
||||
|
||||
when(uuidSelector.getUuids()).thenReturn(Set.of(ACCOUNT_UUID));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(0);
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(uuidSelector.getUuids()).thenReturn(Collections.emptySet());
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
when(preRegistrationExperimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
void testIsEnrolled_PreRegistrationExperiment(final String e164, final String experimentName,
|
||||
|
||||
Reference in New Issue
Block a user