From 3c8b2a82a3b4f82dbe386a31b6fc493beae0679c Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Fri, 22 Nov 2024 15:43:00 -0500 Subject: [PATCH] Store registration recovery passwords by both E164 and PNI --- .../storage/RegistrationRecoveryPasswords.java | 5 ++--- .../storage/RegistrationRecoveryTest.java | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryPasswords.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryPasswords.java index 36c1a868d..927545194 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryPasswords.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryPasswords.java @@ -89,9 +89,8 @@ public class RegistrationRecoveryPasswords extends AbstractDynamoDbStore { return asyncClient.transactWriteItems(TransactWriteItemsRequest.builder() .transactItems( - buildPutRecoveryPasswordWriteItem(number, expirationSeconds, data.salt(), data.hash()) - // buildPutRecoveryPasswordWriteItem(phoneNumberIdentifier.toString(), expirationSeconds, data.salt(), data.hash()) - ) + buildPutRecoveryPasswordWriteItem(number, expirationSeconds, data.salt(), data.hash()), + buildPutRecoveryPasswordWriteItem(phoneNumberIdentifier.toString(), expirationSeconds, data.salt(), data.hash())) .build()) .thenRun(Util.NOOP); } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryTest.java index 8424db754..ce612eaa4 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/RegistrationRecoveryTest.java @@ -82,12 +82,12 @@ public class RegistrationRecoveryTest { assertEquals(ORIGINAL_HASH.hash(), saltedTokenHashByNumber.get().hash()); } - /* { + { final Optional saltedTokenHashByPni = registrationRecoveryPasswords.lookup(PNI).get(); assertTrue(saltedTokenHashByPni.isPresent()); assertEquals(ORIGINAL_HASH.salt(), saltedTokenHashByPni.get().salt()); assertEquals(ORIGINAL_HASH.hash(), saltedTokenHashByPni.get().hash()); - } */ + } } @Test @@ -107,12 +107,12 @@ public class RegistrationRecoveryTest { assertEquals(ORIGINAL_HASH.hash(), saltedTokenHashByNumber.get().hash()); } - /* { + { final Optional saltedTokenHashByPni = registrationRecoveryPasswords.lookup(PNI).get(); assertTrue(saltedTokenHashByPni.isPresent()); assertEquals(ORIGINAL_HASH.salt(), saltedTokenHashByPni.get().salt()); assertEquals(ORIGINAL_HASH.hash(), saltedTokenHashByPni.get().hash()); - } */ + } } @Test @@ -127,12 +127,12 @@ public class RegistrationRecoveryTest { assertEquals(ANOTHER_HASH.hash(), saltedTokenHashByNumber.get().hash()); } - /* { + { final Optional saltedTokenHashByPni = registrationRecoveryPasswords.lookup(PNI).get(); assertTrue(saltedTokenHashByPni.isPresent()); assertEquals(ANOTHER_HASH.salt(), saltedTokenHashByPni.get().salt()); assertEquals(ANOTHER_HASH.hash(), saltedTokenHashByPni.get().hash()); - } */ + } } @Test