Restore an accidentally-removed PNI consistency check
This commit is contained in:
parent
e5acdf1402
commit
71dd0890de
|
@ -292,6 +292,7 @@ public class AccountsManager {
|
||||||
|
|
||||||
final UUID uuid = account.getUuid();
|
final UUID uuid = account.getUuid();
|
||||||
final String originalNumber = account.getNumber();
|
final String originalNumber = account.getNumber();
|
||||||
|
final UUID originalPhoneNumberIdentifier = account.getPhoneNumberIdentifier();
|
||||||
|
|
||||||
updatedAccount = updateWithRetries(account,
|
updatedAccount = updateWithRetries(account,
|
||||||
updater,
|
updater,
|
||||||
|
@ -305,6 +306,13 @@ public class AccountsManager {
|
||||||
new RuntimeException());
|
new RuntimeException());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert updatedAccount.getPhoneNumberIdentifier().equals(originalPhoneNumberIdentifier);
|
||||||
|
|
||||||
|
if (!updatedAccount.getPhoneNumberIdentifier().equals(originalPhoneNumberIdentifier)) {
|
||||||
|
logger.error("Phone number identifier changed via \"normal\" update; PNIs must be changed via changeNumber method",
|
||||||
|
new RuntimeException());
|
||||||
|
}
|
||||||
|
|
||||||
redisSet(updatedAccount);
|
redisSet(updatedAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,18 +355,19 @@ class AccountsManagerTest {
|
||||||
@Test
|
@Test
|
||||||
void testUpdate_optimisticLockingFailure() {
|
void testUpdate_optimisticLockingFailure() {
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
Account account = new Account("+14152222222", uuid, UUID.randomUUID(), new HashSet<>(), new byte[16]);
|
UUID pni = UUID.randomUUID();
|
||||||
|
Account account = new Account("+14152222222", uuid, pni, new HashSet<>(), new byte[16]);
|
||||||
|
|
||||||
when(commands.get(eq("Account3::" + uuid))).thenReturn(null);
|
when(commands.get(eq("Account3::" + uuid))).thenReturn(null);
|
||||||
|
|
||||||
when(accounts.getByAccountIdentifier(uuid)).thenReturn(
|
when(accounts.getByAccountIdentifier(uuid)).thenReturn(
|
||||||
Optional.of(new Account("+14152222222", uuid, UUID.randomUUID(), new HashSet<>(), new byte[16])));
|
Optional.of(new Account("+14152222222", uuid, pni, new HashSet<>(), new byte[16])));
|
||||||
doThrow(ContestedOptimisticLockException.class)
|
doThrow(ContestedOptimisticLockException.class)
|
||||||
.doAnswer(ACCOUNT_UPDATE_ANSWER)
|
.doAnswer(ACCOUNT_UPDATE_ANSWER)
|
||||||
.when(accounts).update(any());
|
.when(accounts).update(any());
|
||||||
|
|
||||||
when(accounts.getByAccountIdentifier(uuid)).thenReturn(
|
when(accounts.getByAccountIdentifier(uuid)).thenReturn(
|
||||||
Optional.of(new Account("+14152222222", uuid, UUID.randomUUID(), new HashSet<>(), new byte[16])));
|
Optional.of(new Account("+14152222222", uuid, pni, new HashSet<>(), new byte[16])));
|
||||||
doThrow(ContestedOptimisticLockException.class)
|
doThrow(ContestedOptimisticLockException.class)
|
||||||
.doAnswer(ACCOUNT_UPDATE_ANSWER)
|
.doAnswer(ACCOUNT_UPDATE_ANSWER)
|
||||||
.when(accounts).update(any());
|
.when(accounts).update(any());
|
||||||
|
|
Loading…
Reference in New Issue