mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 18:38:05 +01:00
Add a Dynamo-backed key store.
This commit is contained in:
committed by
Jon Chambers
parent
426e6923ac
commit
d4d9403829
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
|
||||
import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
|
||||
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
|
||||
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
|
||||
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
|
||||
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType;
|
||||
import org.whispersystems.textsecuregcm.tests.util.LocalDynamoDbRule;
|
||||
|
||||
public class KeysDynamoDbRule extends LocalDynamoDbRule {
|
||||
public static final String TABLE_NAME = "Signal_Keys_Test";
|
||||
|
||||
@Override
|
||||
protected void before() throws Throwable {
|
||||
super.before();
|
||||
|
||||
final DynamoDB dynamoDB = getDynamoDB();
|
||||
|
||||
final CreateTableRequest createTableRequest = new CreateTableRequest()
|
||||
.withTableName(TABLE_NAME)
|
||||
.withKeySchema(new KeySchemaElement(KeysDynamoDb.KEY_ACCOUNT_UUID, "HASH"),
|
||||
new KeySchemaElement(KeysDynamoDb.KEY_DEVICE_ID_KEY_ID, "RANGE"))
|
||||
.withAttributeDefinitions(new AttributeDefinition(KeysDynamoDb.KEY_ACCOUNT_UUID, ScalarAttributeType.B),
|
||||
new AttributeDefinition(KeysDynamoDb.KEY_DEVICE_ID_KEY_ID, ScalarAttributeType.B))
|
||||
.withProvisionedThroughput(new ProvisionedThroughput(20L, 20L));
|
||||
|
||||
dynamoDB.createTable(createTableRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void after() {
|
||||
super.after();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright 2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.textsecuregcm.entities.PreKey;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class KeysDynamoDbTest {
|
||||
|
||||
private Account account;
|
||||
private KeysDynamoDb keysDynamoDb;
|
||||
|
||||
@ClassRule
|
||||
public static KeysDynamoDbRule dynamoDbRule = new KeysDynamoDbRule();
|
||||
|
||||
private static final String ACCOUNT_NUMBER = "+18005551234";
|
||||
private static final long DEVICE_ID = 1L;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
keysDynamoDb = new KeysDynamoDb(dynamoDbRule.getDynamoDB(), KeysDynamoDbRule.TABLE_NAME);
|
||||
|
||||
account = mock(Account.class);
|
||||
when(account.getNumber()).thenReturn(ACCOUNT_NUMBER);
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStore() {
|
||||
assertEquals("Initial pre-key count for an account should be zero",
|
||||
0, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(new PreKey(1, "public-key")));
|
||||
assertEquals(1, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(new PreKey(1, "public-key")));
|
||||
assertEquals("Repeatedly storing same key should have no effect",
|
||||
1, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(new PreKey(2, "different-public-key")));
|
||||
assertEquals("Inserting a new key should overwrite all prior keys for the given account/device",
|
||||
1, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(new PreKey(3, "third-public-key"), new PreKey(4, "fourth-public-key")));
|
||||
assertEquals("Inserting multiple new keys should overwrite all prior keys for the given account/device",
|
||||
2, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTakeAccount() {
|
||||
final Device firstDevice = mock(Device.class);
|
||||
final Device secondDevice = mock(Device.class);
|
||||
|
||||
when(firstDevice.getId()).thenReturn(DEVICE_ID);
|
||||
when(secondDevice.getId()).thenReturn(DEVICE_ID + 1);
|
||||
when(account.getDevices()).thenReturn(Set.of(firstDevice, secondDevice));
|
||||
|
||||
assertEquals(Collections.emptyList(), keysDynamoDb.take(account));
|
||||
|
||||
final PreKey firstDevicePreKey = new PreKey(1, "public-key");
|
||||
final PreKey secondDevicePreKey = new PreKey(2, "second-key");
|
||||
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(firstDevicePreKey));
|
||||
keysDynamoDb.store(account, DEVICE_ID + 1, List.of(secondDevicePreKey));
|
||||
|
||||
final Set<KeyRecord> expectedKeys = Set.of(
|
||||
new KeyRecord(-1, ACCOUNT_NUMBER, DEVICE_ID, firstDevicePreKey.getKeyId(), firstDevicePreKey.getPublicKey()),
|
||||
new KeyRecord(-1, ACCOUNT_NUMBER, DEVICE_ID + 1, secondDevicePreKey.getKeyId(), secondDevicePreKey.getPublicKey()));
|
||||
|
||||
assertEquals(expectedKeys, new HashSet<>(keysDynamoDb.take(account)));
|
||||
assertEquals(0, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
assertEquals(0, keysDynamoDb.getCount(account, DEVICE_ID + 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTakeAccountAndDeviceId() {
|
||||
assertEquals(Collections.emptyList(), keysDynamoDb.take(account, DEVICE_ID));
|
||||
|
||||
final PreKey preKey = new PreKey(1, "public-key");
|
||||
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(preKey, new PreKey(2, "different-pre-key")));
|
||||
assertEquals(List.of(new KeyRecord(-1, ACCOUNT_NUMBER, DEVICE_ID, preKey.getKeyId(), preKey.getPublicKey())), keysDynamoDb.take(account, DEVICE_ID));
|
||||
assertEquals(1, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCount() {
|
||||
assertEquals(0, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(new PreKey(1, "public-key")));
|
||||
assertEquals(1, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteByAccount() {
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(new PreKey(1, "public-key"), new PreKey(2, "different-public-key")));
|
||||
keysDynamoDb.store(account, DEVICE_ID + 1, List.of(new PreKey(3, "public-key-for-different-device")));
|
||||
|
||||
assertEquals(2, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
assertEquals(1, keysDynamoDb.getCount(account, DEVICE_ID + 1));
|
||||
|
||||
keysDynamoDb.delete(account);
|
||||
|
||||
assertEquals(0, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
assertEquals(0, keysDynamoDb.getCount(account, DEVICE_ID + 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteByAccountAndDevice() {
|
||||
keysDynamoDb.store(account, DEVICE_ID, List.of(new PreKey(1, "public-key"), new PreKey(2, "different-public-key")));
|
||||
keysDynamoDb.store(account, DEVICE_ID + 1, List.of(new PreKey(3, "public-key-for-different-device")));
|
||||
|
||||
assertEquals(2, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
assertEquals(1, keysDynamoDb.getCount(account, DEVICE_ID + 1));
|
||||
|
||||
keysDynamoDb.delete(account, DEVICE_ID);
|
||||
|
||||
assertEquals(0, keysDynamoDb.getCount(account, DEVICE_ID));
|
||||
assertEquals(1, keysDynamoDb.getCount(account, DEVICE_ID + 1));
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ import io.dropwizard.testing.junit.ResourceTestRule;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class KeyControllerTest {
|
||||
public class KeysControllerTest {
|
||||
|
||||
private static final String EXISTS_NUMBER = "+14152222222";
|
||||
private static final UUID EXISTS_UUID = UUID.randomUUID();
|
||||
@@ -141,18 +141,16 @@ public class KeyControllerTest {
|
||||
|
||||
List<KeyRecord> singleDevice = new LinkedList<>();
|
||||
singleDevice.add(SAMPLE_KEY);
|
||||
when(keys.get(eq(EXISTS_NUMBER), eq(1L))).thenReturn(singleDevice);
|
||||
|
||||
when(keys.get(eq(NOT_EXISTS_NUMBER), eq(1L))).thenReturn(new LinkedList<>());
|
||||
when(keys.take(eq(existsAccount), eq(1L))).thenReturn(singleDevice);
|
||||
|
||||
List<KeyRecord> multiDevice = new LinkedList<>();
|
||||
multiDevice.add(SAMPLE_KEY);
|
||||
multiDevice.add(SAMPLE_KEY2);
|
||||
multiDevice.add(SAMPLE_KEY3);
|
||||
multiDevice.add(SAMPLE_KEY4);
|
||||
when(keys.get(EXISTS_NUMBER)).thenReturn(multiDevice);
|
||||
when(keys.take(existsAccount)).thenReturn(multiDevice);
|
||||
|
||||
when(keys.getCount(eq(AuthHelper.VALID_NUMBER), eq(1L))).thenReturn(5);
|
||||
when(keys.getCount(eq(AuthHelper.VALID_ACCOUNT), eq(1L))).thenReturn(5);
|
||||
|
||||
when(AuthHelper.VALID_DEVICE.getSignedPreKey()).thenReturn(VALID_DEVICE_SIGNED_KEY);
|
||||
when(AuthHelper.VALID_ACCOUNT.getIdentityKey()).thenReturn(null);
|
||||
@@ -169,7 +167,7 @@ public class KeyControllerTest {
|
||||
|
||||
assertThat(result.getCount()).isEqualTo(4);
|
||||
|
||||
verify(keys).getCount(eq(AuthHelper.VALID_NUMBER), eq(1L));
|
||||
verify(keys).getCount(eq(AuthHelper.VALID_ACCOUNT), eq(1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -183,7 +181,7 @@ public class KeyControllerTest {
|
||||
|
||||
assertThat(result.getCount()).isEqualTo(4);
|
||||
|
||||
verify(keys).getCount(eq(AuthHelper.VALID_NUMBER), eq(1L));
|
||||
verify(keys).getCount(eq(AuthHelper.VALID_ACCOUNT), eq(1L));
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +281,7 @@ public class KeyControllerTest {
|
||||
assertThat(result.getDevice(1).getPreKey().getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
||||
assertThat(result.getDevice(1).getSignedPreKey()).isEqualTo(existsAccount.getDevice(1).get().getSignedPreKey());
|
||||
|
||||
verify(keys).get(eq(EXISTS_NUMBER), eq(1L));
|
||||
verify(keys).take(eq(existsAccount), eq(1L));
|
||||
verifyNoMoreInteractions(keys);
|
||||
}
|
||||
|
||||
@@ -301,7 +299,7 @@ public class KeyControllerTest {
|
||||
assertThat(result.getDevice(1).getPreKey().getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
||||
assertThat(result.getDevice(1).getSignedPreKey()).isEqualTo(existsAccount.getDevice(1).get().getSignedPreKey());
|
||||
|
||||
verify(keys).get(eq(EXISTS_NUMBER), eq(1L));
|
||||
verify(keys).take(eq(existsAccount), eq(1L));
|
||||
verifyNoMoreInteractions(keys);
|
||||
}
|
||||
|
||||
@@ -320,7 +318,7 @@ public class KeyControllerTest {
|
||||
assertThat(result.getDevice(1).getPreKey().getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
||||
assertThat(result.getDevice(1).getSignedPreKey()).isEqualTo(existsAccount.getDevice(1).get().getSignedPreKey());
|
||||
|
||||
verify(keys).get(eq(EXISTS_NUMBER), eq(1L));
|
||||
verify(keys).take(eq(existsAccount), eq(1L));
|
||||
verifyNoMoreInteractions(keys);
|
||||
}
|
||||
|
||||
@@ -338,7 +336,7 @@ public class KeyControllerTest {
|
||||
assertThat(result.getDevice(1).getPreKey().getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
||||
assertThat(result.getDevice(1).getSignedPreKey()).isEqualTo(existsAccount.getDevice(1).get().getSignedPreKey());
|
||||
|
||||
verify(keys).get(eq(EXISTS_NUMBER), eq(1L));
|
||||
verify(keys).take(eq(existsAccount), eq(1L));
|
||||
verifyNoMoreInteractions(keys);
|
||||
}
|
||||
|
||||
@@ -414,7 +412,7 @@ public class KeyControllerTest {
|
||||
assertThat(signedPreKey).isNull();
|
||||
assertThat(deviceId).isEqualTo(4);
|
||||
|
||||
verify(keys).get(eq(EXISTS_NUMBER));
|
||||
verify(keys).take(eq(existsAccount));
|
||||
verifyNoMoreInteractions(keys);
|
||||
}
|
||||
|
||||
@@ -464,7 +462,7 @@ public class KeyControllerTest {
|
||||
assertThat(signedPreKey).isNull();
|
||||
assertThat(deviceId).isEqualTo(4);
|
||||
|
||||
verify(keys).get(eq(EXISTS_NUMBER));
|
||||
verify(keys).take(eq(existsAccount));
|
||||
verifyNoMoreInteractions(keys);
|
||||
}
|
||||
|
||||
@@ -533,7 +531,7 @@ public class KeyControllerTest {
|
||||
assertThat(response.getStatus()).isEqualTo(204);
|
||||
|
||||
ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
|
||||
verify(keys).store(eq(AuthHelper.VALID_NUMBER), eq(1L), listCaptor.capture());
|
||||
verify(keys).store(eq(AuthHelper.VALID_ACCOUNT), eq(1L), listCaptor.capture());
|
||||
|
||||
List<PreKey> capturedList = listCaptor.getValue();
|
||||
assertThat(capturedList.size()).isEqualTo(1);
|
||||
@@ -567,7 +565,7 @@ public class KeyControllerTest {
|
||||
assertThat(response.getStatus()).isEqualTo(204);
|
||||
|
||||
ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
|
||||
verify(keys).store(eq(AuthHelper.DISABLED_NUMBER), eq(1L), listCaptor.capture());
|
||||
verify(keys).store(eq(AuthHelper.DISABLED_ACCOUNT), eq(1L), listCaptor.capture());
|
||||
|
||||
List<PreKey> capturedList = listCaptor.getValue();
|
||||
assertThat(capturedList.size()).isEqualTo(1);
|
||||
@@ -8,7 +8,6 @@ package org.whispersystems.textsecuregcm.tests.storage;
|
||||
import io.lettuce.core.RedisException;
|
||||
import io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands;
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.textsecuregcm.entities.Profile;
|
||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||
import org.whispersystems.textsecuregcm.sqs.DirectoryQueue;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
@@ -16,6 +15,7 @@ import org.whispersystems.textsecuregcm.storage.Accounts;
|
||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||
import org.whispersystems.textsecuregcm.storage.DirectoryManager;
|
||||
import org.whispersystems.textsecuregcm.storage.Keys;
|
||||
import org.whispersystems.textsecuregcm.storage.KeysDynamoDb;
|
||||
import org.whispersystems.textsecuregcm.storage.MessagesManager;
|
||||
import org.whispersystems.textsecuregcm.storage.ProfilesManager;
|
||||
import org.whispersystems.textsecuregcm.storage.UsernamesManager;
|
||||
@@ -46,6 +46,7 @@ public class AccountsManagerTest {
|
||||
DirectoryManager directoryManager = mock(DirectoryManager.class);
|
||||
DirectoryQueue directoryQueue = mock(DirectoryQueue.class);
|
||||
Keys keys = mock(Keys.class);
|
||||
KeysDynamoDb keysDynamoDb = mock(KeysDynamoDb.class);
|
||||
MessagesManager messagesManager = mock(MessagesManager.class);
|
||||
UsernamesManager usernamesManager = mock(UsernamesManager.class);
|
||||
ProfilesManager profilesManager = mock(ProfilesManager.class);
|
||||
@@ -55,7 +56,7 @@ public class AccountsManagerTest {
|
||||
when(commands.get(eq("AccountMap::+14152222222"))).thenReturn(uuid.toString());
|
||||
when(commands.get(eq("Account3::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, messagesManager, usernamesManager, profilesManager);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, keysDynamoDb, messagesManager, usernamesManager, profilesManager);
|
||||
Optional<Account> account = accountsManager.get("+14152222222");
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
@@ -76,6 +77,7 @@ public class AccountsManagerTest {
|
||||
DirectoryManager directoryManager = mock(DirectoryManager.class);
|
||||
DirectoryQueue directoryQueue = mock(DirectoryQueue.class);
|
||||
Keys keys = mock(Keys.class);
|
||||
KeysDynamoDb keysDynamoDb = mock(KeysDynamoDb.class);
|
||||
MessagesManager messagesManager = mock(MessagesManager.class);
|
||||
UsernamesManager usernamesManager = mock(UsernamesManager.class);
|
||||
ProfilesManager profilesManager = mock(ProfilesManager.class);
|
||||
@@ -84,7 +86,7 @@ public class AccountsManagerTest {
|
||||
|
||||
when(commands.get(eq("Account3::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, messagesManager, usernamesManager, profilesManager);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, keysDynamoDb, messagesManager, usernamesManager, profilesManager);
|
||||
Optional<Account> account = accountsManager.get(uuid);
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
@@ -106,6 +108,7 @@ public class AccountsManagerTest {
|
||||
DirectoryManager directoryManager = mock(DirectoryManager.class);
|
||||
DirectoryQueue directoryQueue = mock(DirectoryQueue.class);
|
||||
Keys keys = mock(Keys.class);
|
||||
KeysDynamoDb keysDynamoDb = mock(KeysDynamoDb.class);
|
||||
MessagesManager messagesManager = mock(MessagesManager.class);
|
||||
UsernamesManager usernamesManager = mock(UsernamesManager.class);
|
||||
ProfilesManager profilesManager = mock(ProfilesManager.class);
|
||||
@@ -115,7 +118,7 @@ public class AccountsManagerTest {
|
||||
when(commands.get(eq("AccountMap::+14152222222"))).thenReturn(null);
|
||||
when(accounts.get(eq("+14152222222"))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, messagesManager, usernamesManager, profilesManager);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, keysDynamoDb, messagesManager, usernamesManager, profilesManager);
|
||||
Optional<Account> retrieved = accountsManager.get("+14152222222");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -138,6 +141,7 @@ public class AccountsManagerTest {
|
||||
DirectoryManager directoryManager = mock(DirectoryManager.class);
|
||||
DirectoryQueue directoryQueue = mock(DirectoryQueue.class);
|
||||
Keys keys = mock(Keys.class);
|
||||
KeysDynamoDb keysDynamoDb = mock(KeysDynamoDb.class);
|
||||
MessagesManager messagesManager = mock(MessagesManager.class);
|
||||
UsernamesManager usernamesManager = mock(UsernamesManager.class);
|
||||
ProfilesManager profilesManager = mock(ProfilesManager.class);
|
||||
@@ -147,7 +151,7 @@ public class AccountsManagerTest {
|
||||
when(commands.get(eq("Account3::" + uuid))).thenReturn(null);
|
||||
when(accounts.get(eq(uuid))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, messagesManager, usernamesManager, profilesManager);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, keysDynamoDb, messagesManager, usernamesManager, profilesManager);
|
||||
Optional<Account> retrieved = accountsManager.get(uuid);
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -170,6 +174,7 @@ public class AccountsManagerTest {
|
||||
DirectoryManager directoryManager = mock(DirectoryManager.class);
|
||||
DirectoryQueue directoryQueue = mock(DirectoryQueue.class);
|
||||
Keys keys = mock(Keys.class);
|
||||
KeysDynamoDb keysDynamoDb = mock(KeysDynamoDb.class);
|
||||
MessagesManager messagesManager = mock(MessagesManager.class);
|
||||
UsernamesManager usernamesManager = mock(UsernamesManager.class);
|
||||
ProfilesManager profilesManager = mock(ProfilesManager.class);
|
||||
@@ -179,7 +184,7 @@ public class AccountsManagerTest {
|
||||
when(commands.get(eq("AccountMap::+14152222222"))).thenThrow(new RedisException("Connection lost!"));
|
||||
when(accounts.get(eq("+14152222222"))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, messagesManager, usernamesManager, profilesManager);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, keysDynamoDb, messagesManager, usernamesManager, profilesManager);
|
||||
Optional<Account> retrieved = accountsManager.get("+14152222222");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -202,6 +207,7 @@ public class AccountsManagerTest {
|
||||
DirectoryManager directoryManager = mock(DirectoryManager.class);
|
||||
DirectoryQueue directoryQueue = mock(DirectoryQueue.class);
|
||||
Keys keys = mock(Keys.class);
|
||||
KeysDynamoDb keysDynamoDb = mock(KeysDynamoDb.class);
|
||||
MessagesManager messagesManager = mock(MessagesManager.class);
|
||||
UsernamesManager usernamesManager = mock(UsernamesManager.class);
|
||||
ProfilesManager profilesManager = mock(ProfilesManager.class);
|
||||
@@ -211,7 +217,7 @@ public class AccountsManagerTest {
|
||||
when(commands.get(eq("Account3::" + uuid))).thenThrow(new RedisException("Connection lost!"));
|
||||
when(accounts.get(eq(uuid))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, messagesManager, usernamesManager, profilesManager);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheCluster, directoryQueue, keys, keysDynamoDb, messagesManager, usernamesManager, profilesManager);
|
||||
Optional<Account> retrieved = accountsManager.get(uuid);
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.whispersystems.textsecuregcm.configuration.CircuitBreakerConfiguratio
|
||||
import org.whispersystems.textsecuregcm.configuration.AccountsDatabaseConfiguration;
|
||||
import org.whispersystems.textsecuregcm.configuration.RetryConfiguration;
|
||||
import org.whispersystems.textsecuregcm.entities.PreKey;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.FaultTolerantDatabase;
|
||||
import org.whispersystems.textsecuregcm.storage.KeyRecord;
|
||||
import org.whispersystems.textsecuregcm.storage.Keys;
|
||||
@@ -41,13 +42,14 @@ import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@Ignore
|
||||
public class KeysTest {
|
||||
|
||||
@Rule
|
||||
public PreparedDbRule db = EmbeddedPostgresRules.preparedDatabase(LiquibasePreparer.forClasspathLocation("accountsdb.xml"));
|
||||
|
||||
private Keys keys;
|
||||
private Account firstAccount;
|
||||
private Account secondAccount;
|
||||
private Keys keys;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -56,6 +58,12 @@ public class KeysTest {
|
||||
new CircuitBreakerConfiguration());
|
||||
|
||||
this.keys = new Keys(faultTolerantDatabase, new RetryConfiguration());
|
||||
|
||||
this.firstAccount = mock(Account.class);
|
||||
this.secondAccount = mock(Account.class);
|
||||
|
||||
when(firstAccount.getNumber()).thenReturn("+14152222222");
|
||||
when(secondAccount.getNumber()).thenReturn("+14151111111");
|
||||
}
|
||||
|
||||
|
||||
@@ -79,18 +87,18 @@ public class KeysTest {
|
||||
anotherDeviceTwoPreKeys.add(new PreKey(i, "+14151111111Device2PublicKey" + i));
|
||||
}
|
||||
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store("+14152222222", 2, deviceTwoPreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 2, deviceTwoPreKeys);
|
||||
|
||||
keys.store("+14151111111", 1, oldAnotherDeviceOnePrKeys);
|
||||
keys.store("+14151111111", 1, anotherDeviceOnePreKeys);
|
||||
keys.store("+14151111111", 2, anotherDeviceTwoPreKeys);
|
||||
keys.store(secondAccount, 1, oldAnotherDeviceOnePrKeys);
|
||||
keys.store(secondAccount, 1, anotherDeviceOnePreKeys);
|
||||
keys.store(secondAccount, 2, anotherDeviceTwoPreKeys);
|
||||
|
||||
PreparedStatement statement = db.getTestDatabase().getConnection().prepareStatement("SELECT * FROM keys WHERE number = ? AND device_id = ? ORDER BY key_id");
|
||||
verifyStoredState(statement, "+14152222222", 1);
|
||||
verifyStoredState(statement, "+14152222222", 2);
|
||||
verifyStoredState(statement, "+14151111111", 1);
|
||||
verifyStoredState(statement, "+14151111111", 2);
|
||||
verifyStoredState(statement, firstAccount, 1);
|
||||
verifyStoredState(statement, firstAccount, 2);
|
||||
verifyStoredState(statement, secondAccount, 1);
|
||||
verifyStoredState(statement, secondAccount, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,11 +110,12 @@ public class KeysTest {
|
||||
}
|
||||
|
||||
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGetForDevice() {
|
||||
List<PreKey> deviceOnePreKeys = new LinkedList<>();
|
||||
@@ -125,45 +134,46 @@ public class KeysTest {
|
||||
anotherDeviceTwoPreKeys.add(new PreKey(i, "+14151111111Device2PublicKey" + i));
|
||||
}
|
||||
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store("+14152222222", 2, deviceTwoPreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 2, deviceTwoPreKeys);
|
||||
|
||||
keys.store("+14151111111", 1, anotherDeviceOnePreKeys);
|
||||
keys.store("+14151111111", 2, anotherDeviceTwoPreKeys);
|
||||
keys.store(secondAccount, 1, anotherDeviceOnePreKeys);
|
||||
keys.store(secondAccount, 2, anotherDeviceTwoPreKeys);
|
||||
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(100);
|
||||
List<KeyRecord> records = keys.get("+14152222222", 1);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(100);
|
||||
List<KeyRecord> records = keys.take(firstAccount, 1);
|
||||
|
||||
assertThat(records.size()).isEqualTo(1);
|
||||
assertThat(records.get(0).getKeyId()).isEqualTo(1);
|
||||
assertThat(records.get(0).getPublicKey()).isEqualTo("+14152222222Device1PublicKey1");
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(99);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(99);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 2)).isEqualTo(100);
|
||||
|
||||
records = keys.get("+14152222222", 1);
|
||||
records = keys.take(firstAccount, 1);
|
||||
|
||||
assertThat(records.size()).isEqualTo(1);
|
||||
assertThat(records.get(0).getKeyId()).isEqualTo(2);
|
||||
assertThat(records.get(0).getPublicKey()).isEqualTo("+14152222222Device1PublicKey2");
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(98);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(98);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 2)).isEqualTo(100);
|
||||
|
||||
records = keys.get("+14152222222", 2);
|
||||
records = keys.take(firstAccount, 2);
|
||||
|
||||
assertThat(records.size()).isEqualTo(1);
|
||||
assertThat(records.get(0).getKeyId()).isEqualTo(1);
|
||||
assertThat(records.get(0).getPublicKey()).isEqualTo("+14152222222Device2PublicKey1");
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(98);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(99);
|
||||
assertThat(keys.getCount("+14151111111", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(98);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(99);
|
||||
assertThat(keys.getCount(secondAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 2)).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGetForAllDevices() {
|
||||
List<PreKey> deviceOnePreKeys = new LinkedList<>();
|
||||
@@ -184,18 +194,18 @@ public class KeysTest {
|
||||
anotherDeviceThreePreKeys.add(new PreKey(i, "+14151111111Device3PublicKey" + i));
|
||||
}
|
||||
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store("+14152222222", 2, deviceTwoPreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 2, deviceTwoPreKeys);
|
||||
|
||||
keys.store("+14151111111", 1, anotherDeviceOnePreKeys);
|
||||
keys.store("+14151111111", 2, anotherDeviceTwoPreKeys);
|
||||
keys.store("+14151111111", 3, anotherDeviceThreePreKeys);
|
||||
keys.store(secondAccount, 1, anotherDeviceOnePreKeys);
|
||||
keys.store(secondAccount, 2, anotherDeviceTwoPreKeys);
|
||||
keys.store(secondAccount, 3, anotherDeviceThreePreKeys);
|
||||
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(100);
|
||||
|
||||
List<KeyRecord> records = keys.get("+14152222222");
|
||||
List<KeyRecord> records = keys.take(firstAccount);
|
||||
|
||||
assertThat(records.size()).isEqualTo(2);
|
||||
assertThat(records.get(0).getKeyId()).isEqualTo(1);
|
||||
@@ -204,10 +214,10 @@ public class KeysTest {
|
||||
assertThat(records.stream().anyMatch(record -> record.getPublicKey().equals("+14152222222Device1PublicKey1"))).isTrue();
|
||||
assertThat(records.stream().anyMatch(record -> record.getPublicKey().equals("+14152222222Device2PublicKey1"))).isTrue();
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(99);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(99);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(99);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(99);
|
||||
|
||||
records = keys.get("+14152222222");
|
||||
records = keys.take(firstAccount);
|
||||
|
||||
assertThat(records.size()).isEqualTo(2);
|
||||
assertThat(records.get(0).getKeyId()).isEqualTo(2);
|
||||
@@ -216,11 +226,11 @@ public class KeysTest {
|
||||
assertThat(records.stream().anyMatch(record -> record.getPublicKey().equals("+14152222222Device1PublicKey2"))).isTrue();
|
||||
assertThat(records.stream().anyMatch(record -> record.getPublicKey().equals("+14152222222Device2PublicKey2"))).isTrue();
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(98);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(98);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(98);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(98);
|
||||
|
||||
|
||||
records = keys.get("+14151111111");
|
||||
records = keys.take(secondAccount);
|
||||
|
||||
assertThat(records.size()).isEqualTo(3);
|
||||
assertThat(records.get(0).getKeyId()).isEqualTo(1);
|
||||
@@ -231,11 +241,12 @@ public class KeysTest {
|
||||
assertThat(records.stream().anyMatch(record -> record.getPublicKey().equals("+14151111111Device2PublicKey1"))).isTrue();
|
||||
assertThat(records.stream().anyMatch(record -> record.getPublicKey().equals("+14151111111Device3PublicKey1"))).isTrue();
|
||||
|
||||
assertThat(keys.getCount("+14151111111", 1)).isEqualTo(99);
|
||||
assertThat(keys.getCount("+14151111111", 2)).isEqualTo(99);
|
||||
assertThat(keys.getCount("+14151111111", 3)).isEqualTo(99);
|
||||
assertThat(keys.getCount(secondAccount, 1)).isEqualTo(99);
|
||||
assertThat(keys.getCount(secondAccount, 2)).isEqualTo(99);
|
||||
assertThat(keys.getCount(secondAccount, 3)).isEqualTo(99);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGetForAllDevicesParallel() throws InterruptedException {
|
||||
List<PreKey> deviceOnePreKeys = new LinkedList<>();
|
||||
@@ -246,11 +257,11 @@ public class KeysTest {
|
||||
deviceTwoPreKeys.add(new PreKey(i, "+14152222222Device2PublicKey" + i));
|
||||
}
|
||||
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store("+14152222222", 2, deviceTwoPreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 2, deviceTwoPreKeys);
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(100);
|
||||
|
||||
List<Thread> threads = new LinkedList<>();
|
||||
|
||||
@@ -260,7 +271,7 @@ public class KeysTest {
|
||||
final int MAX_RETRIES = 5;
|
||||
for (int retryAttempt = 0; results == null && retryAttempt < MAX_RETRIES; ++retryAttempt) {
|
||||
try {
|
||||
results = keys.get("+14152222222");
|
||||
results = keys.take(firstAccount);
|
||||
} catch (UnableToExecuteStatementException e) {
|
||||
if (retryAttempt == MAX_RETRIES - 1) {
|
||||
throw e;
|
||||
@@ -278,8 +289,8 @@ public class KeysTest {
|
||||
thread.join();
|
||||
}
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(80);
|
||||
assertThat(keys.getCount("+14152222222",2)).isEqualTo(80);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(80);
|
||||
assertThat(keys.getCount(firstAccount,2)).isEqualTo(80);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -302,32 +313,32 @@ public class KeysTest {
|
||||
anotherDeviceThreePreKeys.add(new PreKey(i, "+14151111111Device3PublicKey" + i));
|
||||
}
|
||||
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store("+14152222222", 2, deviceTwoPreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 2, deviceTwoPreKeys);
|
||||
|
||||
keys.store("+14151111111", 1, anotherDeviceOnePreKeys);
|
||||
keys.store("+14151111111", 2, anotherDeviceTwoPreKeys);
|
||||
keys.store("+14151111111", 3, anotherDeviceThreePreKeys);
|
||||
keys.store(secondAccount, 1, anotherDeviceOnePreKeys);
|
||||
keys.store(secondAccount, 2, anotherDeviceTwoPreKeys);
|
||||
keys.store(secondAccount, 3, anotherDeviceThreePreKeys);
|
||||
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 3)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 3)).isEqualTo(100);
|
||||
|
||||
keys.delete("+14152222222");
|
||||
keys.delete(firstAccount);
|
||||
|
||||
assertThat(keys.getCount("+14152222222", 1)).isEqualTo(0);
|
||||
assertThat(keys.getCount("+14152222222", 2)).isEqualTo(0);
|
||||
assertThat(keys.getCount("+14151111111", 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount("+14151111111", 3)).isEqualTo(100);
|
||||
assertThat(keys.getCount(firstAccount, 1)).isEqualTo(0);
|
||||
assertThat(keys.getCount(firstAccount, 2)).isEqualTo(0);
|
||||
assertThat(keys.getCount(secondAccount, 1)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 2)).isEqualTo(100);
|
||||
assertThat(keys.getCount(secondAccount, 3)).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyKeyGet() {
|
||||
List<KeyRecord> records = keys.get("+14152222222");
|
||||
List<KeyRecord> records = keys.take(firstAccount);
|
||||
|
||||
assertThat(records.isEmpty()).isTrue();
|
||||
}
|
||||
@@ -361,21 +372,21 @@ public class KeysTest {
|
||||
}
|
||||
|
||||
try {
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
throw new AssertionError();
|
||||
} catch (TransactionException e) {
|
||||
// good
|
||||
}
|
||||
|
||||
try {
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
throw new AssertionError();
|
||||
} catch (TransactionException e) {
|
||||
// good
|
||||
}
|
||||
|
||||
try {
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
throw new AssertionError();
|
||||
} catch (CallNotPermittedException e) {
|
||||
// good
|
||||
@@ -384,7 +395,7 @@ public class KeysTest {
|
||||
Thread.sleep(1100);
|
||||
|
||||
try {
|
||||
keys.store("+14152222222", 1, deviceOnePreKeys);
|
||||
keys.store(firstAccount, 1, deviceOnePreKeys);
|
||||
throw new AssertionError();
|
||||
} catch (TransactionException e) {
|
||||
// good
|
||||
@@ -401,7 +412,10 @@ public class KeysTest {
|
||||
Keys keys = new Keys(new FaultTolerantDatabase("testBreaker", jdbi, new CircuitBreakerConfiguration()), new RetryConfiguration());
|
||||
|
||||
// We're happy as long as nothing throws an exception
|
||||
keys.store("+18005551234", 1, Collections.emptyList());
|
||||
Account account = mock(Account.class);
|
||||
when(account.getNumber()).thenReturn("+18005551234");
|
||||
|
||||
keys.store(account, 1, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -414,12 +428,15 @@ public class KeysTest {
|
||||
|
||||
Keys keys = new Keys(new FaultTolerantDatabase("testBreaker", jdbi, new CircuitBreakerConfiguration()), new RetryConfiguration());
|
||||
|
||||
assertThat(keys.get("+18005551234")).isEqualTo(Collections.emptyList());
|
||||
assertThat(keys.get("+18005551234", 1)).isEqualTo(Collections.emptyList());
|
||||
Account account = mock(Account.class);
|
||||
when(account.getNumber()).thenReturn("+18005551234");
|
||||
|
||||
assertThat(keys.take(account)).isEqualTo(Collections.emptyList());
|
||||
assertThat(keys.take(account, 1)).isEqualTo(Collections.emptyList());
|
||||
}
|
||||
|
||||
private void verifyStoredState(PreparedStatement statement, String number, int deviceId) throws SQLException {
|
||||
statement.setString(1, number);
|
||||
private void verifyStoredState(PreparedStatement statement, Account account, int deviceId) throws SQLException {
|
||||
statement.setString(1, account.getNumber());
|
||||
statement.setInt(2, deviceId);
|
||||
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
@@ -431,7 +448,7 @@ public class KeysTest {
|
||||
|
||||
|
||||
assertThat(keyId).isEqualTo(rowCount);
|
||||
assertThat(publicKey).isEqualTo(number + "Device" + deviceId + "PublicKey" + rowCount);
|
||||
assertThat(publicKey).isEqualTo(account.getNumber() + "Device" + deviceId + "PublicKey" + rowCount);
|
||||
|
||||
rowCount++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user