Make phone number identifiers non-optional
This commit is contained in:
parent
069ffa9921
commit
296f6a7a88
|
@ -392,7 +392,7 @@ public class AccountController {
|
||||||
|
|
||||||
return new AccountCreationResult(account.getUuid(),
|
return new AccountCreationResult(account.getUuid(),
|
||||||
account.getNumber(),
|
account.getNumber(),
|
||||||
account.getPhoneNumberIdentifier().orElse(null),
|
account.getPhoneNumberIdentifier(),
|
||||||
existingAccount.map(Account::isStorageSupported).orElse(false));
|
existingAccount.map(Account::isStorageSupported).orElse(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +606,7 @@ public class AccountController {
|
||||||
public AccountCreationResult whoAmI(@Auth AuthenticatedAccount auth) {
|
public AccountCreationResult whoAmI(@Auth AuthenticatedAccount auth) {
|
||||||
return new AccountCreationResult(auth.getAccount().getUuid(),
|
return new AccountCreationResult(auth.getAccount().getUuid(),
|
||||||
auth.getAccount().getNumber(),
|
auth.getAccount().getNumber(),
|
||||||
auth.getAccount().getPhoneNumberIdentifier().orElse(null),
|
auth.getAccount().getPhoneNumberIdentifier(),
|
||||||
auth.getAccount().isStorageSupported());
|
auth.getAccount().isStorageSupported());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.NotFoundException;
|
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
@ -87,7 +86,7 @@ public class CertificateController {
|
||||||
List<GroupCredentials.GroupCredential> credentials = new LinkedList<>();
|
List<GroupCredentials.GroupCredential> credentials = new LinkedList<>();
|
||||||
|
|
||||||
final UUID identifier = identityType.map(String::toLowerCase).orElse("aci").equals("pni") ?
|
final UUID identifier = identityType.map(String::toLowerCase).orElse("aci").equals("pni") ?
|
||||||
auth.getAccount().getPhoneNumberIdentifier().orElseThrow(NotFoundException::new) :
|
auth.getAccount().getPhoneNumberIdentifier() :
|
||||||
auth.getAccount().getUuid();
|
auth.getAccount().getUuid();
|
||||||
|
|
||||||
for (int i = startRedemptionTime; i <= endRedemptionTime; i++) {
|
for (int i = startRedemptionTime; i <= endRedemptionTime; i++) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import javax.validation.Valid;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.HeaderParam;
|
import javax.ws.rs.HeaderParam;
|
||||||
import javax.ws.rs.NotFoundException;
|
|
||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
@ -192,8 +191,7 @@ public class KeysController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean usePhoneNumberIdentity =
|
final boolean usePhoneNumberIdentity = target.getPhoneNumberIdentifier().equals(targetUuid);
|
||||||
target.getPhoneNumberIdentifier().map(pni -> pni.equals(targetUuid)).orElse(false);
|
|
||||||
|
|
||||||
Map<Long, PreKey> preKeysByDeviceId = getLocalKeys(target, deviceId, usePhoneNumberIdentity);
|
Map<Long, PreKey> preKeysByDeviceId = getLocalKeys(target, deviceId, usePhoneNumberIdentity);
|
||||||
List<PreKeyResponseItem> responseItems = new LinkedList<>();
|
List<PreKeyResponseItem> responseItems = new LinkedList<>();
|
||||||
|
@ -254,7 +252,7 @@ public class KeysController {
|
||||||
|
|
||||||
private static UUID getIdentifier(final Account account, final Optional<String> identityType) {
|
private static UUID getIdentifier(final Account account, final Optional<String> identityType) {
|
||||||
return usePhoneNumberIdentity(identityType) ?
|
return usePhoneNumberIdentity(identityType) ?
|
||||||
account.getPhoneNumberIdentifier().orElseThrow(NotFoundException::new) :
|
account.getPhoneNumberIdentifier() :
|
||||||
account.getUuid();
|
account.getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +260,7 @@ public class KeysController {
|
||||||
final Map<Long, PreKey> preKeys;
|
final Map<Long, PreKey> preKeys;
|
||||||
|
|
||||||
final UUID identifier = usePhoneNumberIdentity ?
|
final UUID identifier = usePhoneNumberIdentity ?
|
||||||
destination.getPhoneNumberIdentifier().orElseThrow(NotFoundException::new) :
|
destination.getPhoneNumberIdentifier() :
|
||||||
destination.getUuid();
|
destination.getUuid();
|
||||||
|
|
||||||
if (deviceIdSelector.equals("*")) {
|
if (deviceIdSelector.equals("*")) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.whispersystems.textsecuregcm.auth.AuthenticationCredentials;
|
||||||
import org.whispersystems.textsecuregcm.auth.StoredRegistrationLock;
|
import org.whispersystems.textsecuregcm.auth.StoredRegistrationLock;
|
||||||
import org.whispersystems.textsecuregcm.entities.AccountAttributes;
|
import org.whispersystems.textsecuregcm.entities.AccountAttributes;
|
||||||
import org.whispersystems.textsecuregcm.util.Util;
|
import org.whispersystems.textsecuregcm.util.Util;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class Account {
|
public class Account {
|
||||||
|
|
||||||
|
@ -33,9 +32,7 @@ public class Account {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
// Nullable only until initial migration is complete
|
|
||||||
@JsonProperty("pni")
|
@JsonProperty("pni")
|
||||||
@Nullable
|
|
||||||
private UUID phoneNumberIdentifier;
|
private UUID phoneNumberIdentifier;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -108,11 +105,10 @@ public class Account {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optional only until initial migration is complete
|
public UUID getPhoneNumberIdentifier() {
|
||||||
public Optional<UUID> getPhoneNumberIdentifier() {
|
|
||||||
requireNotStale();
|
requireNotStale();
|
||||||
|
|
||||||
return Optional.ofNullable(phoneNumberIdentifier);
|
return phoneNumberIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -108,18 +108,12 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assert account.getPhoneNumberIdentifier().isPresent();
|
|
||||||
|
|
||||||
if (account.getPhoneNumberIdentifier().isEmpty()) {
|
|
||||||
log.error("Account {} is missing a phone number identifier", account.getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
TransactWriteItem phoneNumberIdentifierConstraintPut = TransactWriteItem.builder()
|
TransactWriteItem phoneNumberIdentifierConstraintPut = TransactWriteItem.builder()
|
||||||
.put(
|
.put(
|
||||||
Put.builder()
|
Put.builder()
|
||||||
.tableName(phoneNumberIdentifierConstraintTableName)
|
.tableName(phoneNumberIdentifierConstraintTableName)
|
||||||
.item(Map.of(
|
.item(Map.of(
|
||||||
ATTR_PNI_UUID, AttributeValues.fromUUID(account.getPhoneNumberIdentifier().get()),
|
ATTR_PNI_UUID, AttributeValues.fromUUID(account.getPhoneNumberIdentifier()),
|
||||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||||
.conditionExpression(
|
.conditionExpression(
|
||||||
"attribute_not_exists(#pni) OR (attribute_exists(#pni) AND #uuid = :uuid)")
|
"attribute_not_exists(#pni) OR (attribute_exists(#pni) AND #uuid = :uuid)")
|
||||||
|
@ -135,12 +129,11 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
final Map<String, AttributeValue> item = new HashMap<>(Map.of(
|
final Map<String, AttributeValue> item = new HashMap<>(Map.of(
|
||||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
||||||
ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
||||||
|
ATTR_PNI_UUID, AttributeValues.fromUUID(account.getPhoneNumberIdentifier()),
|
||||||
ATTR_ACCOUNT_DATA, AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
ATTR_ACCOUNT_DATA, AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
||||||
ATTR_VERSION, AttributeValues.fromInt(account.getVersion()),
|
ATTR_VERSION, AttributeValues.fromInt(account.getVersion()),
|
||||||
ATTR_CANONICALLY_DISCOVERABLE, AttributeValues.fromBool(account.shouldBeVisibleInDirectory())));
|
ATTR_CANONICALLY_DISCOVERABLE, AttributeValues.fromBool(account.shouldBeVisibleInDirectory())));
|
||||||
|
|
||||||
account.getPhoneNumberIdentifier().ifPresent(pni -> item.put(ATTR_PNI_UUID, AttributeValues.fromUUID(pni)));
|
|
||||||
|
|
||||||
TransactWriteItem accountPut = TransactWriteItem.builder()
|
TransactWriteItem accountPut = TransactWriteItem.builder()
|
||||||
.put(Put.builder()
|
.put(Put.builder()
|
||||||
.conditionExpression("attribute_not_exists(#number) OR #number = :number")
|
.conditionExpression("attribute_not_exists(#number) OR #number = :number")
|
||||||
|
@ -180,7 +173,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
account.setUuid(UUIDUtil.fromByteBuffer(actualAccountUuid));
|
account.setUuid(UUIDUtil.fromByteBuffer(actualAccountUuid));
|
||||||
|
|
||||||
final Account existingAccount = getByAccountIdentifier(account.getUuid()).orElseThrow();
|
final Account existingAccount = getByAccountIdentifier(account.getUuid()).orElseThrow();
|
||||||
account.setNumber(existingAccount.getNumber(), existingAccount.getPhoneNumberIdentifier().orElse(account.getPhoneNumberIdentifier().orElseThrow()));
|
account.setNumber(existingAccount.getNumber(), existingAccount.getPhoneNumberIdentifier());
|
||||||
account.setVersion(existingAccount.getVersion());
|
account.setVersion(existingAccount.getVersion());
|
||||||
|
|
||||||
update(account);
|
update(account);
|
||||||
|
@ -220,7 +213,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
public void changeNumber(final Account account, final String number, final UUID phoneNumberIdentifier) {
|
public void changeNumber(final Account account, final String number, final UUID phoneNumberIdentifier) {
|
||||||
CHANGE_NUMBER_TIMER.record(() -> {
|
CHANGE_NUMBER_TIMER.record(() -> {
|
||||||
final String originalNumber = account.getNumber();
|
final String originalNumber = account.getNumber();
|
||||||
final Optional<UUID> originalPni = account.getPhoneNumberIdentifier();
|
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||||
|
|
||||||
boolean succeeded = false;
|
boolean succeeded = false;
|
||||||
|
|
||||||
|
@ -248,12 +241,12 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
originalPni.ifPresent(pni -> writeItems.add(TransactWriteItem.builder()
|
writeItems.add(TransactWriteItem.builder()
|
||||||
.delete(Delete.builder()
|
.delete(Delete.builder()
|
||||||
.tableName(phoneNumberIdentifierConstraintTableName)
|
.tableName(phoneNumberIdentifierConstraintTableName)
|
||||||
.key(Map.of(ATTR_PNI_UUID, AttributeValues.fromUUID(pni)))
|
.key(Map.of(ATTR_PNI_UUID, AttributeValues.fromUUID(originalPni)))
|
||||||
.build())
|
.build())
|
||||||
.build()));
|
.build());
|
||||||
|
|
||||||
writeItems.add(TransactWriteItem.builder()
|
writeItems.add(TransactWriteItem.builder()
|
||||||
.put(Put.builder()
|
.put(Put.builder()
|
||||||
|
@ -301,7 +294,7 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (!succeeded) {
|
if (!succeeded) {
|
||||||
account.setNumber(originalNumber, originalPni.orElse(null));
|
account.setNumber(originalNumber, originalPni);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -312,65 +305,27 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
final List<TransactWriteItem> transactWriteItems = new ArrayList<>(2);
|
final List<TransactWriteItem> transactWriteItems = new ArrayList<>(2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final TransactWriteItem updateAccountWriteItem;
|
final TransactWriteItem updateAccountWriteItem = TransactWriteItem.builder()
|
||||||
|
.update(Update.builder()
|
||||||
if (account.getPhoneNumberIdentifier().isPresent()) {
|
.tableName(accountsTableName)
|
||||||
updateAccountWriteItem = TransactWriteItem.builder()
|
.key(Map.of(KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||||
.update(Update.builder()
|
.updateExpression("SET #data = :data, #cds = :cds, #pni = :pni ADD #version :version_increment")
|
||||||
.tableName(accountsTableName)
|
.conditionExpression("attribute_exists(#number) AND #version = :version")
|
||||||
.key(Map.of(KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
.expressionAttributeNames(Map.of("#number", ATTR_ACCOUNT_E164,
|
||||||
.updateExpression("SET #data = :data, #cds = :cds, #pni = :pni ADD #version :version_increment")
|
"#data", ATTR_ACCOUNT_DATA,
|
||||||
.conditionExpression("attribute_exists(#number) AND #version = :version")
|
"#cds", ATTR_CANONICALLY_DISCOVERABLE,
|
||||||
.expressionAttributeNames(Map.of("#number", ATTR_ACCOUNT_E164,
|
"#version", ATTR_VERSION,
|
||||||
"#data", ATTR_ACCOUNT_DATA,
|
"#pni", ATTR_PNI_UUID))
|
||||||
"#cds", ATTR_CANONICALLY_DISCOVERABLE,
|
.expressionAttributeValues(Map.of(
|
||||||
"#version", ATTR_VERSION,
|
":data", AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
||||||
"#pni", ATTR_PNI_UUID))
|
":cds", AttributeValues.fromBool(account.shouldBeVisibleInDirectory()),
|
||||||
.expressionAttributeValues(Map.of(
|
":version", AttributeValues.fromInt(account.getVersion()),
|
||||||
":data", AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
":version_increment", AttributeValues.fromInt(1),
|
||||||
":cds", AttributeValues.fromBool(account.shouldBeVisibleInDirectory()),
|
":pni", AttributeValues.fromUUID(account.getPhoneNumberIdentifier())))
|
||||||
":version", AttributeValues.fromInt(account.getVersion()),
|
.build())
|
||||||
":version_increment", AttributeValues.fromInt(1),
|
.build();;
|
||||||
":pni", AttributeValues.fromUUID(account.getPhoneNumberIdentifier().get())))
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
} else {
|
|
||||||
updateAccountWriteItem = TransactWriteItem.builder()
|
|
||||||
.update(Update.builder()
|
|
||||||
.tableName(accountsTableName)
|
|
||||||
.key(Map.of(KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.updateExpression("SET #data = :data, #cds = :cds ADD #version :version_increment")
|
|
||||||
.conditionExpression("attribute_exists(#number) AND #version = :version")
|
|
||||||
.expressionAttributeNames(Map.of("#number", ATTR_ACCOUNT_E164,
|
|
||||||
"#data", ATTR_ACCOUNT_DATA,
|
|
||||||
"#cds", ATTR_CANONICALLY_DISCOVERABLE,
|
|
||||||
"#version", ATTR_VERSION))
|
|
||||||
.expressionAttributeValues(Map.of(
|
|
||||||
":data", AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
|
||||||
":cds", AttributeValues.fromBool(account.shouldBeVisibleInDirectory()),
|
|
||||||
":version", AttributeValues.fromInt(account.getVersion()),
|
|
||||||
":version_increment", AttributeValues.fromInt(1)))
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
transactWriteItems.add(updateAccountWriteItem);
|
transactWriteItems.add(updateAccountWriteItem);
|
||||||
|
|
||||||
// TODO Remove after initial migration to phone number identifiers
|
|
||||||
account.getPhoneNumberIdentifier().ifPresent(phoneNumberIdentifier -> transactWriteItems.add(
|
|
||||||
TransactWriteItem.builder()
|
|
||||||
.put(Put.builder()
|
|
||||||
.tableName(phoneNumberIdentifierConstraintTableName)
|
|
||||||
.item(Map.of(
|
|
||||||
ATTR_PNI_UUID, AttributeValues.fromUUID(account.getPhoneNumberIdentifier().get()),
|
|
||||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.conditionExpression("attribute_not_exists(#pni) OR (attribute_exists(#pni) AND #uuid = :uuid)")
|
|
||||||
.expressionAttributeNames(Map.of("#uuid", KEY_ACCOUNT_UUID, "#pni", ATTR_PNI_UUID))
|
|
||||||
.expressionAttributeValues(
|
|
||||||
Map.of(":uuid", AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.returnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
|
|
||||||
.build())
|
|
||||||
.build()));
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
@ -464,12 +419,12 @@ public class Accounts extends AbstractDynamoDbStore {
|
||||||
|
|
||||||
final List<TransactWriteItem> transactWriteItems = new ArrayList<>(List.of(phoneNumberDelete, accountDelete));
|
final List<TransactWriteItem> transactWriteItems = new ArrayList<>(List.of(phoneNumberDelete, accountDelete));
|
||||||
|
|
||||||
account.getPhoneNumberIdentifier().ifPresent(pni -> transactWriteItems.add(TransactWriteItem.builder()
|
transactWriteItems.add(TransactWriteItem.builder()
|
||||||
.delete(Delete.builder()
|
.delete(Delete.builder()
|
||||||
.tableName(phoneNumberIdentifierConstraintTableName)
|
.tableName(phoneNumberIdentifierConstraintTableName)
|
||||||
.key(Map.of(ATTR_PNI_UUID, AttributeValues.fromUUID(pni)))
|
.key(Map.of(ATTR_PNI_UUID, AttributeValues.fromUUID(account.getPhoneNumberIdentifier())))
|
||||||
.build())
|
.build())
|
||||||
.build()));
|
.build());
|
||||||
|
|
||||||
TransactWriteItemsRequest request = TransactWriteItemsRequest.builder()
|
TransactWriteItemsRequest request = TransactWriteItemsRequest.builder()
|
||||||
.transactItems(transactWriteItems).build();
|
.transactItems(transactWriteItems).build();
|
||||||
|
|
|
@ -438,12 +438,9 @@ public class AccountsManager {
|
||||||
usernamesManager.delete(account.getUuid());
|
usernamesManager.delete(account.getUuid());
|
||||||
profilesManager.deleteAll(account.getUuid());
|
profilesManager.deleteAll(account.getUuid());
|
||||||
keys.delete(account.getUuid());
|
keys.delete(account.getUuid());
|
||||||
|
keys.delete(account.getPhoneNumberIdentifier());
|
||||||
messagesManager.clear(account.getUuid());
|
messagesManager.clear(account.getUuid());
|
||||||
|
messagesManager.clear(account.getPhoneNumberIdentifier());
|
||||||
account.getPhoneNumberIdentifier().ifPresent(pni -> {
|
|
||||||
keys.delete(pni);
|
|
||||||
messagesManager.clear(pni);
|
|
||||||
});
|
|
||||||
|
|
||||||
deleteStorageServiceDataFuture.join();
|
deleteStorageServiceDataFuture.join();
|
||||||
deleteBackupServiceDataFuture.join();
|
deleteBackupServiceDataFuture.join();
|
||||||
|
@ -471,9 +468,8 @@ public class AccountsManager {
|
||||||
cacheCluster.useCluster(connection -> {
|
cacheCluster.useCluster(connection -> {
|
||||||
final RedisAdvancedClusterCommands<String, String> commands = connection.sync();
|
final RedisAdvancedClusterCommands<String, String> commands = connection.sync();
|
||||||
|
|
||||||
account.getPhoneNumberIdentifier().ifPresent(pni ->
|
|
||||||
commands.set(getAccountMapKey(pni.toString()), account.getUuid().toString()));
|
|
||||||
|
|
||||||
|
commands.set(getAccountMapKey(account.getPhoneNumberIdentifier().toString()), account.getUuid().toString());
|
||||||
commands.set(getAccountMapKey(account.getNumber()), account.getUuid().toString());
|
commands.set(getAccountMapKey(account.getNumber()), account.getUuid().toString());
|
||||||
commands.set(getAccountEntityKey(account.getUuid()), accountJson);
|
commands.set(getAccountEntityKey(account.getUuid()), accountJson);
|
||||||
});
|
});
|
||||||
|
@ -528,11 +524,10 @@ public class AccountsManager {
|
||||||
|
|
||||||
private void redisDelete(final Account account) {
|
private void redisDelete(final Account account) {
|
||||||
try (final Timer.Context ignored = redisDeleteTimer.time()) {
|
try (final Timer.Context ignored = redisDeleteTimer.time()) {
|
||||||
cacheCluster.useCluster(connection -> {
|
cacheCluster.useCluster(connection -> connection.sync().del(
|
||||||
connection.sync().del(getAccountMapKey(account.getNumber()), getAccountEntityKey(account.getUuid()));
|
getAccountMapKey(account.getNumber()),
|
||||||
|
getAccountMapKey(account.getPhoneNumberIdentifier().toString()),
|
||||||
account.getPhoneNumberIdentifier().ifPresent(pni -> connection.sync().del(getAccountMapKey(pni.toString())));
|
getAccountEntityKey(account.getUuid())));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||||
|
|
||||||
final Account account = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
final Account account = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
||||||
final UUID originalUuid = account.getUuid();
|
final UUID originalUuid = account.getUuid();
|
||||||
final UUID originalPni = account.getPhoneNumberIdentifier().orElseThrow();
|
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||||
|
|
||||||
accountsManager.changeNumber(account, secondNumber);
|
accountsManager.changeNumber(account, secondNumber);
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||||
|
|
||||||
assertTrue(accountsManager.getByE164(secondNumber).isPresent());
|
assertTrue(accountsManager.getByE164(secondNumber).isPresent());
|
||||||
assertEquals(originalUuid, accountsManager.getByE164(secondNumber).map(Account::getUuid).orElseThrow());
|
assertEquals(originalUuid, accountsManager.getByE164(secondNumber).map(Account::getUuid).orElseThrow());
|
||||||
assertNotEquals(originalPni, accountsManager.getByE164(secondNumber).flatMap(Account::getPhoneNumberIdentifier).orElseThrow());
|
assertNotEquals(originalPni, accountsManager.getByE164(secondNumber).map(Account::getPhoneNumberIdentifier).orElseThrow());
|
||||||
|
|
||||||
assertEquals(secondNumber, accountsManager.getByAccountIdentifier(originalUuid).map(Account::getNumber).orElseThrow());
|
assertEquals(secondNumber, accountsManager.getByAccountIdentifier(originalUuid).map(Account::getNumber).orElseThrow());
|
||||||
|
|
||||||
|
@ -231,14 +231,14 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||||
|
|
||||||
Account account = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
Account account = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
||||||
final UUID originalUuid = account.getUuid();
|
final UUID originalUuid = account.getUuid();
|
||||||
final UUID originalPni = account.getPhoneNumberIdentifier().orElseThrow();
|
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||||
|
|
||||||
account = accountsManager.changeNumber(account, secondNumber);
|
account = accountsManager.changeNumber(account, secondNumber);
|
||||||
accountsManager.changeNumber(account, originalNumber);
|
accountsManager.changeNumber(account, originalNumber);
|
||||||
|
|
||||||
assertTrue(accountsManager.getByE164(originalNumber).isPresent());
|
assertTrue(accountsManager.getByE164(originalNumber).isPresent());
|
||||||
assertEquals(originalUuid, accountsManager.getByE164(originalNumber).map(Account::getUuid).orElseThrow());
|
assertEquals(originalUuid, accountsManager.getByE164(originalNumber).map(Account::getUuid).orElseThrow());
|
||||||
assertEquals(originalPni, accountsManager.getByE164(originalNumber).flatMap(Account::getPhoneNumberIdentifier).orElseThrow());
|
assertEquals(originalPni, accountsManager.getByE164(originalNumber).map(Account::getPhoneNumberIdentifier).orElseThrow());
|
||||||
|
|
||||||
assertTrue(accountsManager.getByE164(secondNumber).isEmpty());
|
assertTrue(accountsManager.getByE164(secondNumber).isEmpty());
|
||||||
|
|
||||||
|
@ -283,18 +283,18 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||||
|
|
||||||
final Account account = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
final Account account = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
||||||
final UUID originalUuid = account.getUuid();
|
final UUID originalUuid = account.getUuid();
|
||||||
final UUID originalPni = account.getPhoneNumberIdentifier().orElseThrow();
|
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||||
|
|
||||||
final Account existingAccount = accountsManager.create(secondNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
final Account existingAccount = accountsManager.create(secondNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
||||||
final UUID existingAccountUuid = existingAccount.getUuid();
|
final UUID existingAccountUuid = existingAccount.getUuid();
|
||||||
|
|
||||||
final Account changedNumberAccount = accountsManager.changeNumber(account, secondNumber);
|
final Account changedNumberAccount = accountsManager.changeNumber(account, secondNumber);
|
||||||
final UUID secondPni = changedNumberAccount.getPhoneNumberIdentifier().orElseThrow();
|
final UUID secondPni = changedNumberAccount.getPhoneNumberIdentifier();
|
||||||
|
|
||||||
final Account reRegisteredAccount = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
final Account reRegisteredAccount = accountsManager.create(originalNumber, "password", null, new AccountAttributes(), new ArrayList<>());
|
||||||
|
|
||||||
assertEquals(existingAccountUuid, reRegisteredAccount.getUuid());
|
assertEquals(existingAccountUuid, reRegisteredAccount.getUuid());
|
||||||
assertEquals(originalPni, reRegisteredAccount.getPhoneNumberIdentifier().orElseThrow());
|
assertEquals(originalPni, reRegisteredAccount.getPhoneNumberIdentifier());
|
||||||
|
|
||||||
assertEquals(Optional.empty(), deletedAccounts.findUuid(originalNumber));
|
assertEquals(Optional.empty(), deletedAccounts.findUuid(originalNumber));
|
||||||
assertEquals(Optional.empty(), deletedAccounts.findUuid(secondNumber));
|
assertEquals(Optional.empty(), deletedAccounts.findUuid(secondNumber));
|
||||||
|
@ -303,6 +303,6 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||||
|
|
||||||
assertEquals(Optional.of(originalUuid), deletedAccounts.findUuid(originalNumber));
|
assertEquals(Optional.of(originalUuid), deletedAccounts.findUuid(originalNumber));
|
||||||
assertEquals(Optional.empty(), deletedAccounts.findUuid(secondNumber));
|
assertEquals(Optional.empty(), deletedAccounts.findUuid(secondNumber));
|
||||||
assertEquals(secondPni, changedNumberReRegisteredAccount.getPhoneNumberIdentifier().orElseThrow());
|
assertEquals(secondPni, changedNumberReRegisteredAccount.getPhoneNumberIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,17 +123,17 @@ class AccountsTest {
|
||||||
boolean freshUser = accounts.create(account);
|
boolean freshUser = accounts.create(account);
|
||||||
|
|
||||||
assertThat(freshUser).isTrue();
|
assertThat(freshUser).isTrue();
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier().orElseThrow(), account.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||||
|
|
||||||
freshUser = accounts.create(account);
|
freshUser = accounts.create(account);
|
||||||
assertThat(freshUser).isTrue();
|
assertThat(freshUser).isTrue();
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier().orElseThrow(), account.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -146,10 +146,10 @@ class AccountsTest {
|
||||||
|
|
||||||
accounts.create(account);
|
accounts.create(account);
|
||||||
|
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier().orElseThrow(), account.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -272,7 +272,7 @@ class AccountsTest {
|
||||||
|
|
||||||
accounts.create(account);
|
accounts.create(account);
|
||||||
|
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists("+14151112222", firstUuid);
|
assertPhoneNumberConstraintExists("+14151112222", firstUuid);
|
||||||
assertPhoneNumberIdentifierConstraintExists(firstPni, firstUuid);
|
assertPhoneNumberIdentifierConstraintExists(firstPni, firstUuid);
|
||||||
|
@ -307,24 +307,24 @@ class AccountsTest {
|
||||||
accounts.create(account);
|
accounts.create(account);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier().orElseThrow(), account.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||||
|
|
||||||
device.setName("foobar");
|
device.setName("foobar");
|
||||||
|
|
||||||
accounts.update(account);
|
accounts.update(account);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier().orElseThrow(), account.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||||
|
|
||||||
Optional<Account> retrieved = accounts.getByE164("+14151112222");
|
Optional<Account> retrieved = accounts.getByE164("+14151112222");
|
||||||
|
|
||||||
assertThat(retrieved.isPresent()).isTrue();
|
assertThat(retrieved.isPresent()).isTrue();
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), retrieved.get(), account);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), retrieved.get(), account);
|
||||||
|
|
||||||
retrieved = accounts.getByAccountIdentifier(account.getUuid());
|
retrieved = accounts.getByAccountIdentifier(account.getUuid());
|
||||||
|
|
||||||
assertThat(retrieved.isPresent()).isTrue();
|
assertThat(retrieved.isPresent()).isTrue();
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
|
|
||||||
device = generateDevice(1);
|
device = generateDevice(1);
|
||||||
Account unknownAccount = generateAccount("+14151113333", UUID.randomUUID(), UUID.randomUUID(), Collections.singleton(device));
|
Account unknownAccount = generateAccount("+14151113333", UUID.randomUUID(), UUID.randomUUID(), Collections.singleton(device));
|
||||||
|
@ -337,7 +337,7 @@ class AccountsTest {
|
||||||
|
|
||||||
assertThat(account.getVersion()).isEqualTo(2);
|
assertThat(account.getVersion()).isEqualTo(2);
|
||||||
|
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
|
|
||||||
account.setVersion(1);
|
account.setVersion(1);
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ class AccountsTest {
|
||||||
|
|
||||||
accounts.update(account);
|
accounts.update(account);
|
||||||
|
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -413,7 +413,7 @@ class AccountsTest {
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
verifyStoredState(expectedAccount.getNumber(), expectedAccount.getUuid(), expectedAccount.getPhoneNumberIdentifier().orElseThrow(), retrievedAccount, expectedAccount);
|
verifyStoredState(expectedAccount.getNumber(), expectedAccount.getUuid(), expectedAccount.getPhoneNumberIdentifier(), retrievedAccount, expectedAccount);
|
||||||
|
|
||||||
users.remove(expectedAccount);
|
users.remove(expectedAccount);
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ class AccountsTest {
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
verifyStoredState(expectedAccount.getNumber(), expectedAccount.getUuid(), expectedAccount.getPhoneNumberIdentifier().orElseThrow(), retrievedAccount, expectedAccount);
|
verifyStoredState(expectedAccount.getNumber(), expectedAccount.getUuid(), expectedAccount.getPhoneNumberIdentifier(), retrievedAccount, expectedAccount);
|
||||||
|
|
||||||
users.remove(expectedAccount);
|
users.remove(expectedAccount);
|
||||||
}
|
}
|
||||||
|
@ -452,9 +452,9 @@ class AccountsTest {
|
||||||
accounts.create(retainedAccount);
|
accounts.create(retainedAccount);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists("+14151112222", deletedAccount.getUuid());
|
assertPhoneNumberConstraintExists("+14151112222", deletedAccount.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(deletedAccount.getPhoneNumberIdentifier().orElseThrow(), deletedAccount.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(deletedAccount.getPhoneNumberIdentifier(), deletedAccount.getUuid());
|
||||||
assertPhoneNumberConstraintExists("+14151112345", retainedAccount.getUuid());
|
assertPhoneNumberConstraintExists("+14151112345", retainedAccount.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(retainedAccount.getPhoneNumberIdentifier().orElseThrow(), retainedAccount.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(retainedAccount.getPhoneNumberIdentifier(), retainedAccount.getUuid());
|
||||||
|
|
||||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isPresent();
|
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isPresent();
|
||||||
assertThat(accounts.getByAccountIdentifier(retainedAccount.getUuid())).isPresent();
|
assertThat(accounts.getByAccountIdentifier(retainedAccount.getUuid())).isPresent();
|
||||||
|
@ -464,9 +464,9 @@ class AccountsTest {
|
||||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isNotPresent();
|
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isNotPresent();
|
||||||
|
|
||||||
assertPhoneNumberConstraintDoesNotExist(deletedAccount.getNumber());
|
assertPhoneNumberConstraintDoesNotExist(deletedAccount.getNumber());
|
||||||
assertPhoneNumberIdentifierConstraintDoesNotExist(deletedAccount.getPhoneNumberIdentifier().orElseThrow());
|
assertPhoneNumberIdentifierConstraintDoesNotExist(deletedAccount.getPhoneNumberIdentifier());
|
||||||
|
|
||||||
verifyStoredState(retainedAccount.getNumber(), retainedAccount.getUuid(), retainedAccount.getPhoneNumberIdentifier().orElseThrow(),
|
verifyStoredState(retainedAccount.getNumber(), retainedAccount.getUuid(), retainedAccount.getPhoneNumberIdentifier(),
|
||||||
accounts.getByAccountIdentifier(retainedAccount.getUuid()).get(), retainedAccount);
|
accounts.getByAccountIdentifier(retainedAccount.getUuid()).get(), retainedAccount);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -477,11 +477,11 @@ class AccountsTest {
|
||||||
|
|
||||||
assertThat(freshUser).isTrue();
|
assertThat(freshUser).isTrue();
|
||||||
assertThat(accounts.getByAccountIdentifier(recreatedAccount.getUuid())).isPresent();
|
assertThat(accounts.getByAccountIdentifier(recreatedAccount.getUuid())).isPresent();
|
||||||
verifyStoredState(recreatedAccount.getNumber(), recreatedAccount.getUuid(), recreatedAccount.getPhoneNumberIdentifier().orElseThrow(),
|
verifyStoredState(recreatedAccount.getNumber(), recreatedAccount.getUuid(), recreatedAccount.getPhoneNumberIdentifier(),
|
||||||
accounts.getByAccountIdentifier(recreatedAccount.getUuid()).get(), recreatedAccount);
|
accounts.getByAccountIdentifier(recreatedAccount.getUuid()).get(), recreatedAccount);
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists(recreatedAccount.getNumber(), recreatedAccount.getUuid());
|
assertPhoneNumberConstraintExists(recreatedAccount.getNumber(), recreatedAccount.getUuid());
|
||||||
assertPhoneNumberIdentifierConstraintExists(recreatedAccount.getPhoneNumberIdentifier().orElseThrow(), recreatedAccount.getUuid());
|
assertPhoneNumberIdentifierConstraintExists(recreatedAccount.getPhoneNumberIdentifier(), recreatedAccount.getUuid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,13 +558,13 @@ class AccountsTest {
|
||||||
Account account = generateAccount("+14151112222", UUID.randomUUID(), UUID.randomUUID(), Collections.singleton(device));
|
Account account = generateAccount("+14151112222", UUID.randomUUID(), UUID.randomUUID(), Collections.singleton(device));
|
||||||
account.setDiscoverableByPhoneNumber(false);
|
account.setDiscoverableByPhoneNumber(false);
|
||||||
accounts.create(account);
|
accounts.create(account);
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, false);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, false);
|
||||||
account.setDiscoverableByPhoneNumber(true);
|
account.setDiscoverableByPhoneNumber(true);
|
||||||
accounts.update(account);
|
accounts.update(account);
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, true);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, true);
|
||||||
account.setDiscoverableByPhoneNumber(false);
|
account.setDiscoverableByPhoneNumber(false);
|
||||||
accounts.update(account);
|
accounts.update(account);
|
||||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), account, false);
|
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), account, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -589,7 +589,7 @@ class AccountsTest {
|
||||||
final Optional<Account> retrieved = accounts.getByE164(originalNumber);
|
final Optional<Account> retrieved = accounts.getByE164(originalNumber);
|
||||||
assertThat(retrieved).isPresent();
|
assertThat(retrieved).isPresent();
|
||||||
|
|
||||||
verifyStoredState(originalNumber, account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), retrieved.get(), account);
|
verifyStoredState(originalNumber, account.getUuid(), account.getPhoneNumberIdentifier(), retrieved.get(), account);
|
||||||
}
|
}
|
||||||
|
|
||||||
accounts.changeNumber(account, targetNumber, targetPni);
|
accounts.changeNumber(account, targetNumber, targetPni);
|
||||||
|
@ -606,10 +606,9 @@ class AccountsTest {
|
||||||
final Optional<Account> retrieved = accounts.getByE164(targetNumber);
|
final Optional<Account> retrieved = accounts.getByE164(targetNumber);
|
||||||
assertThat(retrieved).isPresent();
|
assertThat(retrieved).isPresent();
|
||||||
|
|
||||||
verifyStoredState(targetNumber, account.getUuid(), account.getPhoneNumberIdentifier().orElseThrow(), retrieved.get(), account);
|
verifyStoredState(targetNumber, account.getUuid(), account.getPhoneNumberIdentifier(), retrieved.get(), account);
|
||||||
|
|
||||||
assertThat(retrieved.get().getPhoneNumberIdentifier()).isPresent();
|
assertThat(retrieved.get().getPhoneNumberIdentifier()).isEqualTo(targetPni);
|
||||||
assertThat(retrieved.get().getPhoneNumberIdentifier().get()).isEqualTo(targetPni);
|
|
||||||
assertThat(accounts.getByPhoneNumberIdentifier(targetPni)).isPresent();
|
assertThat(accounts.getByPhoneNumberIdentifier(targetPni)).isPresent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -670,218 +669,6 @@ class AccountsTest {
|
||||||
assertThrows(TransactionCanceledException.class, () -> accounts.changeNumber(account, targetNumber, existingPhoneNumberIdentifier));
|
assertThrows(TransactionCanceledException.class, () -> accounts.changeNumber(account, targetNumber, existingPhoneNumberIdentifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
// TODO Remove or adapt after initial PNI migration
|
|
||||||
void testReregistrationFromAccountWithoutPhoneNumberIdentifier() throws JsonProcessingException {
|
|
||||||
final String number = "+18005551234";
|
|
||||||
final UUID originalUuid = UUID.randomUUID();
|
|
||||||
|
|
||||||
// Artificially inject Dynamo items for a legacy account without an assigned PNI
|
|
||||||
{
|
|
||||||
final Account account = generateAccount(number, originalUuid, null);
|
|
||||||
|
|
||||||
final TransactWriteItem phoneNumberConstraintPut = TransactWriteItem.builder()
|
|
||||||
.put(
|
|
||||||
Put.builder()
|
|
||||||
.tableName(NUMBER_CONSTRAINT_TABLE_NAME)
|
|
||||||
.item(Map.of(
|
|
||||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
|
||||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.conditionExpression(
|
|
||||||
"attribute_not_exists(#number) OR (attribute_exists(#number) AND #uuid = :uuid)")
|
|
||||||
.expressionAttributeNames(
|
|
||||||
Map.of("#uuid", Accounts.KEY_ACCOUNT_UUID,
|
|
||||||
"#number", Accounts.ATTR_ACCOUNT_E164))
|
|
||||||
.expressionAttributeValues(
|
|
||||||
Map.of(":uuid", AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.returnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final Map<String, AttributeValue> item = new HashMap<>(Map.of(
|
|
||||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
|
||||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
|
||||||
Accounts.ATTR_ACCOUNT_DATA,
|
|
||||||
AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
|
||||||
Accounts.ATTR_VERSION, AttributeValues.fromInt(account.getVersion()),
|
|
||||||
Accounts.ATTR_CANONICALLY_DISCOVERABLE, AttributeValues.fromBool(account.shouldBeVisibleInDirectory())));
|
|
||||||
|
|
||||||
final TransactWriteItem accountPut = TransactWriteItem.builder()
|
|
||||||
.put(Put.builder()
|
|
||||||
.conditionExpression("attribute_not_exists(#number) OR #number = :number")
|
|
||||||
.expressionAttributeNames(Map.of("#number", Accounts.ATTR_ACCOUNT_E164))
|
|
||||||
.expressionAttributeValues(Map.of(":number", AttributeValues.fromString(account.getNumber())))
|
|
||||||
.tableName(ACCOUNTS_TABLE_NAME)
|
|
||||||
.item(item)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
dynamoDbExtension.getDynamoDbClient().transactWriteItems(TransactWriteItemsRequest.builder()
|
|
||||||
.transactItems(phoneNumberConstraintPut, accountPut)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
final Account reregisteredAccount = generateAccount(number, UUID.randomUUID(), UUID.randomUUID());
|
|
||||||
accounts.create(reregisteredAccount);
|
|
||||||
|
|
||||||
assertPhoneNumberConstraintExists(number, originalUuid);
|
|
||||||
assertPhoneNumberIdentifierConstraintExists(reregisteredAccount.getPhoneNumberIdentifier().orElseThrow(), originalUuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
// TODO Remove or adapt after initial PNI migration
|
|
||||||
void testUpdateAccountAddingPniWithoutPhoneNumberIdentifier() throws JsonProcessingException {
|
|
||||||
final String number = "+18005551234";
|
|
||||||
final UUID uuid = UUID.randomUUID();
|
|
||||||
|
|
||||||
// Artificially inject Dynamo items for a legacy account without an assigned PNI
|
|
||||||
{
|
|
||||||
final Account account = generateAccount(number, uuid, null);
|
|
||||||
|
|
||||||
final TransactWriteItem phoneNumberConstraintPut = TransactWriteItem.builder()
|
|
||||||
.put(
|
|
||||||
Put.builder()
|
|
||||||
.tableName(NUMBER_CONSTRAINT_TABLE_NAME)
|
|
||||||
.item(Map.of(
|
|
||||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
|
||||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.conditionExpression(
|
|
||||||
"attribute_not_exists(#number) OR (attribute_exists(#number) AND #uuid = :uuid)")
|
|
||||||
.expressionAttributeNames(
|
|
||||||
Map.of("#uuid", Accounts.KEY_ACCOUNT_UUID,
|
|
||||||
"#number", Accounts.ATTR_ACCOUNT_E164))
|
|
||||||
.expressionAttributeValues(
|
|
||||||
Map.of(":uuid", AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.returnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final Map<String, AttributeValue> item = new HashMap<>(Map.of(
|
|
||||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
|
||||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
|
||||||
Accounts.ATTR_ACCOUNT_DATA,
|
|
||||||
AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
|
||||||
Accounts.ATTR_VERSION, AttributeValues.fromInt(account.getVersion()),
|
|
||||||
Accounts.ATTR_CANONICALLY_DISCOVERABLE, AttributeValues.fromBool(account.shouldBeVisibleInDirectory())));
|
|
||||||
|
|
||||||
final TransactWriteItem accountPut = TransactWriteItem.builder()
|
|
||||||
.put(Put.builder()
|
|
||||||
.conditionExpression("attribute_not_exists(#number) OR #number = :number")
|
|
||||||
.expressionAttributeNames(Map.of("#number", Accounts.ATTR_ACCOUNT_E164))
|
|
||||||
.expressionAttributeValues(Map.of(":number", AttributeValues.fromString(account.getNumber())))
|
|
||||||
.tableName(ACCOUNTS_TABLE_NAME)
|
|
||||||
.item(item)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
dynamoDbExtension.getDynamoDbClient().transactWriteItems(TransactWriteItemsRequest.builder()
|
|
||||||
.transactItems(phoneNumberConstraintPut, accountPut)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(accounts.getByAccountIdentifier(uuid)).hasValueSatisfying(account -> {
|
|
||||||
assertThat(account.getUuid()).isEqualTo(uuid);
|
|
||||||
assertThat(account.getNumber()).isEqualTo(number);
|
|
||||||
assertThat(account.getPhoneNumberIdentifier()).isEmpty();
|
|
||||||
});
|
|
||||||
|
|
||||||
final UUID phoneNumberIdentifier = UUID.randomUUID();
|
|
||||||
|
|
||||||
{
|
|
||||||
final Account accountToUpdate = accounts.getByAccountIdentifier(uuid).orElseThrow();
|
|
||||||
accountToUpdate.setNumber(number, phoneNumberIdentifier);
|
|
||||||
|
|
||||||
assertThat(accountToUpdate.getPhoneNumberIdentifier()).hasValueSatisfying(pni ->
|
|
||||||
assertThat(pni).isEqualTo(phoneNumberIdentifier));
|
|
||||||
|
|
||||||
accounts.update(accountToUpdate);
|
|
||||||
|
|
||||||
assertThat(accountToUpdate.getPhoneNumberIdentifier()).hasValueSatisfying(pni ->
|
|
||||||
assertThat(pni).isEqualTo(phoneNumberIdentifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(accounts.getByAccountIdentifier(uuid)).hasValueSatisfying(account -> {
|
|
||||||
assertThat(account.getUuid()).isEqualTo(uuid);
|
|
||||||
assertThat(account.getNumber()).isEqualTo(number);
|
|
||||||
assertThat(account.getPhoneNumberIdentifier()).hasValueSatisfying(pni ->
|
|
||||||
assertThat(pni).isEqualTo(phoneNumberIdentifier));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
// TODO Remove or adapt after initial PNI migration
|
|
||||||
void testUpdateAccountWithoutPhoneNumberIdentifier() throws JsonProcessingException {
|
|
||||||
final String number = "+18005551234";
|
|
||||||
final UUID uuid = UUID.randomUUID();
|
|
||||||
|
|
||||||
// Artificially inject Dynamo items for a legacy account without an assigned PNI
|
|
||||||
{
|
|
||||||
final Account account = generateAccount(number, uuid, null);
|
|
||||||
|
|
||||||
final TransactWriteItem phoneNumberConstraintPut = TransactWriteItem.builder()
|
|
||||||
.put(
|
|
||||||
Put.builder()
|
|
||||||
.tableName(NUMBER_CONSTRAINT_TABLE_NAME)
|
|
||||||
.item(Map.of(
|
|
||||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
|
||||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.conditionExpression(
|
|
||||||
"attribute_not_exists(#number) OR (attribute_exists(#number) AND #uuid = :uuid)")
|
|
||||||
.expressionAttributeNames(
|
|
||||||
Map.of("#uuid", Accounts.KEY_ACCOUNT_UUID,
|
|
||||||
"#number", Accounts.ATTR_ACCOUNT_E164))
|
|
||||||
.expressionAttributeValues(
|
|
||||||
Map.of(":uuid", AttributeValues.fromUUID(account.getUuid())))
|
|
||||||
.returnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final Map<String, AttributeValue> item = new HashMap<>(Map.of(
|
|
||||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
|
||||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
|
||||||
Accounts.ATTR_ACCOUNT_DATA,
|
|
||||||
AttributeValues.fromByteArray(SystemMapper.getMapper().writeValueAsBytes(account)),
|
|
||||||
Accounts.ATTR_VERSION, AttributeValues.fromInt(account.getVersion()),
|
|
||||||
Accounts.ATTR_CANONICALLY_DISCOVERABLE, AttributeValues.fromBool(account.shouldBeVisibleInDirectory())));
|
|
||||||
|
|
||||||
final TransactWriteItem accountPut = TransactWriteItem.builder()
|
|
||||||
.put(Put.builder()
|
|
||||||
.conditionExpression("attribute_not_exists(#number) OR #number = :number")
|
|
||||||
.expressionAttributeNames(Map.of("#number", Accounts.ATTR_ACCOUNT_E164))
|
|
||||||
.expressionAttributeValues(Map.of(":number", AttributeValues.fromString(account.getNumber())))
|
|
||||||
.tableName(ACCOUNTS_TABLE_NAME)
|
|
||||||
.item(item)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
dynamoDbExtension.getDynamoDbClient().transactWriteItems(TransactWriteItemsRequest.builder()
|
|
||||||
.transactItems(phoneNumberConstraintPut, accountPut)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(accounts.getByAccountIdentifier(uuid)).hasValueSatisfying(account -> {
|
|
||||||
assertThat(account.getUuid()).isEqualTo(uuid);
|
|
||||||
assertThat(account.getNumber()).isEqualTo(number);
|
|
||||||
assertThat(account.getPhoneNumberIdentifier()).isEmpty();
|
|
||||||
});
|
|
||||||
|
|
||||||
final String updatedName = "An updated name!";
|
|
||||||
|
|
||||||
{
|
|
||||||
final Account accountToUpdate = accounts.getByAccountIdentifier(uuid).orElseThrow();
|
|
||||||
accountToUpdate.setProfileName(updatedName);
|
|
||||||
|
|
||||||
accounts.update(accountToUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
assertThat(accounts.getByAccountIdentifier(uuid)).hasValueSatisfying(account -> {
|
|
||||||
assertThat(account.getUuid()).isEqualTo(uuid);
|
|
||||||
assertThat(account.getNumber()).isEqualTo(number);
|
|
||||||
assertThat(account.getPhoneNumberIdentifier()).isEmpty();
|
|
||||||
assertThat(account.getProfileName()).isEqualTo(updatedName);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Device generateDevice(long id) {
|
private Device generateDevice(long id) {
|
||||||
Random random = new Random(System.currentTimeMillis());
|
Random random = new Random(System.currentTimeMillis());
|
||||||
SignedPreKey signedPreKey = new SignedPreKey(random.nextInt(), "testPublicKey-" + random.nextInt(), "testSignature-" + random.nextInt());
|
SignedPreKey signedPreKey = new SignedPreKey(random.nextInt(), "testPublicKey-" + random.nextInt(), "testSignature-" + random.nextInt());
|
||||||
|
@ -973,7 +760,7 @@ class AccountsTest {
|
||||||
|
|
||||||
private void verifyStoredState(String number, UUID uuid, UUID pni, Account result, Account expecting) {
|
private void verifyStoredState(String number, UUID uuid, UUID pni, Account result, Account expecting) {
|
||||||
assertThat(result.getNumber()).isEqualTo(number);
|
assertThat(result.getNumber()).isEqualTo(number);
|
||||||
assertThat(result.getPhoneNumberIdentifier()).isEqualTo(Optional.ofNullable(pni));
|
assertThat(result.getPhoneNumberIdentifier()).isEqualTo(pni);
|
||||||
assertThat(result.getLastSeen()).isEqualTo(expecting.getLastSeen());
|
assertThat(result.getLastSeen()).isEqualTo(expecting.getLastSeen());
|
||||||
assertThat(result.getUuid()).isEqualTo(uuid);
|
assertThat(result.getUuid()).isEqualTo(uuid);
|
||||||
assertThat(result.getVersion()).isEqualTo(expecting.getVersion());
|
assertThat(result.getVersion()).isEqualTo(expecting.getVersion());
|
||||||
|
|
|
@ -220,7 +220,7 @@ class CertificateControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetSingleAuthCredentialByPni() {
|
void testGetSingleAuthCredentialByPni() {
|
||||||
when(AuthHelper.VALID_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(Optional.of(UUID.randomUUID()));
|
when(AuthHelper.VALID_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(UUID.randomUUID());
|
||||||
|
|
||||||
GroupCredentials credentials = resources.getJerseyTest()
|
GroupCredentials credentials = resources.getJerseyTest()
|
||||||
.target("/v1/certificate/group/" + Util.currentDaysSinceEpoch() + "/" + Util.currentDaysSinceEpoch())
|
.target("/v1/certificate/group/" + Util.currentDaysSinceEpoch() + "/" + Util.currentDaysSinceEpoch())
|
||||||
|
@ -239,20 +239,6 @@ class CertificateControllerTest {
|
||||||
clientZkAuthOperations.receiveAuthCredential(AuthHelper.VALID_UUID, Util.currentDaysSinceEpoch(), new AuthCredentialResponse(credentials.getCredentials().get(0).getCredential())));
|
clientZkAuthOperations.receiveAuthCredential(AuthHelper.VALID_UUID, Util.currentDaysSinceEpoch(), new AuthCredentialResponse(credentials.getCredentials().get(0).getCredential())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testGetSingleAuthCredentialByPniNotSet() {
|
|
||||||
when(AuthHelper.VALID_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(Optional.empty());
|
|
||||||
|
|
||||||
Response response = resources.getJerseyTest()
|
|
||||||
.target("/v1/certificate/group/" + Util.currentDaysSinceEpoch() + "/" + Util.currentDaysSinceEpoch())
|
|
||||||
.queryParam("identity", "pni")
|
|
||||||
.request()
|
|
||||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertThat(response.getStatus()).isEqualTo(404);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetWeekLongAuthCredentials() {
|
void testGetWeekLongAuthCredentials() {
|
||||||
GroupCredentials credentials = resources.getJerseyTest()
|
GroupCredentials credentials = resources.getJerseyTest()
|
||||||
|
|
|
@ -153,7 +153,7 @@ class KeysControllerTest {
|
||||||
when(sampleDevice4.getId()).thenReturn(4L);
|
when(sampleDevice4.getId()).thenReturn(4L);
|
||||||
|
|
||||||
when(existsAccount.getUuid()).thenReturn(EXISTS_UUID);
|
when(existsAccount.getUuid()).thenReturn(EXISTS_UUID);
|
||||||
when(existsAccount.getPhoneNumberIdentifier()).thenReturn(Optional.of(EXISTS_PNI));
|
when(existsAccount.getPhoneNumberIdentifier()).thenReturn(EXISTS_PNI);
|
||||||
when(existsAccount.getDevice(1L)).thenReturn(Optional.of(sampleDevice));
|
when(existsAccount.getDevice(1L)).thenReturn(Optional.of(sampleDevice));
|
||||||
when(existsAccount.getDevice(2L)).thenReturn(Optional.of(sampleDevice2));
|
when(existsAccount.getDevice(2L)).thenReturn(Optional.of(sampleDevice2));
|
||||||
when(existsAccount.getDevice(3L)).thenReturn(Optional.of(sampleDevice3));
|
when(existsAccount.getDevice(3L)).thenReturn(Optional.of(sampleDevice3));
|
||||||
|
|
|
@ -155,7 +155,7 @@ class AccountsManagerTest {
|
||||||
assertTrue(account.isPresent());
|
assertTrue(account.isPresent());
|
||||||
assertEquals(account.get().getNumber(), "+14152222222");
|
assertEquals(account.get().getNumber(), "+14152222222");
|
||||||
assertEquals(account.get().getProfileName(), "test");
|
assertEquals(account.get().getProfileName(), "test");
|
||||||
assertEquals(Optional.of(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e")), account.get().getPhoneNumberIdentifier());
|
assertEquals(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e"), account.get().getPhoneNumberIdentifier());
|
||||||
|
|
||||||
verify(commands, times(1)).get(eq("AccountMap::+14152222222"));
|
verify(commands, times(1)).get(eq("AccountMap::+14152222222"));
|
||||||
verify(commands, times(1)).get(eq("Account3::" + uuid));
|
verify(commands, times(1)).get(eq("Account3::" + uuid));
|
||||||
|
@ -176,7 +176,7 @@ class AccountsManagerTest {
|
||||||
assertEquals(account.get().getNumber(), "+14152222222");
|
assertEquals(account.get().getNumber(), "+14152222222");
|
||||||
assertEquals(account.get().getUuid(), uuid);
|
assertEquals(account.get().getUuid(), uuid);
|
||||||
assertEquals(account.get().getProfileName(), "test");
|
assertEquals(account.get().getProfileName(), "test");
|
||||||
assertEquals(Optional.of(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e")), account.get().getPhoneNumberIdentifier());
|
assertEquals(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e"), account.get().getPhoneNumberIdentifier());
|
||||||
|
|
||||||
verify(commands, times(1)).get(eq("Account3::" + uuid));
|
verify(commands, times(1)).get(eq("Account3::" + uuid));
|
||||||
verifyNoMoreInteractions(commands);
|
verifyNoMoreInteractions(commands);
|
||||||
|
@ -197,7 +197,7 @@ class AccountsManagerTest {
|
||||||
assertTrue(account.isPresent());
|
assertTrue(account.isPresent());
|
||||||
assertEquals(account.get().getNumber(), "+14152222222");
|
assertEquals(account.get().getNumber(), "+14152222222");
|
||||||
assertEquals(account.get().getProfileName(), "test");
|
assertEquals(account.get().getProfileName(), "test");
|
||||||
assertEquals(Optional.of(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e")), account.get().getPhoneNumberIdentifier());
|
assertEquals(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e"), account.get().getPhoneNumberIdentifier());
|
||||||
|
|
||||||
verify(commands).get(eq("AccountMap::" + pni));
|
verify(commands).get(eq("AccountMap::" + pni));
|
||||||
verify(commands).get(eq("Account3::" + uuid));
|
verify(commands).get(eq("Account3::" + uuid));
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class AccountsHelper {
|
||||||
} else {
|
} else {
|
||||||
final ObjectMapper mapper = SystemMapper.getMapper();
|
final ObjectMapper mapper = SystemMapper.getMapper();
|
||||||
updatedAccount = mapper.readValue(mapper.writeValueAsBytes(account), Account.class);
|
updatedAccount = mapper.readValue(mapper.writeValueAsBytes(account), Account.class);
|
||||||
updatedAccount.setNumber(account.getNumber(), account.getPhoneNumberIdentifier().orElse(null));
|
updatedAccount.setNumber(account.getNumber(), account.getPhoneNumberIdentifier());
|
||||||
account.markStale();
|
account.markStale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class AuthHelper {
|
||||||
|
|
||||||
when(VALID_ACCOUNT.getNumber()).thenReturn(VALID_NUMBER);
|
when(VALID_ACCOUNT.getNumber()).thenReturn(VALID_NUMBER);
|
||||||
when(VALID_ACCOUNT.getUuid()).thenReturn(VALID_UUID);
|
when(VALID_ACCOUNT.getUuid()).thenReturn(VALID_UUID);
|
||||||
when(VALID_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(Optional.of(VALID_PNI));
|
when(VALID_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(VALID_PNI);
|
||||||
when(VALID_ACCOUNT_TWO.getNumber()).thenReturn(VALID_NUMBER_TWO);
|
when(VALID_ACCOUNT_TWO.getNumber()).thenReturn(VALID_NUMBER_TWO);
|
||||||
when(VALID_ACCOUNT_TWO.getUuid()).thenReturn(VALID_UUID_TWO);
|
when(VALID_ACCOUNT_TWO.getUuid()).thenReturn(VALID_UUID_TWO);
|
||||||
when(DISABLED_ACCOUNT.getNumber()).thenReturn(DISABLED_NUMBER);
|
when(DISABLED_ACCOUNT.getNumber()).thenReturn(DISABLED_NUMBER);
|
||||||
|
|
Loading…
Reference in New Issue