mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 11:46:53 +00:00
Rename Account#getUUID() to Account#getAccountIdentifier()
This commit is contained in:
1 parent
7b472afbcb
commit
20cf3d7429
81 files changed
+421
-427
No files matched your search
+5
-5
@@ -153,7 +153,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
@@ -181,7 +181,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
@@ -210,7 +210,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(authenticatedDevice));
|
||||
when(account.getPrimaryDevice()).thenReturn(authenticatedDevice);
|
||||
@@ -250,7 +250,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
@@ -277,7 +277,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ class CertificateGeneratorTest {
|
||||
SIGNING_CERTIFICATE_DATA, SIGNING_KEY, 1, embedSigner);
|
||||
|
||||
when(account.getIdentityKey(IdentityType.ACI)).thenReturn(IDENTITY_KEY);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
when(account.getNumber()).thenReturn(E164);
|
||||
|
||||
final byte[] contents = certificateGenerator.createFor(account, deviceId, includeE164);
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
|
||||
account = mock(Account.class);
|
||||
final UUID accountIdentifier = UUID.randomUUID();
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.getNumber()).thenReturn("+18005551212");
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -106,7 +106,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
} else {
|
||||
verify(registrationRecoveryPasswordsManager, never()).remove(any());
|
||||
}
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of(Device.PRIMARY_ID));
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getAccountIdentifier(), List.of(Device.PRIMARY_ID));
|
||||
try {
|
||||
verify(pushNotificationManager).sendAttemptLoginNotification(any(), eq("failedRegistrationLock"));
|
||||
} catch (final NotPushRegisteredException ignored) {
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ public class BackupAuthManagerTest {
|
||||
final BackupAuthManager authManager = create();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(aci);
|
||||
|
||||
AccountsHelper.setupMockGet(accountsManager, account);
|
||||
@@ -556,7 +556,7 @@ public class BackupAuthManagerTest {
|
||||
private final Account account = mock(Account.class);
|
||||
|
||||
MockAccountBuilder() {
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
}
|
||||
|
||||
MockAccountBuilder backupLevel(BackupLevel backupLevel) {
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class BackupAuthTestUtil {
|
||||
final BackupAuthManager issuer = new BackupAuthManager(
|
||||
mock(ExperimentEnrollmentManager.class), null, null, null, null, params, clock);
|
||||
Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getBackupCredentialRequest(any())).thenReturn(Optional.of(request.serialize()));
|
||||
when(account.getBackupVoucher()).thenReturn(switch (backupLevel) {
|
||||
case FREE -> null;
|
||||
|
||||
+4
-4
@@ -185,7 +185,7 @@ class AccountControllerTest {
|
||||
when(senderPinAccount.getRegistrationLock()).thenReturn(
|
||||
new StoredRegistrationLock(Optional.empty(), Optional.empty(), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
|
||||
when(senderHasStorage.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(senderHasStorage.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
when(senderHasStorage.hasCapability(DeviceCapability.STORAGE)).thenReturn(true);
|
||||
when(senderHasStorage.getRegistrationLock()).thenReturn(
|
||||
new StoredRegistrationLock(Optional.empty(), Optional.empty(), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
@@ -194,12 +194,12 @@ class AccountControllerTest {
|
||||
new StoredRegistrationLock(Optional.of(registrationLockCredentials.hash()),
|
||||
Optional.of(registrationLockCredentials.salt()), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
when(senderRegLockAccount.getLastSeen()).thenReturn(System.currentTimeMillis());
|
||||
when(senderRegLockAccount.getUuid()).thenReturn(SENDER_REG_LOCK_UUID);
|
||||
when(senderRegLockAccount.getAccountIdentifier()).thenReturn(SENDER_REG_LOCK_UUID);
|
||||
when(senderRegLockAccount.getNumber()).thenReturn(SENDER_REG_LOCK);
|
||||
|
||||
when(senderTransfer.getRegistrationLock()).thenReturn(
|
||||
new StoredRegistrationLock(Optional.empty(), Optional.empty(), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
when(senderTransfer.getUuid()).thenReturn(SENDER_TRANSFER_UUID);
|
||||
when(senderTransfer.getAccountIdentifier()).thenReturn(SENDER_TRANSFER_UUID);
|
||||
when(senderTransfer.getNumber()).thenReturn(SENDER_TRANSFER);
|
||||
|
||||
when(accountsManager.getByE164(eq(SENDER_PIN))).thenReturn(Optional.of(senderPinAccount));
|
||||
@@ -975,7 +975,7 @@ class AccountControllerTest {
|
||||
void testLookupUsername() {
|
||||
final Account account = mock(Account.class);
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
|
||||
when(accountsManager.getByUsernameHash(any())).thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
Response response = resources.getJerseyTest()
|
||||
|
||||
+4
-4
@@ -126,7 +126,7 @@ class AccountControllerV2Test {
|
||||
final List<Device> devices = account.getDevices();
|
||||
|
||||
final Account updatedAccount = mock(Account.class);
|
||||
when(updatedAccount.getUuid()).thenReturn(uuid);
|
||||
when(updatedAccount.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(updatedAccount.getNumber()).thenReturn(number);
|
||||
when(updatedAccount.getIdentityKey(IdentityType.PNI)).thenReturn(pniIdentityKey);
|
||||
if (number.equals(account.getNumber())) {
|
||||
@@ -469,13 +469,13 @@ class AccountControllerV2Test {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(AccountsTestHelper.AccountsDataReportArgumentProvider.class)
|
||||
void testGetAccountDataReport(final Account account, final String expectedTextAfterHeader) throws Exception {
|
||||
when(AuthHelper.ACCOUNTS_MANAGER.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(AuthHelper.ACCOUNTS_MANAGER.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final Response response = resources.getJerseyTest()
|
||||
.target("/v2/accounts/data_report")
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getAuthHeader(account.getUuid(), "password"))
|
||||
.header("Authorization", AuthHelper.getAuthHeader(account.getAccountIdentifier(), "password"))
|
||||
.get();
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ class DeviceControllerTest {
|
||||
|
||||
when(account.getNextDeviceId()).thenReturn(NEXT_DEVICE_ID);
|
||||
when(account.getNumber()).thenReturn(AuthHelper.VALID_NUMBER);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI);
|
||||
when(account.getIdentifier(IdentityType.PNI)).thenReturn(AuthHelper.VALID_PNI);
|
||||
|
||||
+1
-1
@@ -211,7 +211,7 @@ class KeysControllerTest {
|
||||
when(KEYS.takeDevicePreKeys(eq(SAMPLE_DEVICE_ID), eq(EXISTS_PNI_SERVICE_ID), any()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(pniKeys)));
|
||||
|
||||
when(existsAccount.getUuid()).thenReturn(EXISTS_UUID);
|
||||
when(existsAccount.getAccountIdentifier()).thenReturn(EXISTS_UUID);
|
||||
when(existsAccount.isIdentifiedBy(new AciServiceIdentifier(EXISTS_UUID))).thenReturn(true);
|
||||
when(existsAccount.getPhoneNumberIdentifier()).thenReturn(EXISTS_PNI);
|
||||
when(existsAccount.isIdentifiedBy(new PniServiceIdentifier(EXISTS_PNI))).thenReturn(true);
|
||||
|
||||
+6
-6
@@ -722,7 +722,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -754,7 +754,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -786,7 +786,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -819,7 +819,7 @@ class MessageControllerTest {
|
||||
final UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -851,7 +851,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -914,7 +914,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
|
||||
+6
-6
@@ -211,7 +211,7 @@ class ProfileControllerTest {
|
||||
|
||||
when(profileAccount.getIdentityKey(IdentityType.ACI)).thenReturn(ACCOUNT_TWO_IDENTITY_KEY);
|
||||
when(profileAccount.getIdentityKey(IdentityType.PNI)).thenReturn(ACCOUNT_TWO_PHONE_NUMBER_IDENTITY_KEY);
|
||||
when(profileAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID_TWO);
|
||||
when(profileAccount.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID_TWO);
|
||||
when(profileAccount.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID_TWO);
|
||||
when(profileAccount.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI_TWO);
|
||||
when(profileAccount.getCurrentProfileVersion()).thenReturn(Optional.empty());
|
||||
@@ -222,7 +222,7 @@ class ProfileControllerTest {
|
||||
|
||||
capabilitiesAccount = mock(Account.class);
|
||||
|
||||
when(capabilitiesAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(capabilitiesAccount.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(capabilitiesAccount.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(capabilitiesAccount.getIdentityKey(IdentityType.ACI)).thenReturn(ACCOUNT_IDENTITY_KEY);
|
||||
when(capabilitiesAccount.getIdentityKey(IdentityType.PNI)).thenReturn(ACCOUNT_PHONE_NUMBER_IDENTITY_KEY);
|
||||
@@ -1037,7 +1037,7 @@ class ProfileControllerTest {
|
||||
@Test
|
||||
void testGetProfileWithExpiringProfileKeyCredentialVersionNotFound() throws VerificationFailedException {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version("version")));
|
||||
|
||||
@@ -1249,7 +1249,7 @@ class ProfileControllerTest {
|
||||
final ProfileKeyCredentialRequest credentialRequest = profileKeyCredentialRequestContext.getRequest();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version));
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(UNIDENTIFIED_ACCESS_KEY));
|
||||
@@ -1318,7 +1318,7 @@ class ProfileControllerTest {
|
||||
final ProfileKeyCredentialRequest credentialRequest = profileKeyCredentialRequestContext.getRequest();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(UNIDENTIFIED_ACCESS_KEY));
|
||||
when(account.isIdentifiedBy(new AciServiceIdentifier(AuthHelper.VALID_UUID))).thenReturn(true);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version));
|
||||
@@ -1366,7 +1366,7 @@ class ProfileControllerTest {
|
||||
final ProfileKeyCredentialRequest credentialRequest = profileKeyCredentialRequestContext.getRequest();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(UNIDENTIFIED_ACCESS_KEY));
|
||||
when(account.isIdentifiedBy(new AciServiceIdentifier(AuthHelper.VALID_UUID))).thenReturn(true);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version("the-current-version")));
|
||||
|
||||
+1
-1
@@ -619,7 +619,7 @@ class RegistrationControllerTest {
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
final Account account = MockUtils.buildMock(Account.class, a -> {
|
||||
when(a.getUuid()).thenReturn(accountIdentifier);
|
||||
when(a.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(a.getPhoneNumberIdentifier()).thenReturn(phoneNumberIdentifier);
|
||||
when(a.getPrimaryDevice()).thenReturn(device);
|
||||
});
|
||||
|
||||
+1
-1
@@ -385,7 +385,7 @@ public class SecureValueRecovery2ControllerTest {
|
||||
|
||||
private static Account account(final UUID uuid) {
|
||||
final Account a = new Account();
|
||||
a.setUuid(uuid);
|
||||
a.setAccountIdentifier(uuid);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-18
@@ -81,25 +81,25 @@ class ExperimentEnrollmentManagerTest {
|
||||
.thenReturn(Optional.of(e164ExperimentEnrollmentConfiguration));
|
||||
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACCOUNT_UUID);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsEnrolled_UuidExperiment() {
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(
|
||||
experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME + "-unrelated-experiment"));
|
||||
experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME + "-unrelated-experiment"));
|
||||
|
||||
when(uuidSelector.getUuids()).thenReturn(Set.of(ACCOUNT_UUID));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(uuidSelector.getUuids()).thenReturn(Collections.emptySet());
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(0);
|
||||
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(experimentEnrollmentConfiguration.getExcludedUuids()).thenReturn(Set.of(EXCLUDED_UUID));
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
@@ -112,14 +112,14 @@ class ExperimentEnrollmentManagerTest {
|
||||
void testIsEnrolled_UuidExperimentPercentage() {
|
||||
when(uuidSelector.getUuids()).thenReturn(Set.of(ACCOUNT_UUID));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(0);
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(75);
|
||||
final Map<Boolean, Long> counts = IntStream.range(0, 100).mapToObj(i -> {
|
||||
when(random.nextInt(100)).thenReturn(i);
|
||||
return experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME);
|
||||
return experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME);
|
||||
})
|
||||
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||
assertEquals(25, counts.get(false));
|
||||
@@ -137,24 +137,24 @@ class ExperimentEnrollmentManagerTest {
|
||||
// test UUID enrollment is prioritized
|
||||
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));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), 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));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
|
||||
// test fallback from UUID enrollment to general enrollment percentage
|
||||
when(uuidSelector.getUuids()).thenReturn(Collections.emptySet());
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
|
||||
// test fallback from UUID/general enrollment to e164 enrollment
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(0);
|
||||
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));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
when(e164ExperimentEnrollmentConfiguration.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));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ class AccountsAnonymousGrpcServiceTest extends
|
||||
final byte[] usernameHash = TestRandomUtil.nextBytes(AccountController.USERNAME_HASH_LENGTH);
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
|
||||
when(accountsManager.getByUsernameHash(usernameHash))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
|
||||
+8
-8
@@ -170,7 +170,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
final UUID usernameLinkHandle = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(phoneNumberIdentifier);
|
||||
when(account.getNumber()).thenReturn(e164);
|
||||
when(account.getUsernameHash()).thenReturn(Optional.of(usernameHash));
|
||||
@@ -759,7 +759,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
final Duration retryDuration = Duration.ofDays(1);
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI))
|
||||
.thenReturn(Optional.of(account));
|
||||
@@ -787,7 +787,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
|
||||
when(account.getBackupVoucher()).thenReturn(new Account.BackupVoucher(100, expiration));
|
||||
when(account.getBadges()).thenReturn(List.of(badge1, badge2));
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI)).thenReturn(Optional.of(account));
|
||||
|
||||
final GetEntitlementsResponse entitlements = authenticatedServiceStub()
|
||||
@@ -827,7 +827,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
final UUID updatedPni = UUID.randomUUID();
|
||||
|
||||
final Account updatedAccount = mock(Account.class);
|
||||
when(updatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(updatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(updatedAccount.getNumber()).thenReturn(newNumber);
|
||||
when(updatedAccount.getPhoneNumberIdentifier()).thenReturn(updatedPni);
|
||||
when(updatedAccount.getUsernameHash()).thenReturn(Optional.empty());
|
||||
@@ -996,8 +996,8 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(AccountsTestHelper.AccountsDataReportArgumentProvider.class)
|
||||
void getAccountDataReport(final Account account, final String expectedTextAfterHeader) {
|
||||
getMockAuthenticationInterceptor().setAuthenticatedDevice(account.getUuid(), Device.PRIMARY_ID);
|
||||
when(accountsManager.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
getMockAuthenticationInterceptor().setAuthenticatedDevice(account.getAccountIdentifier(), Device.PRIMARY_ID);
|
||||
when(accountsManager.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final GetAccountDataReportResponse response =
|
||||
authenticatedServiceStub().getAccountDataReport(GetAccountDataReportRequest.newBuilder().build());
|
||||
@@ -1009,12 +1009,12 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
@Test
|
||||
void getCapabilities() {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
// public-visible and self-visible capabilities should be returned on the authenticated RPC
|
||||
when(account.hasCapability(DeviceCapability.SPARSE_POST_QUANTUM_RATCHET)).thenReturn(true);
|
||||
when(account.hasCapability(DeviceCapability.USERNAME_CHANGE_SYNC_MESSAGE)).thenReturn(true);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI)).thenReturn(Optional.of(account));
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class ChallengeGrpcServiceTest extends
|
||||
|
||||
@Override
|
||||
protected ChallengeGrpcService createServiceBeforeEachTest() {
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI)).thenReturn(Optional.of(account));
|
||||
return new ChallengeGrpcService(
|
||||
accountsManager,
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class CredentialsAnonymousGrpcServiceTest extends
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(USER_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(USER_UUID);
|
||||
|
||||
when(accountsManager.getByE164(USER_E164)).thenReturn(Optional.of(account));
|
||||
}
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ public class CredentialsGrpcServiceTest
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getNumber()).thenReturn(PHONE_NUMBER);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.PNI)).thenReturn(AUTHENTICATED_PNI);
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ class DevicesGrpcServiceTest extends SimpleBaseGrpcTest<DevicesGrpcService, Devi
|
||||
|
||||
@Override
|
||||
protected DevicesGrpcService createServiceBeforeEachTest() {
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI))
|
||||
|
||||
+1
-1
@@ -381,7 +381,7 @@ class KeysAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<KeysAnonymousGrpcS
|
||||
final byte[] unidentifiedAccessKey = TestRandomUtil.nextBytes(UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH);
|
||||
|
||||
final Account targetAccount = mock(Account.class);
|
||||
when(targetAccount.getUuid()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getIdentityKey(IdentityType.ACI)).thenReturn(new IdentityKey(ECKeyPair.generate().getPublicKey()));
|
||||
when(targetAccount.getDevices()).thenReturn(Collections.emptyList());
|
||||
when(targetAccount.getDevice(anyByte())).thenReturn(Optional.empty());
|
||||
|
||||
+5
-6
@@ -72,7 +72,6 @@ import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||
import org.whispersystems.textsecuregcm.storage.Device;
|
||||
import org.whispersystems.textsecuregcm.storage.DeviceCapability;
|
||||
import org.whispersystems.textsecuregcm.storage.KeyIdUtil;
|
||||
import org.whispersystems.textsecuregcm.storage.KeysManager;
|
||||
import org.whispersystems.textsecuregcm.tests.util.KeysHelper;
|
||||
@@ -111,7 +110,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
when(authenticatedDevice.getId()).thenReturn(AUTHENTICATED_DEVICE_ID);
|
||||
|
||||
final Account authenticatedAccount = mock(Account.class);
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getPhoneNumberIdentifier()).thenReturn(AUTHENTICATED_PNI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.PNI)).thenReturn(AUTHENTICATED_PNI);
|
||||
@@ -470,7 +469,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
case ACI -> new AciServiceIdentifier(identifier);
|
||||
};
|
||||
|
||||
when(targetAccount.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getIdentifier(identityType)).thenReturn(identifier);
|
||||
when(targetAccount.getIdentityKey(identityType)).thenReturn(identityKey);
|
||||
when(accountsManager.getByServiceIdentifier(serviceIdentifier))
|
||||
@@ -587,7 +586,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
final UUID accountIdentifier = UUID.randomUUID();
|
||||
|
||||
final Account targetAccount = mock(Account.class);
|
||||
when(targetAccount.getUuid()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getIdentityKey(IdentityType.ACI)).thenReturn(new IdentityKey(ECKeyPair.generate().getPublicKey()));
|
||||
when(targetAccount.getDevices()).thenReturn(Collections.emptyList());
|
||||
when(targetAccount.getDevice(anyByte())).thenReturn(Optional.empty());
|
||||
@@ -618,7 +617,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
when(mockDevice.getRegistrationId(IdentityType.ACI)).thenReturn(registrationId);
|
||||
|
||||
final Account targetAccount = mock(Account.class);
|
||||
when(targetAccount.getUuid()).thenReturn(targetAccountId);
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(targetAccountId);
|
||||
when(targetAccount.getIdentityKey(IdentityType.ACI)).thenReturn(new IdentityKey(ECKeyPair.generate().getPublicKey()));
|
||||
when(targetAccount.getDevice(targetDeviceId)).thenReturn(Optional.of(mockDevice));
|
||||
when(targetAccount.getDevices()).thenReturn(List.of(mockDevice));
|
||||
@@ -667,7 +666,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
case ACI -> new AciServiceIdentifier(identifier);
|
||||
};
|
||||
|
||||
when(targetAccount.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getIdentifier(identityType)).thenReturn(identifier);
|
||||
when(targetAccount.getIdentityKey(identityType)).thenReturn(identityKey);
|
||||
when(accountsManager.getByServiceIdentifier(serviceIdentifier))
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class MessageDispatcherTest {
|
||||
void setUp() {
|
||||
account = mock(Account.class);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(ACI);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
|
||||
device = mock(Device.class);
|
||||
messagesManager = mock(MessagesManager.class);
|
||||
|
||||
+1
-3
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.when;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Empty;
|
||||
import io.grpc.Channel;
|
||||
import io.grpc.Grpc;
|
||||
import io.grpc.Status;
|
||||
import io.grpc.StatusException;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
@@ -45,7 +44,6 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
import org.junit.jupiter.api.function.ThrowingSupplier;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
@@ -173,7 +171,7 @@ class MessagesGrpcServiceTest extends SimpleBaseGrpcTest<MessagesGrpcService, Me
|
||||
when(secondLinkedDevice.getId()).thenReturn(SECOND_LINKED_DEVICE_ID);
|
||||
when(secondLinkedDevice.getRegistrationId(IdentityType.ACI)).thenReturn(SECOND_LINKED_DEVICE_REGISTRATION_ID);
|
||||
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getDevice(anyByte())).thenReturn(Optional.empty());
|
||||
when(authenticatedAccount.getDevice(AUTHENTICATED_DEVICE_ID)).thenReturn(Optional.of(authenticatedDevice));
|
||||
|
||||
+4
-4
@@ -517,7 +517,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
final VersionedProfileV1 profile = mock(VersionedProfileV1.class);
|
||||
when(profile.commitment()).thenReturn(profileKeyCommitment.serialize());
|
||||
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(Optional.of(account));
|
||||
when(profilesManager.getV1(targetUuid, HexFormat.of().formatHex(profileKeyBytes))).thenReturn(Optional.of(profile));
|
||||
@@ -554,7 +554,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
final byte[] unidentifiedAccessKey = TestRandomUtil.nextBytes(UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH);
|
||||
final UUID targetUuid = UUID.randomUUID();
|
||||
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(
|
||||
missingAccount ? Optional.empty() : Optional.of(account));
|
||||
@@ -604,7 +604,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
final byte[] version = TestRandomUtil.nextBytes(32);
|
||||
final String versionHex = HexFormat.of().formatHex(version);
|
||||
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(
|
||||
Optional.of(account));
|
||||
@@ -643,7 +643,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
|
||||
final VersionedProfileV1 profile = mock(VersionedProfileV1.class);
|
||||
when(profile.commitment()).thenReturn("commitment".getBytes(StandardCharsets.UTF_8));
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(Optional.of(account));
|
||||
when(profilesManager.getV1(targetUuid, versionHex)).thenReturn(Optional.of(profile));
|
||||
|
||||
+4
-4
@@ -182,7 +182,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
when(dynamicConfigurationManager.getConfiguration()).thenReturn(dynamicConfiguration);
|
||||
when(dynamicConfiguration.getPaymentsConfiguration()).thenReturn(dynamicPaymentsConfiguration);
|
||||
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getIdentifier(org.whispersystems.textsecuregcm.identity.IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getNumber()).thenReturn(phoneNumber);
|
||||
when(account.getBadges()).thenReturn(Collections.emptyList());
|
||||
@@ -241,7 +241,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
final ArgumentCaptor<VersionedProfileV1> profileV1ArgumentCaptor = ArgumentCaptor.forClass(VersionedProfileV1.class);
|
||||
final ArgumentCaptor<VersionedProfile> profileArgumentCaptor = ArgumentCaptor.forClass(VersionedProfile.class);
|
||||
|
||||
verify(profilesManager).set(eq(account.getUuid()), profileV1ArgumentCaptor.capture(), profileArgumentCaptor.capture(), isNull());
|
||||
verify(profilesManager).set(eq(account.getAccountIdentifier()), profileV1ArgumentCaptor.capture(), profileArgumentCaptor.capture(), isNull());
|
||||
|
||||
final VersionedProfile profile = profileArgumentCaptor.getValue();
|
||||
|
||||
@@ -684,7 +684,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
final UUID targetAci = UUID.randomUUID();
|
||||
final VersionedProfile v2Profile = new VersionedProfile(version, data, paymentAddress, commitment);
|
||||
|
||||
when(account.getUuid()).thenReturn(targetAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetAci);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version));
|
||||
when(account.hasCapability(DeviceCapability.PROFILES_V2)).thenReturn(true);
|
||||
when(account.getIdentityKey(org.whispersystems.textsecuregcm.identity.IdentityType.ACI)).thenReturn(identityKey);
|
||||
@@ -737,7 +737,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
final VersionedProfile v2Profile = new VersionedProfile(version, data, paymentAddress, commitment);
|
||||
|
||||
final UUID targetAci = UUID.randomUUID();
|
||||
when(account.getUuid()).thenReturn(targetAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetAci);
|
||||
when(account.hasCapability(DeviceCapability.PROFILES_V2)).thenReturn(true);
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetAci))).thenReturn(Optional.of(account));
|
||||
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ class RateLimitChallengeManagerTest {
|
||||
@ValueSource(booleans = {true, false})
|
||||
void answerPushChallenge(final boolean successfulChallenge) throws RateLimitExceededException {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(account.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
when(pushChallengeManager.answerChallenge(eq(account), any())).thenReturn(successfulChallenge);
|
||||
|
||||
@@ -84,7 +84,7 @@ class RateLimitChallengeManagerTest {
|
||||
throws RateLimitExceededException, IOException, InvalidCaptchaArgumentException {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getNumber()).thenReturn("+18005551234");
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(account.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
when(captchaChecker.verify(any(), eq(Action.CHALLENGE), any(), any(), any()))
|
||||
.thenReturn(AssessmentResult.fromScore(actualScore, DEFAULT_SCORE_THRESHOLD));
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ class RateLimitChallengeOptionManagerTest {
|
||||
final int expectedLength = (expectCaptcha ? 1 : 0) + (expectPushChallenge ? 1 : 0);
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(account.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
final List<RateLimitChallengeOption> options = rateLimitChallengeOptionManager.getChallengeOptions(account);
|
||||
assertEquals(expectedLength, options.size());
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class MessageMetricsTest {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(pni);
|
||||
when(account.isIdentifiedBy(any())).thenReturn(false);
|
||||
when(account.isIdentifiedBy(new AciServiceIdentifier(aci))).thenReturn(true);
|
||||
|
||||
@@ -111,7 +111,7 @@ class MessageSenderTest {
|
||||
.setUrgent(urgent)
|
||||
.build();
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -168,7 +168,7 @@ class MessageSenderTest {
|
||||
final Device device = mock(Device.class);
|
||||
final MessageProtos.Envelope message = MessageProtos.Envelope.newBuilder().build();
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -209,7 +209,7 @@ class MessageSenderTest {
|
||||
final Device device = mock(Device.class);
|
||||
final MessageProtos.Envelope message = MessageProtos.Envelope.newBuilder().build();
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -245,7 +245,7 @@ class MessageSenderTest {
|
||||
final Account account = mock(Account.class);
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -306,7 +306,7 @@ class MessageSenderTest {
|
||||
final Account account = mock(Account.class);
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -361,7 +361,7 @@ class MessageSenderTest {
|
||||
final Account account = mock(Account.class);
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -686,7 +686,7 @@ class MessageSenderTest {
|
||||
final byte deviceId = Device.PRIMARY_ID;
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
|
||||
|
||||
+5
-5
@@ -190,7 +190,7 @@ class PushNotificationManagerTest {
|
||||
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
|
||||
final PushNotification pushNotification = new PushNotification(
|
||||
"token", tokenType, PushNotification.NotificationType.NOTIFICATION, null, account, device, urgent, null);
|
||||
@@ -226,7 +226,7 @@ class PushNotificationManagerTest {
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
when(device.getGcmId()).thenReturn("token");
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(aci);
|
||||
when(accountsManager.getByAccountIdentifier(aci)).thenReturn(Optional.of(account));
|
||||
|
||||
@@ -252,7 +252,7 @@ class PushNotificationManagerTest {
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
when(device.getApnId()).thenReturn("apns-token");
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(aci);
|
||||
when(accountsManager.getByAccountIdentifier(aci)).thenReturn(Optional.of(account));
|
||||
|
||||
@@ -284,7 +284,7 @@ class PushNotificationManagerTest {
|
||||
when(device.getApnId()).thenReturn("apns-token");
|
||||
when(device.getPushTimestamp()).thenReturn(tokenTimestamp.toEpochMilli());
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(accountsManager.getByAccountIdentifier(aci)).thenReturn(Optional.of(account));
|
||||
|
||||
final PushNotification pushNotification = new PushNotification(
|
||||
@@ -311,7 +311,7 @@ class PushNotificationManagerTest {
|
||||
final Device device = mock(Device.class);
|
||||
final String userAgent = HttpHeaders.USER_AGENT;
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
|
||||
when(pushNotificationScheduler.cancelScheduledNotifications(account, device))
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class PushNotificationSchedulerTest {
|
||||
when(device.getLastSeen()).thenReturn(System.currentTimeMillis());
|
||||
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getNumber()).thenReturn(ACCOUNT_NUMBER);
|
||||
when(account.getDevice(DEVICE_ID)).thenReturn(Optional.of(device));
|
||||
|
||||
+6
-6
@@ -254,9 +254,9 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
aciPqLastResortPreKey,
|
||||
pniPqLastResortPreKey);
|
||||
|
||||
assertEquals(Optional.of(aciSignedPreKey), keysManager.getEcSignedPreKey(account.getUuid(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(aciSignedPreKey), keysManager.getEcSignedPreKey(account.getAccountIdentifier(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(pniSignedPreKey), keysManager.getEcSignedPreKey(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(aciPqLastResortPreKey), keysManager.getLastResort(account.getUuid(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(aciPqLastResortPreKey), keysManager.getLastResort(account.getAccountIdentifier(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(pniPqLastResortPreKey), keysManager.getLastResort(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join());
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
pniPqLastResortPreKey),
|
||||
null);
|
||||
|
||||
existingAccountUuid = existingAccount.getUuid();
|
||||
existingAccountUuid = existingAccount.getAccountIdentifier();
|
||||
}
|
||||
|
||||
final String password = RandomStringUtils.secure().nextAlphanumeric(16);
|
||||
@@ -394,7 +394,7 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
aciPqLastResortPreKey,
|
||||
pniPqLastResortPreKey);
|
||||
|
||||
assertEquals(existingAccountUuid, reregisteredAccount.getUuid());
|
||||
assertEquals(existingAccountUuid, reregisteredAccount.getAccountIdentifier());
|
||||
|
||||
verify(disconnectionRequestManager).requestDisconnection(argThat(account ->
|
||||
account.getIdentifier(IdentityType.ACI).equals(existingAccountUuid) && account != reregisteredAccount));
|
||||
@@ -464,9 +464,9 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
accountsManager.delete(account.getIdentifier(IdentityType.ACI), AccountsManager.DeletionReason.ADMIN_DELETED);
|
||||
|
||||
assertFalse(accountsManager.getByAccountIdentifier(aci).isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(account.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(account.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(account.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(account.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
|
||||
verify(disconnectionRequestManager).requestDisconnection(argThat(disconnectedAccount ->
|
||||
|
||||
@@ -135,7 +135,7 @@ class AccountTest {
|
||||
account.markStale();
|
||||
|
||||
assertThrows(AssertionError.class, account::getNumber);
|
||||
assertDoesNotThrow(account::getUuid);
|
||||
assertDoesNotThrow(account::getAccountIdentifier);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+15
-15
@@ -162,7 +162,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
final String secondNumber = "+18005552222";
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -177,7 +177,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isEmpty());
|
||||
|
||||
final Account updatedAccount = accountsManager.getByE164(secondNumber).orElseThrow();
|
||||
assertEquals(originalUuid, updatedAccount.getUuid());
|
||||
assertEquals(originalUuid, updatedAccount.getAccountIdentifier());
|
||||
assertEquals(secondNumber, updatedAccount.getNumber());
|
||||
assertNotEquals(originalPni, updatedAccount.getPhoneNumberIdentifier());
|
||||
|
||||
@@ -190,7 +190,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
final String originalNumber = "+18005551111";
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -203,7 +203,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
Map.of(Device.PRIMARY_ID, 1));
|
||||
|
||||
final Account updatedAccount = accountsManager.getByE164(originalNumber).orElseThrow();
|
||||
assertEquals(originalUuid, updatedAccount.getUuid());
|
||||
assertEquals(originalUuid, updatedAccount.getAccountIdentifier());
|
||||
assertEquals(originalNumber, updatedAccount.getNumber());
|
||||
assertEquals(originalPni, updatedAccount.getPhoneNumberIdentifier());
|
||||
|
||||
@@ -225,7 +225,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
keysManager.storeEcSignedPreKeys(account.getIdentifier(IdentityType.ACI),
|
||||
Device.PRIMARY_ID, KeysHelper.signedECPreKey(1, rotatedPniIdentityKeyPair)).join();
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final IdentityKey pniIdentityKey = new IdentityKey(rotatedPniIdentityKeyPair.getPublicKey());
|
||||
@@ -239,7 +239,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isEmpty());
|
||||
|
||||
assertTrue(accountsManager.getByE164(secondNumber).isPresent());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(secondNumber).map(Account::getUuid).orElseThrow());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(secondNumber).map(Account::getAccountIdentifier).orElseThrow());
|
||||
assertNotEquals(originalPni, secondPni);
|
||||
assertEquals(secondPni, accountsManager.getByE164(secondNumber).map(Account::getPhoneNumberIdentifier).orElseThrow());
|
||||
|
||||
@@ -262,7 +262,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair originalIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -285,7 +285,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
Map.of(Device.PRIMARY_ID, 2));
|
||||
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isPresent());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(originalNumber).map(Account::getUuid).orElseThrow());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(originalNumber).map(Account::getAccountIdentifier).orElseThrow());
|
||||
assertEquals(originalPni, accountsManager.getByE164(originalNumber).map(Account::getPhoneNumberIdentifier).orElseThrow());
|
||||
|
||||
assertTrue(accountsManager.getByE164(secondNumber).isEmpty());
|
||||
@@ -303,7 +303,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair originalIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -311,7 +311,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account existingAccount = AccountsHelper.createAccount(accountsManager, secondNumber);
|
||||
|
||||
final UUID existingAccountUuid = existingAccount.getUuid();
|
||||
final UUID existingAccountUuid = existingAccount.getAccountIdentifier();
|
||||
|
||||
accountsManager.changeNumber(originalUuid,
|
||||
secondNumber,
|
||||
@@ -325,7 +325,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isEmpty());
|
||||
|
||||
assertTrue(accountsManager.getByE164(secondNumber).isPresent());
|
||||
assertEquals(Optional.of(originalUuid), accountsManager.getByE164(secondNumber).map(Account::getUuid));
|
||||
assertEquals(Optional.of(originalUuid), accountsManager.getByE164(secondNumber).map(Account::getAccountIdentifier));
|
||||
|
||||
assertEquals(secondNumber, accountsManager.getByAccountIdentifier(originalUuid).map(Account::getNumber).orElseThrow());
|
||||
|
||||
@@ -344,7 +344,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account existingAccount2 = AccountsHelper.createAccount(accountsManager, secondNumber);
|
||||
|
||||
assertEquals(existingAccountUuid, existingAccount2.getUuid());
|
||||
assertEquals(existingAccountUuid, existingAccount2.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -354,12 +354,12 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final Account existingAccount = AccountsHelper.createAccount(accountsManager, secondNumber);
|
||||
|
||||
final UUID existingAccountUuid = existingAccount.getUuid();
|
||||
final UUID existingAccountUuid = existingAccount.getAccountIdentifier();
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account changedNumberAccount = accountsManager.changeNumber(originalUuid,
|
||||
@@ -373,7 +373,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account reRegisteredAccount = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
assertEquals(existingAccountUuid, reRegisteredAccount.getUuid());
|
||||
assertEquals(existingAccountUuid, reRegisteredAccount.getAccountIdentifier());
|
||||
assertEquals(originalPni, reRegisteredAccount.getPhoneNumberIdentifier());
|
||||
|
||||
assertEquals(Optional.empty(), accountsManager.findRecentlyDeletedAccountIdentifier(originalPni));
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ class AccountsManagerConcurrentModificationIntegrationTest {
|
||||
a.addDevice(DevicesHelper.createDevice(Device.PRIMARY_ID));
|
||||
});
|
||||
|
||||
uuid = account.getUuid();
|
||||
uuid = account.getAccountIdentifier();
|
||||
}
|
||||
|
||||
final boolean discoverableByPhoneNumber = false;
|
||||
|
||||
+20
-20
@@ -286,7 +286,7 @@ class AccountsManagerTest {
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
assertEquals(account.get().getNumber(), "+14152222222");
|
||||
assertEquals(account.get().getUuid(), uuid);
|
||||
assertEquals(account.get().getAccountIdentifier(), uuid);
|
||||
assertEquals(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e"), account.get().getPhoneNumberIdentifier());
|
||||
|
||||
verify(clusterCommands, times(1)).get(eq("Account3::" + uuid));
|
||||
@@ -308,7 +308,7 @@ class AccountsManagerTest {
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
assertEquals(account.get().getNumber(), "+14152222222");
|
||||
assertEquals(account.get().getUuid(), uuid);
|
||||
assertEquals(account.get().getAccountIdentifier(), uuid);
|
||||
assertEquals(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e"), account.get().getPhoneNumberIdentifier());
|
||||
|
||||
verify(asyncClusterCommands, times(1)).get(eq("Account3::" + uuid));
|
||||
@@ -669,7 +669,7 @@ class AccountsManagerTest {
|
||||
|
||||
Account account = AccountsHelper.generateTestAccount("+14152222222", List.of(primaryDevice, linkedDevice));
|
||||
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
when(keysManager.deleteSingleUsePreKeys(any(), anyByte())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(messagesManager.clear(any(), anyByte())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
|
||||
@@ -678,10 +678,10 @@ class AccountsManagerTest {
|
||||
account = accountsManager.removeDevice(account.getIdentifier(IdentityType.ACI), linkedDevice.getId());
|
||||
|
||||
assertFalse(account.getDevice(linkedDevice.getId()).isPresent());
|
||||
verify(messagesManager, times(2)).clear(account.getUuid(), linkedDevice.getId());
|
||||
verify(keysManager, times(2)).deleteSingleUsePreKeys(account.getUuid(), linkedDevice.getId());
|
||||
verify(keysManager).buildWriteItemsForRemovedDevice(account.getUuid(), account.getPhoneNumberIdentifier(), linkedDevice.getId());
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of(linkedDevice.getId()));
|
||||
verify(messagesManager, times(2)).clear(account.getAccountIdentifier(), linkedDevice.getId());
|
||||
verify(keysManager, times(2)).deleteSingleUsePreKeys(account.getAccountIdentifier(), linkedDevice.getId());
|
||||
verify(keysManager).buildWriteItemsForRemovedDevice(account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), linkedDevice.getId());
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getAccountIdentifier(), List.of(linkedDevice.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -714,7 +714,7 @@ class AccountsManagerTest {
|
||||
|
||||
verify(accounts).create(argThat(account -> e164.equals(account.getNumber())), any());
|
||||
verify(keysManager).buildWriteItemsForNewDevice(
|
||||
eq(createdAccount.getUuid()),
|
||||
eq(createdAccount.getAccountIdentifier()),
|
||||
eq(createdAccount.getPhoneNumberIdentifier()),
|
||||
eq(Device.PRIMARY_ID),
|
||||
notNull(),
|
||||
@@ -722,7 +722,7 @@ class AccountsManagerTest {
|
||||
notNull(),
|
||||
notNull());
|
||||
|
||||
verify(changeNumberWaitingPeriodManager).handleAccountCreated(eq(createdAccount.getUuid()), any(Instant.class));
|
||||
verify(changeNumberWaitingPeriodManager).handleAccountCreated(eq(createdAccount.getAccountIdentifier()), any(Instant.class));
|
||||
|
||||
verifyNoInteractions(messagesManager);
|
||||
verifyNoInteractions(profilesManager);
|
||||
@@ -746,7 +746,7 @@ class AccountsManagerTest {
|
||||
final Account requestedAccount = invocation.getArgument(0);
|
||||
|
||||
final Account existingAccount = mock(Account.class);
|
||||
when(existingAccount.getUuid()).thenReturn(existingUuid);
|
||||
when(existingAccount.getAccountIdentifier()).thenReturn(existingUuid);
|
||||
when(existingAccount.getIdentifier(IdentityType.ACI)).thenReturn(existingUuid);
|
||||
when(existingAccount.getNumber()).thenReturn(existingAccountE164);
|
||||
when(existingAccount.getPhoneNumberIdentifier()).thenReturn(requestedAccount.getIdentifier(IdentityType.PNI));
|
||||
@@ -764,10 +764,10 @@ class AccountsManagerTest {
|
||||
assertEquals(e164, reregisteredAccount.getNumber());
|
||||
|
||||
verify(accounts)
|
||||
.create(argThat(account -> e164.equals(account.getNumber()) && existingUuid.equals(account.getUuid())), any());
|
||||
.create(argThat(account -> e164.equals(account.getNumber()) && existingUuid.equals(account.getAccountIdentifier())), any());
|
||||
|
||||
verify(keysManager).buildWriteItemsForNewDevice(
|
||||
eq(reregisteredAccount.getUuid()),
|
||||
eq(reregisteredAccount.getAccountIdentifier()),
|
||||
eq(reregisteredAccount.getPhoneNumberIdentifier()),
|
||||
eq(Device.PRIMARY_ID),
|
||||
notNull(),
|
||||
@@ -797,7 +797,7 @@ class AccountsManagerTest {
|
||||
final Account account = createAccount(e164, attributes);
|
||||
|
||||
verify(accounts).create(
|
||||
argThat(a -> e164.equals(a.getNumber()) && recentlyDeletedUuid.equals(a.getUuid())),
|
||||
argThat(a -> e164.equals(a.getNumber()) && recentlyDeletedUuid.equals(a.getAccountIdentifier())),
|
||||
any());
|
||||
|
||||
verify(keysManager).buildWriteItemsForNewDevice(eq(account.getIdentifier(IdentityType.ACI)),
|
||||
@@ -1124,7 +1124,7 @@ class AccountsManagerTest {
|
||||
@Test
|
||||
void testReserveUsernameHash() throws UsernameHashNotAvailableException {
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final List<byte[]> usernameHashes = List.of(TestRandomUtil.nextBytes(32), TestRandomUtil.nextBytes(32));
|
||||
|
||||
@@ -1138,7 +1138,7 @@ class AccountsManagerTest {
|
||||
final byte[] oldUsernameHash = TestRandomUtil.nextBytes(32);
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
account.setUsernameHash(oldUsernameHash);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final List<byte[]> usernameHashes = List.of(TestRandomUtil.nextBytes(32), oldUsernameHash, TestRandomUtil.nextBytes(32));
|
||||
|
||||
@@ -1150,7 +1150,7 @@ class AccountsManagerTest {
|
||||
@Test
|
||||
void testReserveUsernameOptimisticLockingFailure() throws UsernameHashNotAvailableException {
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final List<byte[]> usernameHashes = List.of(TestRandomUtil.nextBytes(32), TestRandomUtil.nextBytes(32));
|
||||
|
||||
@@ -1190,7 +1190,7 @@ class AccountsManagerTest {
|
||||
void testConfirmReservedUsernameHashOptimisticLockingFailure() throws UsernameHashNotAvailableException, UsernameReservationNotFoundException {
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
setReservationHash(account, USERNAME_HASH_1);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
doThrow(new ContestedOptimisticLockException())
|
||||
.doNothing()
|
||||
@@ -1275,7 +1275,7 @@ class AccountsManagerTest {
|
||||
final Account account = AccountsHelper.generateTestAccount("+14152222222", List.of(primaryDevice, linkedDevice));
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> accountsManager.waitForNewLinkedDevice(account.getUuid(), linkedDevice, "", Duration.ofSeconds(1)));
|
||||
() -> accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(), linkedDevice, "", Duration.ofSeconds(1)));
|
||||
|
||||
}
|
||||
|
||||
@@ -1292,9 +1292,9 @@ class AccountsManagerTest {
|
||||
UUID.fromString("111111-1111-1111-1111-111111111111")).orElseThrow();
|
||||
|
||||
final String serialized = AccountsManager.writeRedisAccountJson(originalAccount);
|
||||
final Account parsedAccount = AccountsManager.parseAccountJson(serialized, originalAccount.getUuid()).orElseThrow();
|
||||
final Account parsedAccount = AccountsManager.parseAccountJson(serialized, originalAccount.getAccountIdentifier()).orElseThrow();
|
||||
|
||||
assertEquals(originalAccount.getUuid(), parsedAccount.getUuid());
|
||||
assertEquals(originalAccount.getAccountIdentifier(), parsedAccount.getAccountIdentifier());
|
||||
assertEquals(originalAccount.getPhoneNumberIdentifier(), parsedAccount.getPhoneNumberIdentifier());
|
||||
assertEquals(originalAccount.getIdentityKey(IdentityType.ACI), parsedAccount.getIdentityKey(IdentityType.ACI));
|
||||
assertEquals(originalAccount.getIdentityKey(IdentityType.PNI), parsedAccount.getIdentityKey(IdentityType.PNI));
|
||||
|
||||
+8
-8
@@ -180,7 +180,7 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
() -> accountsManager.reserveUsernameHash(account.getIdentifier(IdentityType.ACI), usernameHashes));
|
||||
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,16 +227,16 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
reservation.reservedUsernameHash(),
|
||||
ENCRYPTED_USERNAME_1);
|
||||
assertArrayEquals(account.getUsernameHash().orElseThrow(), USERNAME_HASH_1);
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid()).isEqualTo(
|
||||
account.getUuid());
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier()).isEqualTo(
|
||||
account.getAccountIdentifier());
|
||||
assertThat(account.getUsernameLinkHandle()).isNotNull();
|
||||
assertThat(accountsManager.getByUsernameLinkHandle(account.getUsernameLinkHandle()).join().orElseThrow().getUuid())
|
||||
.isEqualTo(account.getUuid());
|
||||
assertThat(accountsManager.getByUsernameLinkHandle(account.getUsernameLinkHandle()).join().orElseThrow().getAccountIdentifier())
|
||||
.isEqualTo(account.getAccountIdentifier());
|
||||
|
||||
// clear
|
||||
account = accountsManager.clearUsernameHash(account.getIdentifier(IdentityType.ACI));
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,7 +256,7 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
// clear
|
||||
account = accountsManager.clearUsernameHash(account.getIdentifier(IdentityType.ACI));
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
|
||||
assertThat(accountsManager.getByUsernameHash(reservation.reservedUsernameHash()).join()).isEmpty();
|
||||
|
||||
@@ -294,7 +294,7 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
() -> accountsManager.confirmReservedUsernameHash(reservation1.account().getIdentifier(IdentityType.ACI), USERNAME_HASH_1, ENCRYPTED_USERNAME_1));
|
||||
account2 = accountsManager.confirmReservedUsernameHash(reservation2.account().getIdentifier(IdentityType.ACI), USERNAME_HASH_1, ENCRYPTED_USERNAME_1);
|
||||
assertEquals(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid(), account2.getUuid());
|
||||
assertEquals(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier(), account2.getAccountIdentifier());
|
||||
assertArrayEquals(account2.getUsernameHash().orElseThrow(), USERNAME_HASH_1);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class AccountsTest {
|
||||
final BiConsumer<Optional<Account>, byte[]> validator = (maybeAccount, expectedEncryptedUsername) -> {
|
||||
assertTrue(maybeAccount.isPresent());
|
||||
assertTrue(maybeAccount.get().getEncryptedUsername().isPresent());
|
||||
assertEquals(account.getUuid(), maybeAccount.get().getUuid());
|
||||
assertEquals(account.getAccountIdentifier(), maybeAccount.get().getAccountIdentifier());
|
||||
assertArrayEquals(expectedEncryptedUsername, maybeAccount.get().getEncryptedUsername().get());
|
||||
};
|
||||
|
||||
@@ -189,17 +189,17 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
freshUser = createAccount(account);
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,20 +212,20 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
accounts.delete(originalUuid, Collections.emptyList());
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(account.getPhoneNumberIdentifier())).hasValue(originalUuid);
|
||||
|
||||
freshUser = createAccount(account);
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(account.getPhoneNumberIdentifier())).isEmpty();
|
||||
}
|
||||
@@ -237,10 +237,10 @@ class AccountsTest {
|
||||
|
||||
createAccount(account);
|
||||
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -251,10 +251,10 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
account.setNumber("+14153334444", UUID.randomUUID());
|
||||
assertThrows(IllegalArgumentException.class, () -> createAccount(account),
|
||||
@@ -269,10 +269,10 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account1);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account1.getUuid(), account1.getPhoneNumberIdentifier(), null, account1, true);
|
||||
verifyStoredState("+14151112222", account1.getAccountIdentifier(), account1.getPhoneNumberIdentifier(), null, account1, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account1.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account1.getPhoneNumberIdentifier(), account1.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account1.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account1.getPhoneNumberIdentifier(), account1.getAccountIdentifier());
|
||||
|
||||
Device device2 = generateDevice(DEVICE_ID_1);
|
||||
Account account2 = generateAccount("+14151112222", UUID.randomUUID(), account1.getPhoneNumberIdentifier(),
|
||||
@@ -399,7 +399,7 @@ class AccountsTest {
|
||||
assertThrows(AccountAlreadyExistsException.class,
|
||||
() -> accounts.create(reregisteredAccount, Collections.emptyList()));
|
||||
|
||||
reregisteredAccount.setUuid(accountAlreadyExistsException.getExistingAccount().getUuid());
|
||||
reregisteredAccount.setAccountIdentifier(accountAlreadyExistsException.getExistingAccount().getAccountIdentifier());
|
||||
|
||||
// Phone number canonicalization means that a user can re-register with a different phone number
|
||||
// in the same equivalence class and get back the same phone number identifier.
|
||||
@@ -459,7 +459,7 @@ class AccountsTest {
|
||||
accounts.confirmUsernameHash(existingAccount, usernameHash, encryptedUsername);
|
||||
final UUID usernameLinkHandle = existingAccount.getUsernameLinkHandle();
|
||||
|
||||
verifyStoredState(e164, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), usernameHash, existingAccount, true);
|
||||
verifyStoredState(e164, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), usernameHash, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(e164, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(existingPni, existingUuid);
|
||||
@@ -516,7 +516,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(firstNumber, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(firstNumber, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(firstNumber, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(pni, existingUuid);
|
||||
@@ -560,7 +560,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(beninPhoneNumber, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(pni, existingUuid);
|
||||
@@ -578,7 +578,7 @@ class AccountsTest {
|
||||
assertThrows(AccountAlreadyExistsException.class,
|
||||
() -> accounts.create(secondAccount, Collections.emptyList()));
|
||||
|
||||
secondAccount.setUuid(accountAlreadyExistsException.getExistingAccount().getUuid());
|
||||
secondAccount.setAccountIdentifier(accountAlreadyExistsException.getExistingAccount().getAccountIdentifier());
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> accounts.reclaimAccount(existingAccount,
|
||||
secondAccount,
|
||||
@@ -595,7 +595,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(beninPhoneNumber, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(existingPni, existingUuid);
|
||||
@@ -626,7 +626,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(newFormatBeninE164, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(newFormatBeninE164, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(newFormatBeninE164, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(existingPni, existingUuid);
|
||||
@@ -652,25 +652,25 @@ class AccountsTest {
|
||||
|
||||
createAccount(account);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
device.setName("foobar".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
accounts.update(account);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
Optional<Account> retrieved = accounts.getByE164("+14151112222");
|
||||
|
||||
assertThat(retrieved.isPresent()).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
|
||||
retrieved = accounts.getByAccountIdentifier(account.getUuid());
|
||||
retrieved = accounts.getByAccountIdentifier(account.getAccountIdentifier());
|
||||
|
||||
assertThat(retrieved.isPresent()).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
device = generateDevice(DEVICE_ID_1);
|
||||
Account unknownAccount = generateAccount("+14151113333", UUID.randomUUID(), UUID.randomUUID(), List.of(device));
|
||||
@@ -681,7 +681,7 @@ class AccountsTest {
|
||||
|
||||
assertThat(account.getVersion()).isEqualTo(2);
|
||||
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
account.setVersion(1);
|
||||
|
||||
@@ -691,7 +691,7 @@ class AccountsTest {
|
||||
|
||||
accounts.update(account);
|
||||
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -725,7 +725,7 @@ class AccountsTest {
|
||||
final byte[] deviceName = "device-name".getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
assertNotEquals(deviceName,
|
||||
accounts.getByAccountIdentifier(account.getUuid()).orElseThrow().getPrimaryDevice().getName());
|
||||
accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getPrimaryDevice().getName());
|
||||
|
||||
assertFalse(DYNAMO_DB_EXTENSION.getDynamoDbClient().getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.CLIENT_RELEASES.tableName())
|
||||
@@ -749,7 +749,7 @@ class AccountsTest {
|
||||
.build()));
|
||||
|
||||
assertArrayEquals(deviceName,
|
||||
accounts.getByAccountIdentifier(account.getUuid()).orElseThrow().getPrimaryDevice().getName());
|
||||
accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getPrimaryDevice().getName());
|
||||
|
||||
assertTrue(DYNAMO_DB_EXTENSION.getDynamoDbClient().getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.CLIENT_RELEASES.tableName())
|
||||
@@ -822,8 +822,8 @@ class AccountsTest {
|
||||
accounts.getAll(2, Schedulers.parallel()).collectList().block();
|
||||
|
||||
assertNotNull(retrievedAccounts);
|
||||
assertEquals(expectedAccounts.stream().map(Account::getUuid).collect(Collectors.toSet()),
|
||||
retrievedAccounts.stream().map(Account::getUuid).collect(Collectors.toSet()));
|
||||
assertEquals(expectedAccounts.stream().map(Account::getAccountIdentifier).collect(Collectors.toSet()),
|
||||
retrievedAccounts.stream().map(Account::getAccountIdentifier).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -856,24 +856,24 @@ class AccountsTest {
|
||||
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(deletedAccount.getPhoneNumberIdentifier())).isEmpty();
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", deletedAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(deletedAccount.getPhoneNumberIdentifier(), deletedAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112345", retainedAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(retainedAccount.getPhoneNumberIdentifier(), retainedAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", deletedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(deletedAccount.getPhoneNumberIdentifier(), deletedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberConstraintExists("+14151112345", retainedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(retainedAccount.getPhoneNumberIdentifier(), retainedAccount.getAccountIdentifier());
|
||||
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifier(retainedAccount.getUuid())).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getAccountIdentifier())).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifier(retainedAccount.getAccountIdentifier())).isPresent();
|
||||
|
||||
accounts.delete(deletedAccount.getUuid(), Collections.emptyList());
|
||||
accounts.delete(deletedAccount.getAccountIdentifier(), Collections.emptyList());
|
||||
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isNotPresent();
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(deletedAccount.getPhoneNumberIdentifier())).hasValue(deletedAccount.getUuid());
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getAccountIdentifier())).isNotPresent();
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(deletedAccount.getPhoneNumberIdentifier())).hasValue(deletedAccount.getAccountIdentifier());
|
||||
|
||||
assertPhoneNumberConstraintDoesNotExist(deletedAccount.getNumber());
|
||||
assertPhoneNumberIdentifierConstraintDoesNotExist(deletedAccount.getPhoneNumberIdentifier());
|
||||
|
||||
verifyStoredState(retainedAccount.getNumber(), retainedAccount.getUuid(), retainedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(retainedAccount.getUuid()).orElseThrow(), retainedAccount);
|
||||
verifyStoredState(retainedAccount.getNumber(), retainedAccount.getAccountIdentifier(), retainedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(retainedAccount.getAccountIdentifier()).orElseThrow(), retainedAccount);
|
||||
|
||||
{
|
||||
final Account recreatedAccount = generateAccount(deletedAccount.getNumber(), UUID.randomUUID(),
|
||||
@@ -882,12 +882,12 @@ class AccountsTest {
|
||||
final boolean freshUser = createAccount(recreatedAccount);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
assertThat(accounts.getByAccountIdentifier(recreatedAccount.getUuid())).isPresent();
|
||||
verifyStoredState(recreatedAccount.getNumber(), recreatedAccount.getUuid(), recreatedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(recreatedAccount.getUuid()).orElseThrow(), recreatedAccount);
|
||||
assertThat(accounts.getByAccountIdentifier(recreatedAccount.getAccountIdentifier())).isPresent();
|
||||
verifyStoredState(recreatedAccount.getNumber(), recreatedAccount.getAccountIdentifier(), recreatedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(recreatedAccount.getAccountIdentifier()).orElseThrow(), recreatedAccount);
|
||||
|
||||
assertPhoneNumberConstraintExists(recreatedAccount.getNumber(), recreatedAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(recreatedAccount.getPhoneNumberIdentifier(), recreatedAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists(recreatedAccount.getNumber(), recreatedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(recreatedAccount.getPhoneNumberIdentifier(), recreatedAccount.getAccountIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(account);
|
||||
|
||||
assertThat(accounts.getByAccountIdentifierAsync(account.getUuid()).join()).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifierAsync(account.getAccountIdentifier()).join()).isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -949,13 +949,13 @@ class AccountsTest {
|
||||
Account account = generateAccount("+14151112222", UUID.randomUUID(), UUID.randomUUID(), List.of(device));
|
||||
account.setDiscoverableByPhoneNumber(false);
|
||||
createAccount(account);
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
account.setDiscoverableByPhoneNumber(true);
|
||||
accounts.update(account);
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
account.setDiscoverableByPhoneNumber(false);
|
||||
accounts.update(account);
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
@@ -975,14 +975,14 @@ class AccountsTest {
|
||||
|
||||
assertThat(accounts.getByPhoneNumberIdentifier(originalPni)).isPresent();
|
||||
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getUuid());
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getAccountIdentifier());
|
||||
|
||||
{
|
||||
final Optional<Account> retrieved = accounts.getByE164(originalNumber);
|
||||
assertThat(retrieved).isPresent();
|
||||
|
||||
verifyStoredState(originalNumber, account.getUuid(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
verifyStoredState(originalNumber, account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
}
|
||||
|
||||
accounts.changeNumber(account, targetNumber, targetPni, maybeDisplacedAccountIdentifier, Collections.emptyList());
|
||||
@@ -992,14 +992,14 @@ class AccountsTest {
|
||||
|
||||
assertPhoneNumberConstraintDoesNotExist(originalNumber);
|
||||
assertPhoneNumberIdentifierConstraintDoesNotExist(originalPni);
|
||||
assertPhoneNumberConstraintExists(targetNumber, account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, account.getUuid());
|
||||
assertPhoneNumberConstraintExists(targetNumber, account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, account.getAccountIdentifier());
|
||||
|
||||
{
|
||||
final Optional<Account> retrieved = accounts.getByE164(targetNumber);
|
||||
assertThat(retrieved).isPresent();
|
||||
|
||||
verifyStoredState(targetNumber, account.getUuid(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
verifyStoredState(targetNumber, account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
|
||||
assertThat(retrieved.get().getPhoneNumberIdentifier()).isEqualTo(targetPni);
|
||||
assertThat(accounts.getByPhoneNumberIdentifier(targetPni)).isPresent();
|
||||
@@ -1032,12 +1032,12 @@ class AccountsTest {
|
||||
createAccount(account);
|
||||
createAccount(existingAccount);
|
||||
|
||||
assertThrows(TransactionCanceledException.class, () -> accounts.changeNumber(account, targetNumber, targetPni, Optional.of(existingAccount.getUuid()), Collections.emptyList()));
|
||||
assertThrows(TransactionCanceledException.class, () -> accounts.changeNumber(account, targetNumber, targetPni, Optional.of(existingAccount.getAccountIdentifier()), Collections.emptyList()));
|
||||
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getUuid());
|
||||
assertPhoneNumberConstraintExists(targetNumber, existingAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, existingAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getAccountIdentifier());
|
||||
assertPhoneNumberConstraintExists(targetNumber, existingAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, existingAccount.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1085,7 +1085,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(firstAccountInstance);
|
||||
|
||||
final Account secondAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getUuid()).orElseThrow();
|
||||
final Account secondAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getAccountIdentifier()).orElseThrow();
|
||||
|
||||
// update via the first instance, which will update the version
|
||||
firstAccountInstance.setCurrentProfileVersion(new byte[32]);
|
||||
@@ -1095,15 +1095,15 @@ class AccountsTest {
|
||||
() -> accounts.changeNumber(secondAccountInstance, targetNumber, targetPni, Optional.empty(),
|
||||
Collections.emptyList()), "Second account instance has stale version");
|
||||
|
||||
final Account refreshedAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getUuid())
|
||||
final Account refreshedAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getAccountIdentifier())
|
||||
.orElseThrow();
|
||||
accounts.changeNumber(refreshedAccountInstance, targetNumber, targetPni, Optional.empty(),
|
||||
Collections.emptyList());
|
||||
|
||||
assertPhoneNumberConstraintDoesNotExist(originalNumber);
|
||||
assertPhoneNumberIdentifierConstraintDoesNotExist(originalPni);
|
||||
assertPhoneNumberConstraintExists(targetNumber, firstAccountInstance.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, firstAccountInstance.getUuid());
|
||||
assertPhoneNumberConstraintExists(targetNumber, firstAccountInstance.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, firstAccountInstance.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1119,10 +1119,10 @@ class AccountsTest {
|
||||
|
||||
{
|
||||
final Optional<Account> maybeAccount = accounts.getByUsernameHash(USERNAME_HASH_1).join();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.orElseThrow(), account);
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.orElseThrow(), account);
|
||||
|
||||
final Optional<Account> maybeAccount2 = accounts.getByUsernameLinkHandle(oldHandle).join();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount2.orElseThrow(), account);
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount2.orElseThrow(), account);
|
||||
}
|
||||
|
||||
accounts.reserveUsernameHash(account, USERNAME_HASH_2, Duration.ofDays(1));
|
||||
@@ -1133,7 +1133,7 @@ class AccountsTest {
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(getUsernameConstraintTableItem(USERNAME_HASH_1)).containsExactlyInAnyOrderEntriesOf(Map.of(
|
||||
Accounts.UsernameTable.KEY_USERNAME_HASH, AttributeValues.b(USERNAME_HASH_1),
|
||||
Accounts.UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.b(account.getUuid()),
|
||||
Accounts.UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.b(account.getAccountIdentifier()),
|
||||
Accounts.UsernameTable.ATTR_CONFIRMED, AttributeValues.fromBool(false),
|
||||
Accounts.UsernameTable.ATTR_TTL,
|
||||
AttributeValues.n(clock.instant().plus(Accounts.USERNAME_HOLD_DURATION).getEpochSecond())));
|
||||
@@ -1143,10 +1143,10 @@ class AccountsTest {
|
||||
final Optional<Account> maybeAccount = accounts.getByUsernameHash(USERNAME_HASH_2).join();
|
||||
|
||||
assertThat(maybeAccount).isPresent();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(),
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(),
|
||||
USERNAME_HASH_2, maybeAccount.orElseThrow(), account);
|
||||
final Optional<Account> maybeAccount2 = accounts.getByUsernameLinkHandle(newHandle).join();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(),
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(),
|
||||
USERNAME_HASH_2, maybeAccount2.orElseThrow(), account);
|
||||
}
|
||||
}
|
||||
@@ -1168,7 +1168,7 @@ class AccountsTest {
|
||||
final Optional<Account> maybeAccount = accounts.getByUsernameHash(USERNAME_HASH_1).join();
|
||||
|
||||
assertThat(maybeAccount).isPresent();
|
||||
verifyStoredState(firstAccount.getNumber(), firstAccount.getUuid(), firstAccount.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.get(), firstAccount);
|
||||
verifyStoredState(firstAccount.getNumber(), firstAccount.getAccountIdentifier(), firstAccount.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.get(), firstAccount);
|
||||
|
||||
// throw an error if second account tries to reserve or confirm the same username hash
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
@@ -1305,7 +1305,7 @@ class AccountsTest {
|
||||
accounts.clearUsernameHash(account);
|
||||
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(accounts.getByAccountIdentifier(account.getUuid()))
|
||||
assertThat(accounts.getByAccountIdentifier(account.getAccountIdentifier()))
|
||||
.hasValueSatisfying(clearedAccount -> {
|
||||
assertThat(clearedAccount.getUsernameHash()).isEmpty();
|
||||
assertThat(clearedAccount.getUsernameLinkHandle()).isNull();
|
||||
@@ -1411,7 +1411,7 @@ class AccountsTest {
|
||||
accounts.confirmUsernameHash(account1, USERNAME_HASH_1, ENCRYPTED_USERNAME_1);
|
||||
assertThat(account1.getReservedUsernameHash()).isEmpty();
|
||||
assertArrayEquals(USERNAME_HASH_1, account1.getUsernameHash().orElseThrow());
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid()).isEqualTo(account1.getUuid());
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier()).isEqualTo(account1.getAccountIdentifier());
|
||||
|
||||
final Map<String, AttributeValue> usernameConstraintRecord = getUsernameConstraintTableItem(USERNAME_HASH_1);
|
||||
|
||||
@@ -1518,7 +1518,7 @@ class AccountsTest {
|
||||
() -> accounts.reserveUsernameHash(account1, USERNAME_HASH_1, Duration.ofDays(2)));
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
() -> accounts.confirmUsernameHash(account1, USERNAME_HASH_1, ENCRYPTED_USERNAME_1));
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid()).isEqualTo(account2.getUuid());
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier()).isEqualTo(account2.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1552,7 +1552,7 @@ class AccountsTest {
|
||||
accounts.confirmUsernameHash(account, username, ENCRYPTED_USERNAME_1);
|
||||
assertThat(accounts.getByUsernameHash(username).join()).isPresent();
|
||||
|
||||
final Account read = accounts.getByAccountIdentifier(account.getUuid()).orElseThrow();
|
||||
final Account read = accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow();
|
||||
assertThat(read.getUsernameHolds().stream().map(Account.UsernameHold::usernameHash).toList())
|
||||
.containsExactlyElementsOf(expectedHolds);
|
||||
|
||||
@@ -1751,7 +1751,7 @@ class AccountsTest {
|
||||
final Map<String, AttributeValue> accountRecord = DYNAMO_DB_EXTENSION.getDynamoDbClient()
|
||||
.getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.ACCOUNTS.tableName())
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.build())
|
||||
.item();
|
||||
final Map<?, ?> dataMap = SystemMapper.jsonMapper()
|
||||
@@ -1785,7 +1785,7 @@ class AccountsTest {
|
||||
|
||||
final GetItemResponse response = DYNAMO_DB_EXTENSION.getDynamoDbAsyncClient().getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.ACCOUNTS.tableName())
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.build()).join();
|
||||
|
||||
final Map<?, ?> accountData = SystemMapper.jsonMapper()
|
||||
@@ -1800,7 +1800,7 @@ class AccountsTest {
|
||||
|
||||
DYNAMO_DB_EXTENSION.getDynamoDbAsyncClient().updateItem(UpdateItemRequest.builder()
|
||||
.tableName(Tables.ACCOUNTS.tableName())
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.updateExpression("SET #data = :data")
|
||||
.expressionAttributeNames(Map.of("#data", Accounts.ATTR_ACCOUNT_DATA))
|
||||
.expressionAttributeValues(
|
||||
@@ -1808,7 +1808,7 @@ class AccountsTest {
|
||||
.build()).join();
|
||||
|
||||
final CompletionException e = assertThrows(CompletionException.class,
|
||||
() -> accounts.getByAccountIdentifierAsync(account.getUuid()).join());
|
||||
() -> accounts.getByAccountIdentifierAsync(account.getAccountIdentifier()).join());
|
||||
|
||||
Throwable cause = e.getCause();
|
||||
while (cause.getCause() != null) {
|
||||
@@ -1944,7 +1944,7 @@ class AccountsTest {
|
||||
}
|
||||
|
||||
final Map<String, AttributeValue> item = new HashMap<>(Map.of(
|
||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier()),
|
||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
||||
Accounts.ATTR_PNI_UUID, AttributeValues.fromUUID(account.getPhoneNumberIdentifier()),
|
||||
Accounts.ATTR_ACCOUNT_DATA, accountData,
|
||||
@@ -2125,7 +2125,7 @@ class AccountsTest {
|
||||
assertThat(result.getNumber()).isEqualTo(number);
|
||||
assertThat(result.getPhoneNumberIdentifier()).isEqualTo(pni);
|
||||
assertThat(result.getLastSeen()).isEqualTo(expecting.getLastSeen());
|
||||
assertThat(result.getUuid()).isEqualTo(uuid);
|
||||
assertThat(result.getAccountIdentifier()).isEqualTo(uuid);
|
||||
assertThat(result.getVersion()).isEqualTo(expecting.getVersion());
|
||||
assertArrayEquals(result.getUsernameHash().orElse(null), usernameHash);
|
||||
assertArrayEquals(expecting.getUnidentifiedAccessKey().orElseThrow(), result.getUnidentifiedAccessKey().orElseThrow());
|
||||
|
||||
+27
-27
@@ -179,7 +179,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final Pair<Account, Device> updatedAccountAndDevice =
|
||||
accountsManager.addDevice(account.getIdentifier(IdentityType.ACI), new DeviceSpec(
|
||||
@@ -201,17 +201,17 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
assertEquals(2, updatedAccountAndDevice.first().getDevices().size());
|
||||
|
||||
assertEquals(2,
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getUuid()).orElseThrow().getDevices()
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getAccountIdentifier()).orElseThrow().getDevices()
|
||||
.size());
|
||||
|
||||
final byte addedDeviceId = updatedAccountAndDevice.second().getId();
|
||||
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(updatedAccountAndDevice.first().getUuid(), addedDeviceId).join().isPresent());
|
||||
keysManager.getEcSignedPreKey(updatedAccountAndDevice.first().getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(updatedAccountAndDevice.first().getPhoneNumberIdentifier(), addedDeviceId).join()
|
||||
.isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccountAndDevice.first().getUuid(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccountAndDevice.first().getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(updatedAccountAndDevice.first().getPhoneNumberIdentifier(), addedDeviceId).join()
|
||||
.isPresent());
|
||||
@@ -227,7 +227,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final String linkDeviceToken = accountsManager.generateLinkDeviceToken(account.getIdentifier(IdentityType.ACI));
|
||||
|
||||
@@ -249,7 +249,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
linkDeviceToken);
|
||||
|
||||
assertEquals(2,
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getUuid()).orElseThrow().getDevices()
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getAccountIdentifier()).orElseThrow().getDevices()
|
||||
.size());
|
||||
|
||||
assertThrows(LinkDeviceTokenAlreadyUsedException.class,
|
||||
@@ -270,7 +270,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
linkDeviceToken));
|
||||
|
||||
assertEquals(2,
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getUuid()).orElseThrow().getDevices()
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getAccountIdentifier()).orElseThrow().getDevices()
|
||||
.size());
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final Pair<Account, Device> updatedAccountAndDevice =
|
||||
accountsManager.addDevice(account.getIdentifier(IdentityType.ACI), new DeviceSpec(
|
||||
@@ -309,16 +309,16 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
|
||||
assertEquals(1, updatedAccount.getDevices().size());
|
||||
|
||||
assertFalse(keysManager.getEcSignedPreKey(updatedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(updatedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertFalse(
|
||||
keysManager.getEcSignedPreKey(updatedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(updatedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(updatedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(updatedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
|
||||
assertTrue(keysManager.getEcSignedPreKey(updatedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(updatedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(updatedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(updatedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final UUID aci = account.getIdentifier(IdentityType.ACI);
|
||||
|
||||
@@ -366,17 +366,17 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
|
||||
assertEquals(2, retrievedAccount.getDevices().size());
|
||||
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(retrievedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(retrievedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join()
|
||||
.isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(retrievedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
}
|
||||
@@ -396,13 +396,13 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final String linkDeviceTokenIdentifier = AccountsManager.getLinkDeviceTokenIdentifier(linkDeviceToken);
|
||||
|
||||
final CompletableFuture<Optional<DeviceInfo>> displacedFuture = accountsManager.waitForNewLinkedDevice(
|
||||
account.getUuid(), account.getPrimaryDevice(),
|
||||
account.getAccountIdentifier(), account.getPrimaryDevice(),
|
||||
linkDeviceTokenIdentifier, Duration.ofSeconds(5));
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.empty()));
|
||||
final CompletableFuture<Optional<DeviceInfo>> activeFuture =
|
||||
accountsManager.waitForNewLinkedDevice(account.getUuid(), account.getPrimaryDevice(), linkDeviceTokenIdentifier,
|
||||
accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(), account.getPrimaryDevice(), linkDeviceTokenIdentifier,
|
||||
Duration.ofSeconds(5));
|
||||
|
||||
assertEquals(Optional.empty(), displacedFuture.join());
|
||||
@@ -465,11 +465,11 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
KeysHelper.signedKEMPreKey(4, pniKeyPair)),
|
||||
linkDeviceToken);
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.empty()));
|
||||
|
||||
final CompletableFuture<Optional<DeviceInfo>> linkedDeviceFuture = accountsManager.waitForNewLinkedDevice(
|
||||
account.getUuid(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMinutes(1));
|
||||
account.getAccountIdentifier(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMinutes(1));
|
||||
|
||||
final Optional<DeviceInfo> maybeDeviceInfo = linkedDeviceFuture.join();
|
||||
|
||||
@@ -492,7 +492,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final String linkDeviceTokenIdentifier = AccountsManager.getLinkDeviceTokenIdentifier(linkDeviceToken);
|
||||
|
||||
final CompletableFuture<Optional<DeviceInfo>> linkedDeviceFuture = accountsManager.waitForNewLinkedDevice(
|
||||
account.getUuid(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMillis(1));
|
||||
account.getAccountIdentifier(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMillis(1));
|
||||
|
||||
final Optional<DeviceInfo> maybeDeviceInfo = linkedDeviceFuture.join();
|
||||
|
||||
@@ -534,12 +534,12 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
KeysHelper.signedKEMPreKey(4, pniKeyPair)),
|
||||
linkDeviceToken);
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.ofNullable(oldestMessage).map(Instant::ofEpochMilli)));
|
||||
|
||||
clock.pin(Instant.ofEpochMilli(currentTime));
|
||||
Duration timeout = shouldWait ? Duration.ofMillis(5) : Duration.ofMillis(1000);
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getUuid(),
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(),
|
||||
account.getPrimaryDevice(), linkDeviceTokenIdentifier, timeout).join();
|
||||
assertEquals(result.isEmpty(), shouldWait);
|
||||
}
|
||||
@@ -577,7 +577,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
KeysHelper.signedKEMPreKey(4, pniKeyPair)),
|
||||
linkDeviceToken);
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
// Has a message older than the message epoch
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(Instant.ofEpochMilli(1000))))
|
||||
// The message was fetched
|
||||
@@ -588,7 +588,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
x.getArgument(0, Runnable.class).run();
|
||||
return null;
|
||||
});
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getUuid(),
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(),
|
||||
account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofSeconds(10)).join();
|
||||
assertTrue(result.isPresent());
|
||||
}
|
||||
|
||||
+6
-6
@@ -127,7 +127,7 @@ class MessagePersisterIntegrationTest {
|
||||
final UUID accountUuid = UUID.randomUUID();
|
||||
|
||||
when(account.getNumber()).thenReturn("+18005551234");
|
||||
when(account.getUuid()).thenReturn(accountUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountUuid);
|
||||
when(accountsManager.getByAccountIdentifier(accountUuid)).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifierAsync(accountUuid)).thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(DevicesHelper.createDevice(Device.PRIMARY_ID)));
|
||||
@@ -166,13 +166,13 @@ class MessagePersisterIntegrationTest {
|
||||
|
||||
final MessageProtos.Envelope message = generateRandomMessage(messageGuid, timestamp, false);
|
||||
|
||||
messagesCache.insert(messageGuid, account.getUuid(), Device.PRIMARY_ID, message).join();
|
||||
messagesCache.insert(messageGuid, account.getAccountIdentifier(), Device.PRIMARY_ID, message).join();
|
||||
expectedMessages.add(message);
|
||||
}
|
||||
|
||||
final CountDownLatch messagesPersistedLatch = new CountDownLatch(1);
|
||||
|
||||
redisMessageAvailabilityManager.handleClientConnected(account.getUuid(), Device.PRIMARY_ID,
|
||||
redisMessageAvailabilityManager.handleClientConnected(account.getAccountIdentifier(), Device.PRIMARY_ID,
|
||||
new MessageAvailabilityListener() {
|
||||
@Override
|
||||
public void handleNewMessageAvailable() {
|
||||
@@ -226,7 +226,7 @@ class MessagePersisterIntegrationTest {
|
||||
|
||||
final MessageProtos.Envelope message = generateRandomMessage(messageGuid, timestamp, true);
|
||||
|
||||
messagesCache.insert(messageGuid, account.getUuid(), Device.PRIMARY_ID, message).join();
|
||||
messagesCache.insert(messageGuid, account.getAccountIdentifier(), Device.PRIMARY_ID, message).join();
|
||||
}
|
||||
|
||||
final List<MessageProtos.Envelope> expectedMessages = new ArrayList<>(persistableMessages);
|
||||
@@ -237,7 +237,7 @@ class MessagePersisterIntegrationTest {
|
||||
|
||||
final MessageProtos.Envelope message = generateRandomMessage(messageGuid, timestamp, false);
|
||||
|
||||
messagesCache.insert(messageGuid, account.getUuid(), Device.PRIMARY_ID, message).join();
|
||||
messagesCache.insert(messageGuid, account.getAccountIdentifier(), Device.PRIMARY_ID, message).join();
|
||||
expectedMessages.add(message);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ class MessagePersisterIntegrationTest {
|
||||
.toList();
|
||||
|
||||
assertEquals(expectedMessages, persistedMessages);
|
||||
assertFalse(messagesCache.hasMessagesAsync(account.getUuid(), Device.PRIMARY_ID).join());
|
||||
assertFalse(messagesCache.hasMessagesAsync(account.getAccountIdentifier(), Device.PRIMARY_ID).join());
|
||||
}
|
||||
|
||||
private MessageProtos.Envelope generateRandomMessage(final UUID messageGuid, final long serverTimestamp, final boolean ephemeral) {
|
||||
|
||||
+2
-2
@@ -118,7 +118,7 @@ class MessagePersisterTest {
|
||||
when(accountsManager.removeDevice(any(), anyByte()))
|
||||
.thenAnswer(invocation -> accountsManager.getByAccountIdentifier(invocation.getArgument(0)).orElseThrow());
|
||||
|
||||
when(destinationAccount.getUuid()).thenReturn(DESTINATION_ACCOUNT_UUID);
|
||||
when(destinationAccount.getAccountIdentifier()).thenReturn(DESTINATION_ACCOUNT_UUID);
|
||||
when(destinationAccount.getIdentifier(IdentityType.ACI)).thenReturn(DESTINATION_ACCOUNT_UUID);
|
||||
when(destinationAccount.getNumber()).thenReturn(DESTINATION_ACCOUNT_NUMBER);
|
||||
when(destinationAccount.getDevice(DESTINATION_DEVICE_ID)).thenReturn(Optional.of(DESTINATION_DEVICE));
|
||||
@@ -249,7 +249,7 @@ class MessagePersisterTest {
|
||||
when(accountsManager.getByAccountIdentifierAsync(accountUuid))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
|
||||
when(account.getUuid()).thenReturn(accountUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountUuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountUuid);
|
||||
when(account.getDevice(anyByte())).thenAnswer(invocation -> Optional.of(DevicesHelper.createDevice(invocation.getArgument(0))));
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class ReportMessageManagerTest {
|
||||
reporterUuid = UUID.randomUUID();
|
||||
|
||||
sourceAccount = mock(Account.class);
|
||||
when(sourceAccount.getUuid()).thenReturn(sourceAci);
|
||||
when(sourceAccount.getAccountIdentifier()).thenReturn(sourceAci);
|
||||
when(sourceAccount.getNumber()).thenReturn(sourceNumber);
|
||||
when(sourceAccount.getPhoneNumberIdentifier()).thenReturn(sourcePni);
|
||||
}
|
||||
|
||||
+6
-6
@@ -54,7 +54,7 @@ class AppleDeviceCheckManagerTest {
|
||||
void setupDeviceChecks() {
|
||||
clock.pin(Instant.now());
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
|
||||
final DeviceCheckManager deviceCheckManager = DeviceCheckTestUtil.appleDeviceCheckManager();
|
||||
appleDeviceChecks = new AppleDeviceChecks(DYNAMO_DB_EXTENSION.getDynamoDbClient(),
|
||||
@@ -112,7 +112,7 @@ class AppleDeviceCheckManagerTest {
|
||||
public void duplicateKeys() {
|
||||
assertThatNoException().isThrownBy(() -> registerAttestation(account));
|
||||
final Account duplicator = mock(Account.class);
|
||||
when(duplicator.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(duplicator.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
// Both accounts use the attestation keyId, the second registration should fail
|
||||
assertThatExceptionOfType(DuplicatePublicKeyException.class)
|
||||
@@ -124,7 +124,7 @@ class AppleDeviceCheckManagerTest {
|
||||
final String challenge =
|
||||
appleDeviceCheckManager.createChallenge(AppleDeviceCheckManager.ChallengeType.ATTEST, account);
|
||||
final String redisKey = AppleDeviceCheckManager.challengeKey(AppleDeviceCheckManager.ChallengeType.ATTEST,
|
||||
account.getUuid());
|
||||
account.getAccountIdentifier());
|
||||
|
||||
final String storedChallenge = CLUSTER_EXTENSION.getRedisCluster()
|
||||
.withCluster(cluster -> cluster.sync().get(redisKey));
|
||||
@@ -165,7 +165,7 @@ class AppleDeviceCheckManagerTest {
|
||||
// Rig redis to return our sample challenge for the assert
|
||||
final String assertChallengeKey = AppleDeviceCheckManager.challengeKey(
|
||||
AppleDeviceCheckManager.ChallengeType.ASSERT_BACKUP_REDEMPTION,
|
||||
account.getUuid());
|
||||
account.getAccountIdentifier());
|
||||
CLUSTER_EXTENSION.getRedisCluster().useCluster(cluster ->
|
||||
cluster.sync().set(assertChallengeKey, DeviceCheckTestUtil.SAMPLE_CHALLENGE));
|
||||
|
||||
@@ -196,7 +196,7 @@ class AppleDeviceCheckManagerTest {
|
||||
CLUSTER_EXTENSION.getRedisCluster().useCluster(cluster -> cluster.sync().set(
|
||||
AppleDeviceCheckManager.challengeKey(
|
||||
AppleDeviceCheckManager.ChallengeType.ASSERT_BACKUP_REDEMPTION,
|
||||
account.getUuid()),
|
||||
account.getAccountIdentifier()),
|
||||
DeviceCheckTestUtil.SAMPLE_CHALLENGE));
|
||||
|
||||
assertThatExceptionOfType(RequestReuseException.class).isThrownBy(() ->
|
||||
@@ -217,7 +217,7 @@ class AppleDeviceCheckManagerTest {
|
||||
throws DeviceCheckVerificationFailedException, ChallengeNotFoundException, TooManyKeysException, DuplicatePublicKeyException {
|
||||
final String attestChallengeKey = AppleDeviceCheckManager.challengeKey(
|
||||
AppleDeviceCheckManager.ChallengeType.ATTEST,
|
||||
account.getUuid());
|
||||
account.getAccountIdentifier());
|
||||
CLUSTER_EXTENSION.getRedisCluster().useCluster(cluster ->
|
||||
cluster.sync().set(attestChallengeKey, DeviceCheckTestUtil.SAMPLE_CHALLENGE));
|
||||
try (MockedStatic<Instant> mocked = mockStatic(Instant.class, Mockito.CALLS_REAL_METHODS)) {
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ class AppleDeviceChecksTest {
|
||||
@BeforeEach
|
||||
void setupDeviceChecks() {
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
deviceChecks = new AppleDeviceChecks(DYNAMO_DB_EXTENSION.getDynamoDbClient(),
|
||||
DeviceCheckManager.createObjectConverter(),
|
||||
DynamoDbExtensionSchema.Tables.APPLE_DEVICE_CHECKS.tableName(),
|
||||
@@ -78,7 +78,7 @@ class AppleDeviceChecksTest {
|
||||
final byte[] keyId = appleDevice.getAttestedCredentialData().getCredentialId();
|
||||
|
||||
final Account dupliateAccount = mock(Account.class);
|
||||
when(dupliateAccount.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(dupliateAccount.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
deviceChecks.storeAttestation(account, keyId, appleDevice);
|
||||
|
||||
|
||||
+4
-4
@@ -47,7 +47,7 @@ public class AccountsHelper {
|
||||
public static Account generateTestAccount(String number, UUID uuid, final UUID phoneNumberIdentifier, List<Device> devices, byte[] unidentifiedAccessKey) {
|
||||
final Account account = new Account();
|
||||
account.setNumber(number, phoneNumberIdentifier);
|
||||
account.setUuid(uuid);
|
||||
account.setAccountIdentifier(uuid);
|
||||
devices.forEach(account::addDevice);
|
||||
account.setUnidentifiedAccessKey(unidentifiedAccessKey);
|
||||
|
||||
@@ -160,9 +160,9 @@ public class AccountsHelper {
|
||||
}
|
||||
|
||||
public static void setupMockGet(final AccountsManager mockAccountsManager, final Account account) {
|
||||
if (account.getUuid() != null || account.getIdentifier(IdentityType.ACI) != null) {
|
||||
if (account.getAccountIdentifier() != null || account.getIdentifier(IdentityType.ACI) != null) {
|
||||
final UUID accountIdentifier =
|
||||
Objects.requireNonNullElseGet(account.getIdentifier(IdentityType.ACI), account::getUuid);
|
||||
Objects.requireNonNullElseGet(account.getIdentifier(IdentityType.ACI), account::getAccountIdentifier);
|
||||
|
||||
when(mockAccountsManager.getByAccountIdentifier(accountIdentifier))
|
||||
.thenReturn(Optional.of(account));
|
||||
@@ -219,7 +219,7 @@ public class AccountsHelper {
|
||||
|
||||
for (Stubbing stubbing : mockingDetails.getStubbings()) {
|
||||
switch (stubbing.getInvocation().getMethod().getName()) {
|
||||
case "getUuid" -> when(updatedAccount.getUuid()).thenAnswer(stubbing);
|
||||
case "getAccountIdentifier" -> when(updatedAccount.getAccountIdentifier()).thenAnswer(stubbing);
|
||||
case "getPhoneNumberIdentifier" -> when(updatedAccount.getPhoneNumberIdentifier()).thenAnswer(stubbing);
|
||||
case "getIdentifier" -> when(updatedAccount.getIdentifier(stubbing.getInvocation().getArgument(0))).thenAnswer(stubbing);
|
||||
case "isIdentifiedBy" -> when(updatedAccount.isIdentifiedBy(stubbing.getInvocation().getArgument(0))).thenAnswer(stubbing);
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public class AccountsTestHelper {
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = new Account();
|
||||
account.setUuid(aci);
|
||||
account.setAccountIdentifier(aci);
|
||||
account.setNumber(number, UUID.randomUUID());
|
||||
account.setUnrestrictedUnidentifiedAccess(unrestrictedUnidentifiedAccess);
|
||||
account.setDiscoverableByPhoneNumber(discoverableByPhoneNumber);
|
||||
|
||||
@@ -158,22 +158,22 @@ public class AuthHelper {
|
||||
when(VALID_ACCOUNT_3.getDevices()).thenReturn(List.of(VALID_DEVICE_3_PRIMARY, VALID_DEVICE_3_LINKED));
|
||||
|
||||
when(VALID_ACCOUNT.getNumber()).thenReturn(VALID_NUMBER);
|
||||
when(VALID_ACCOUNT.getUuid()).thenReturn(VALID_UUID);
|
||||
when(VALID_ACCOUNT.getAccountIdentifier()).thenReturn(VALID_UUID);
|
||||
when(VALID_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(VALID_PNI);
|
||||
when(VALID_ACCOUNT.getIdentifier(IdentityType.ACI)).thenReturn(VALID_UUID);
|
||||
when(VALID_ACCOUNT.getIdentifier(IdentityType.PNI)).thenReturn(VALID_PNI);
|
||||
when(VALID_ACCOUNT_TWO.getNumber()).thenReturn(VALID_NUMBER_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getUuid()).thenReturn(VALID_UUID_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getAccountIdentifier()).thenReturn(VALID_UUID_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getPhoneNumberIdentifier()).thenReturn(VALID_PNI_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getIdentifier(IdentityType.ACI)).thenReturn(VALID_UUID_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getIdentifier(IdentityType.PNI)).thenReturn(VALID_PNI_TWO);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getNumber()).thenReturn(UNDISCOVERABLE_NUMBER);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getUuid()).thenReturn(UNDISCOVERABLE_UUID);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getAccountIdentifier()).thenReturn(UNDISCOVERABLE_UUID);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(UNDISCOVERABLE_PNI);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getIdentifier(IdentityType.ACI)).thenReturn(UNDISCOVERABLE_UUID);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getIdentifier(IdentityType.PNI)).thenReturn(UNDISCOVERABLE_PNI);
|
||||
when(VALID_ACCOUNT_3.getNumber()).thenReturn(VALID_NUMBER_3);
|
||||
when(VALID_ACCOUNT_3.getUuid()).thenReturn(VALID_UUID_3);
|
||||
when(VALID_ACCOUNT_3.getAccountIdentifier()).thenReturn(VALID_UUID_3);
|
||||
when(VALID_ACCOUNT_3.getPhoneNumberIdentifier()).thenReturn(VALID_PNI_3);
|
||||
when(VALID_ACCOUNT_3.getIdentifier(IdentityType.ACI)).thenReturn(VALID_UUID_3);
|
||||
when(VALID_ACCOUNT_3.getIdentifier(IdentityType.PNI)).thenReturn(VALID_PNI_3);
|
||||
@@ -276,7 +276,7 @@ public class AuthHelper {
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
when(account.getNumber()).thenReturn(number);
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(accountsManager.getByE164(number)).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
|
||||
Reference in new issue
Block a user