mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 06:26:47 +00:00
Rename Account#getUUID() to Account#getAccountIdentifier()
This commit is contained in:
1 parent
7b472afbcb
commit
20cf3d7429
81 files changed
+421
-427
No files matched your search
+1
-1
@@ -126,7 +126,7 @@ public class AccountAuthenticator implements Authenticator<BasicCredentials, Aut
|
||||
@VisibleForTesting
|
||||
public Account updateLastSeen(Account account, Device device) {
|
||||
// compute a non-negative integer between 0 and 86400.
|
||||
long n = Util.ensureNonNegativeLong(account.getUuid().getLeastSignificantBits());
|
||||
long n = Util.ensureNonNegativeLong(account.getAccountIdentifier().getLeastSignificantBits());
|
||||
final long lastSeenOffsetSeconds = n % ChronoUnit.DAYS.getDuration().toSeconds();
|
||||
|
||||
// produce a truncated timestamp which is either today at UTC midnight
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class CertificateGenerator {
|
||||
.setSenderDevice(Math.toIntExact(deviceId))
|
||||
.setExpires(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(expiresDays))
|
||||
.setIdentityKey(ByteString.copyFrom(account.getIdentityKey(IdentityType.ACI).serialize()))
|
||||
.setSenderUuid(UUIDUtil.toByteString(account.getUuid()));
|
||||
.setSenderUuid(UUIDUtil.toByteString(account.getAccountIdentifier()));
|
||||
|
||||
if (includeE164) {
|
||||
builder.setSenderE164(account.getNumber());
|
||||
|
||||
+2
-2
@@ -154,7 +154,7 @@ public class RegistrationLockVerificationManager {
|
||||
}
|
||||
|
||||
final List<Byte> deviceIds = updatedAccount.getDevices().stream().map(Device::getId).toList();
|
||||
disconnectionRequestManager.requestDisconnection(updatedAccount.getUuid(), deviceIds);
|
||||
disconnectionRequestManager.requestDisconnection(updatedAccount.getAccountIdentifier(), deviceIds);
|
||||
|
||||
try {
|
||||
// Send a push notification that prompts the client to attempt login and fail due to locked credentials
|
||||
@@ -176,7 +176,7 @@ public class RegistrationLockVerificationManager {
|
||||
if (!existingRegistrationLock.needsFailureCredentials()) {
|
||||
return null;
|
||||
}
|
||||
return svr2CredentialGenerator.generateForUuid(account.getUuid());
|
||||
return svr2CredentialGenerator.generateForUuid(account.getAccountIdentifier());
|
||||
}
|
||||
|
||||
}
|
||||
+6
-6
@@ -136,11 +136,11 @@ public class BackupAuthManager {
|
||||
}
|
||||
|
||||
if (requiresMessageRotation) {
|
||||
rateLimiters.forDescriptor(RateLimiters.For.SET_BACKUP_ID).validate(account.getUuid());
|
||||
rateLimiters.forDescriptor(RateLimiters.For.SET_BACKUP_ID).validate(account.getAccountIdentifier());
|
||||
}
|
||||
|
||||
if (requiresMediaRotation && hasActiveVoucher(account)) {
|
||||
rateLimiters.forDescriptor(RateLimiters.For.SET_PAID_MEDIA_BACKUP_ID).validate(account.getUuid());
|
||||
rateLimiters.forDescriptor(RateLimiters.For.SET_PAID_MEDIA_BACKUP_ID).validate(account.getAccountIdentifier());
|
||||
}
|
||||
|
||||
this.accountsManager.update(account, a ->
|
||||
@@ -156,9 +156,9 @@ public class BackupAuthManager {
|
||||
final boolean isPaid = hasActiveVoucher(account);
|
||||
|
||||
final CompletionStage<Boolean> hasSetMessagesPermits =
|
||||
messagesLimiter.hasAvailablePermitsAsync(account.getUuid(), 1);
|
||||
messagesLimiter.hasAvailablePermitsAsync(account.getAccountIdentifier(), 1);
|
||||
final CompletionStage<Boolean> hasSetMediaPermits = isPaid
|
||||
? mediaLimiter.hasAvailablePermitsAsync(account.getUuid(), 1)
|
||||
? mediaLimiter.hasAvailablePermitsAsync(account.getAccountIdentifier(), 1)
|
||||
: CompletableFuture.completedFuture(true);
|
||||
|
||||
return hasSetMessagesPermits.thenCombine(hasSetMediaPermits, (hasMessage, hasMedia) -> {
|
||||
@@ -266,7 +266,7 @@ public class BackupAuthManager {
|
||||
}
|
||||
|
||||
boolean receiptAllowed = redeemedReceiptsManager
|
||||
.put(receiptSerial, receiptExpiration.getEpochSecond(), receiptLevel, account.getUuid());
|
||||
.put(receiptSerial, receiptExpiration.getEpochSecond(), receiptLevel, account.getAccountIdentifier());
|
||||
if (!receiptAllowed) {
|
||||
throw new BackupBadReceiptException("receipt serial is already redeemed");
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class BackupAuthManager {
|
||||
* BackupVoucher.
|
||||
*/
|
||||
private BackupLevel configuredBackupLevel(final Account account) {
|
||||
return this.experimentEnrollmentManager.isEnrolled(account.getUuid(), BACKUP_MEDIA_EXPERIMENT_NAME)
|
||||
return this.experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), BACKUP_MEDIA_EXPERIMENT_NAME)
|
||||
? BackupLevel.PAID
|
||||
: BackupLevel.FREE;
|
||||
}
|
||||
|
||||
+1
-1
@@ -389,7 +389,7 @@ public class AccountController {
|
||||
throw new WebApplicationException(Response.status(422).build());
|
||||
}
|
||||
|
||||
return accounts.getByUsernameHash(hash).thenApply(maybeAccount -> maybeAccount.map(Account::getUuid)
|
||||
return accounts.getByUsernameHash(hash).thenApply(maybeAccount -> maybeAccount.map(Account::getAccountIdentifier)
|
||||
.map(AciServiceIdentifier::new)
|
||||
.map(AccountIdentifierResponse::new)
|
||||
.orElseThrow(() -> new WebApplicationException(Status.NOT_FOUND)));
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class AccountIdentityResponseBuilder {
|
||||
.map(bv -> new Entitlements.BackupEntitlement(bv.receiptLevel(), bv.expiration()))
|
||||
.orElse(null);
|
||||
|
||||
return new AccountIdentityResponse(account.getUuid(),
|
||||
return new AccountIdentityResponse(account.getAccountIdentifier(),
|
||||
account.getNumber(),
|
||||
account.getPhoneNumberIdentifier(),
|
||||
account.getUsernameHash().filter(h -> h.length > 0).orElse(null),
|
||||
|
||||
+3
-3
@@ -196,7 +196,7 @@ public class DeviceController {
|
||||
final Account account = accounts.getByAccountIdentifier(auth.accountIdentifier())
|
||||
.orElseThrow(() -> new WebApplicationException(Response.Status.UNAUTHORIZED));
|
||||
|
||||
rateLimiters.getAllocateDeviceLimiter().validate(account.getUuid());
|
||||
rateLimiters.getAllocateDeviceLimiter().validate(account.getAccountIdentifier());
|
||||
|
||||
if (account.getDevices().size() >= MAX_DEVICES) {
|
||||
throw new DeviceLimitExceededException(account.getDevices().size(), MAX_DEVICES);
|
||||
@@ -206,7 +206,7 @@ public class DeviceController {
|
||||
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
final String token = accounts.generateLinkDeviceToken(account.getUuid());
|
||||
final String token = accounts.generateLinkDeviceToken(account.getAccountIdentifier());
|
||||
|
||||
return new LinkDeviceToken(token, AccountsManager.getLinkDeviceTokenIdentifier(token));
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class DeviceController {
|
||||
final DeviceActivationRequest deviceActivationRequest = linkDeviceRequest.deviceActivationRequest();
|
||||
final DeviceAttributes deviceAttributes = linkDeviceRequest.deviceAttributes();
|
||||
|
||||
rateLimiters.getVerifyDeviceLimiter().validate(account.getUuid());
|
||||
rateLimiters.getVerifyDeviceLimiter().validate(account.getAccountIdentifier());
|
||||
|
||||
final boolean allKeysValid =
|
||||
PreKeySignatureValidator.validatePreKeySignatures(account.getIdentityKey(IdentityType.ACI),
|
||||
|
||||
+1
-1
@@ -426,7 +426,7 @@ public class KeysController {
|
||||
.flatMap(targetAccount::getDevice)
|
||||
.map(device -> device.getRegistrationId(targetIdentifier.identityType()));
|
||||
return RateLimitKeys.preKeyLimiterKey(
|
||||
account.getUuid(),
|
||||
account.getAccountIdentifier(),
|
||||
authenticatedDevice.deviceId(),
|
||||
targetIdentifier,
|
||||
parsedTargetDeviceId, targetRegistrationId);
|
||||
|
||||
+3
-3
@@ -263,7 +263,7 @@ public class MessageController {
|
||||
final Account destination =
|
||||
accountsManager.getByServiceIdentifier(destinationIdentifier).orElseThrow(NotFoundException::new);
|
||||
|
||||
rateLimiters.getMessagesLimiter().validate(source.accountIdentifier(), destination.getUuid());
|
||||
rateLimiters.getMessagesLimiter().validate(source.accountIdentifier(), destination.getAccountIdentifier());
|
||||
|
||||
sendIndividualMessage(destination,
|
||||
destinationIdentifier,
|
||||
@@ -335,7 +335,7 @@ public class MessageController {
|
||||
final Account destination = accountsManager.getByServiceIdentifier(destinationIdentifier).orElseThrow(() ->
|
||||
new WebApplicationException(Response.ok(new SendMessageResponse(false)).build()));
|
||||
|
||||
rateLimiters.getStoriesLimiter().validate(destination.getUuid());
|
||||
rateLimiters.getStoriesLimiter().validate(destination.getAccountIdentifier());
|
||||
|
||||
sendIndividualMessage(destination,
|
||||
destinationIdentifier,
|
||||
@@ -744,7 +744,7 @@ public class MessageController {
|
||||
sourceNumber = Optional.of(source);
|
||||
final Optional<Account> maybeAccount = accountsManager.getByE164(source);
|
||||
if (maybeAccount.isPresent()) {
|
||||
sourceAci = maybeAccount.map(Account::getUuid);
|
||||
sourceAci = maybeAccount.map(Account::getAccountIdentifier);
|
||||
sourcePni = maybeAccount.map(Account::getPhoneNumberIdentifier);
|
||||
} else {
|
||||
sourcePni = Optional.ofNullable(phoneNumberIdentifiers.getPhoneNumberIdentifier(source).join());
|
||||
|
||||
+8
-8
@@ -245,7 +245,7 @@ public class ProfileController {
|
||||
|
||||
return buildVersionedProfileResponse(targetAccount,
|
||||
version,
|
||||
maybeRequester.map(requester -> ProfileHelper.isSelfProfileRequest(requester.getUuid(), accountIdentifier)).orElse(false),
|
||||
maybeRequester.map(requester -> ProfileHelper.isSelfProfileRequest(requester.getAccountIdentifier(), accountIdentifier)).orElse(false),
|
||||
false,
|
||||
containerRequestContext);
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class ProfileController {
|
||||
.orElseThrow(() -> new WebApplicationException(Response.Status.UNAUTHORIZED)));
|
||||
|
||||
final Account targetAccount = verifyPermissionToReceiveProfile(maybeRequester, accessKey, accountIdentifier, "credentialRequest", userAgent);
|
||||
final boolean isSelf = maybeRequester.map(requester -> ProfileHelper.isSelfProfileRequest(requester.getUuid(), accountIdentifier)).orElse(false);
|
||||
final boolean isSelf = maybeRequester.map(requester -> ProfileHelper.isSelfProfileRequest(requester.getAccountIdentifier(), accountIdentifier)).orElse(false);
|
||||
|
||||
return buildExpiringProfileKeyCredentialProfileResponse(targetAccount,
|
||||
version,
|
||||
@@ -341,7 +341,7 @@ public class ProfileController {
|
||||
}
|
||||
return switch (identifier.identityType()) {
|
||||
case ACI -> buildBaseProfileResponseForAccountIdentity(targetAccount,
|
||||
maybeRequester.map(requester -> ProfileHelper.isSelfProfileRequest(requester.getUuid(), identifier)).orElse(false),
|
||||
maybeRequester.map(requester -> ProfileHelper.isSelfProfileRequest(requester.getAccountIdentifier(), identifier)).orElse(false),
|
||||
containerRequestContext);
|
||||
case PNI -> buildBaseProfileResponseForPhoneNumberIdentity(targetAccount);
|
||||
};
|
||||
@@ -426,13 +426,13 @@ public class ProfileController {
|
||||
final ExpiringProfileKeyCredentialResponse expiringProfileKeyCredentialResponse;
|
||||
|
||||
if (account.getCurrentProfileVersion().map(v -> HexFormat.of().formatHex(v).equals(version)).orElse(false)) {
|
||||
expiringProfileKeyCredentialResponse = profilesManager.getV1(account.getUuid(), version)
|
||||
expiringProfileKeyCredentialResponse = profilesManager.getV1(account.getAccountIdentifier(), version)
|
||||
.map(profile -> {
|
||||
final ExpiringProfileKeyCredentialResponse profileKeyCredentialResponse;
|
||||
try {
|
||||
profileKeyCredentialResponse = ProfileHelper.getExpiringProfileKeyCredential(
|
||||
new ProfileKeyCredentialRequest(HexFormat.of().parseHex(encodedCredentialRequest)),
|
||||
new ProfileKeyCommitment(profile.commitment()), new ServiceId.Aci(account.getUuid()),
|
||||
new ProfileKeyCommitment(profile.commitment()), new ServiceId.Aci(account.getAccountIdentifier()),
|
||||
zkProfileOperations);
|
||||
} catch (VerificationFailedException | InvalidInputException e) {
|
||||
throw new BadRequestException(e);
|
||||
@@ -455,7 +455,7 @@ public class ProfileController {
|
||||
final boolean hasCredentialRequest,
|
||||
final ContainerRequestContext containerRequestContext) {
|
||||
|
||||
final Optional<VersionedProfileV1> maybeProfile = profilesManager.getV1(account.getUuid(), version);
|
||||
final Optional<VersionedProfileV1> maybeProfile = profilesManager.getV1(account.getAccountIdentifier(), version);
|
||||
|
||||
if (maybeProfile.isEmpty()) {
|
||||
// this can happen if an account re-registers, which includes some device-transfer scenarios
|
||||
@@ -498,7 +498,7 @@ public class ProfileController {
|
||||
HeaderUtils.getAcceptableLanguagesForRequest(containerRequestContext),
|
||||
account.getBadges(),
|
||||
isSelf),
|
||||
new AciServiceIdentifier(account.getUuid()));
|
||||
new AciServiceIdentifier(account.getAccountIdentifier()));
|
||||
}
|
||||
|
||||
private BaseProfileResponse buildBaseProfileResponseForPhoneNumberIdentity(final Account account) {
|
||||
@@ -537,7 +537,7 @@ public class ProfileController {
|
||||
}
|
||||
|
||||
if (maybeRequester.isPresent()) {
|
||||
rateLimiters.getProfileLimiter().validate(maybeRequester.get().getUuid());
|
||||
rateLimiters.getProfileLimiter().validate(maybeRequester.get().getAccountIdentifier());
|
||||
}
|
||||
|
||||
final Optional<Account> maybeTargetAccount = accountsManager.getByServiceIdentifier(accountIdentifier);
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class SecureValueRecovery2Controller {
|
||||
// the username associated with the provided number
|
||||
final Optional<String> matchingUsername = accountsManager
|
||||
.getByE164(request.number())
|
||||
.map(Account::getUuid)
|
||||
.map(Account::getAccountIdentifier)
|
||||
.map(backupServiceCredentialGenerator::generateForUuid)
|
||||
.map(ExternalServiceCredentials::username);
|
||||
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class AccountsAnonymousGrpcService extends SimpleAccountsAnonymousGrpc.Ac
|
||||
|
||||
return accountsManager.getByUsernameHash(request.getUsernameHash().toByteArray()).join()
|
||||
.map(account -> LookupUsernameHashResponse.newBuilder()
|
||||
.setServiceIdentifier(GrpcServiceIdentifierUtil.toGrpcServiceIdentifier(new AciServiceIdentifier(account.getUuid())))
|
||||
.setServiceIdentifier(GrpcServiceIdentifierUtil.toGrpcServiceIdentifier(new AciServiceIdentifier(account.getAccountIdentifier())))
|
||||
.build())
|
||||
.orElseGet(() -> LookupUsernameHashResponse.newBuilder().setNotFound(NotFound.getDefaultInstance()).build());
|
||||
}
|
||||
|
||||
+1
-4
@@ -16,7 +16,6 @@ import java.util.HexFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -62,7 +61,6 @@ import org.signal.chat.account.StaleDevices;
|
||||
import org.signal.chat.account.UsernameNotAvailable;
|
||||
import org.signal.chat.common.AccountIdentifiers;
|
||||
import org.signal.chat.errors.FailedPrecondition;
|
||||
import org.signal.chat.errors.NotFound;
|
||||
import org.signal.chat.messages.SendMessageType;
|
||||
import org.signal.libsignal.protocol.IdentityKey;
|
||||
import org.signal.libsignal.protocol.InvalidKeyException;
|
||||
@@ -73,7 +71,6 @@ import org.whispersystems.textsecuregcm.auth.InvalidRegistrationSessionException
|
||||
import org.whispersystems.textsecuregcm.auth.RecoveryPasswordVerificationFailedException;
|
||||
import org.whispersystems.textsecuregcm.auth.RegistrationLockFailureException;
|
||||
import org.whispersystems.textsecuregcm.auth.SaltedTokenHash;
|
||||
import org.whispersystems.textsecuregcm.auth.UnidentifiedAccessUtil;
|
||||
import org.whispersystems.textsecuregcm.auth.UnverifiedRegistrationSessionException;
|
||||
import org.whispersystems.textsecuregcm.auth.grpc.AuthenticatedDevice;
|
||||
import org.whispersystems.textsecuregcm.auth.grpc.AuthenticationUtil;
|
||||
@@ -519,7 +516,7 @@ public class AccountsGrpcService extends SimpleAccountsGrpc.AccountsImplBase {
|
||||
|
||||
private static AccountIdentifiers buildAccountIdentifiers(final Account account) {
|
||||
final AccountIdentifiers.Builder accountIdentifiersBuilder = AccountIdentifiers.newBuilder()
|
||||
.addServiceIdentifiers(GrpcServiceIdentifierUtil.toGrpcServiceIdentifier(new AciServiceIdentifier(account.getUuid())))
|
||||
.addServiceIdentifiers(GrpcServiceIdentifierUtil.toGrpcServiceIdentifier(new AciServiceIdentifier(account.getAccountIdentifier())))
|
||||
.addServiceIdentifiers(GrpcServiceIdentifierUtil.toGrpcServiceIdentifier(new PniServiceIdentifier(account.getPhoneNumberIdentifier())))
|
||||
.setE164(account.getNumber());
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class CredentialsAnonymousGrpcService extends SimpleCredentialsAnonymousG
|
||||
|
||||
// the username associated with the provided number
|
||||
final Optional<String> maybeUsername = accountsManager.getByE164(request.getNumber())
|
||||
.map(Account::getUuid)
|
||||
.map(Account::getAccountIdentifier)
|
||||
.map(svrCredentialsGenerator::generateForUuid)
|
||||
.map(ExternalServiceCredentials::username);
|
||||
|
||||
|
||||
@@ -232,8 +232,8 @@ public class MessageDispatcher {
|
||||
messageMetrics.measureMessageStreamDisplaced(MessageMetrics.GRPC_CHANNEL, userAgent, false);
|
||||
sink.error(GrpcExceptions.invalidCredentials("reauthentication required"));
|
||||
};
|
||||
disconnectionRequestManager.addListener(account.getUuid(), device.getId(), listener);
|
||||
sink.onDispose(() -> disconnectionRequestManager.removeListener(account.getUuid(), device.getId(), listener));
|
||||
disconnectionRequestManager.addListener(account.getAccountIdentifier(), device.getId(), listener);
|
||||
sink.onDispose(() -> disconnectionRequestManager.removeListener(account.getAccountIdentifier(), device.getId(), listener));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ public class MessagesGrpcService extends SimpleMessagesGrpc.MessagesImplBase {
|
||||
}
|
||||
final Account destination = maybeDestination.get();
|
||||
|
||||
rateLimiters.getMessagesLimiter().validate(authenticatedDevice.accountIdentifier(), destination.getUuid());
|
||||
rateLimiters.getMessagesLimiter().validate(authenticatedDevice.accountIdentifier(), destination.getAccountIdentifier());
|
||||
|
||||
return sendMessage(destination,
|
||||
destinationServiceIdentifier,
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.Clock;
|
||||
import java.util.Arrays;
|
||||
import java.util.HexFormat;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.bouncycastle.crypto.digests.TupleHash;
|
||||
import org.signal.chat.common.S3UploadForm;
|
||||
@@ -54,7 +53,7 @@ public class ProfileGrpcHelper {
|
||||
final ProfileBadgeConverter profileBadgeConverter,
|
||||
final byte[] requestVersion) {
|
||||
final Optional<VersionedProfileV1> maybeV1Profile =
|
||||
profilesManager.getV1(account.getUuid(), HexFormat.of().formatHex(requestVersion));
|
||||
profilesManager.getV1(account.getAccountIdentifier(), HexFormat.of().formatHex(requestVersion));
|
||||
if (maybeV1Profile.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -86,7 +85,7 @@ public class ProfileGrpcHelper {
|
||||
final byte[] requestVersion) {
|
||||
|
||||
final Optional<VersionedProfile> maybeProfile = account.hasCapability(DeviceCapability.PROFILES_V2)
|
||||
? profilesManager.get(account.getUuid(), requestVersion)
|
||||
? profilesManager.get(account.getAccountIdentifier(), requestVersion)
|
||||
: Optional.empty();
|
||||
if (maybeProfile.isEmpty()) {
|
||||
return Optional.empty();
|
||||
@@ -131,13 +130,13 @@ public class ProfileGrpcHelper {
|
||||
|
||||
final Optional<VersionedProfile> versionedProfile;
|
||||
if (account.hasCapability(DeviceCapability.PROFILES_V2)) {
|
||||
versionedProfile = profilesManager.get(account.getUuid(), version);
|
||||
versionedProfile = profilesManager.get(account.getAccountIdentifier(), version);
|
||||
} else {
|
||||
versionedProfile = Optional.empty();
|
||||
}
|
||||
|
||||
return versionedProfile.map(VersionedProfile::commitment)
|
||||
.or(() -> profilesManager.getV1(account.getUuid(), HexFormat.of().formatHex(version))
|
||||
.or(() -> profilesManager.getV1(account.getAccountIdentifier(), HexFormat.of().formatHex(version))
|
||||
.map(VersionedProfileV1::commitment))
|
||||
.map(commitment -> {
|
||||
|
||||
@@ -145,7 +144,7 @@ public class ProfileGrpcHelper {
|
||||
try {
|
||||
profileKeyCredentialResponse = ProfileHelper.getExpiringProfileKeyCredential(
|
||||
new ProfileKeyCredentialRequest(encodedCredentialRequest),
|
||||
new ProfileKeyCommitment(commitment), new ServiceId.Aci(account.getUuid()), zkProfileOperations);
|
||||
new ProfileKeyCommitment(commitment), new ServiceId.Aci(account.getAccountIdentifier()), zkProfileOperations);
|
||||
} catch (VerificationFailedException | InvalidInputException e) {
|
||||
throw GrpcExceptions.invalidArguments("invalid credential request");
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class PushChallengeManager {
|
||||
final boolean sent;
|
||||
final String platform;
|
||||
|
||||
if (pushChallengeDynamoDb.add(account.getUuid(), token, CHALLENGE_TTL)) {
|
||||
if (pushChallengeDynamoDb.add(account.getAccountIdentifier(), token, CHALLENGE_TTL)) {
|
||||
pushNotificationManager.sendRateLimitChallengeNotification(account, HexFormat.of().formatHex(token));
|
||||
|
||||
sent = true;
|
||||
@@ -82,7 +82,7 @@ public class PushChallengeManager {
|
||||
boolean success = false;
|
||||
|
||||
try {
|
||||
success = pushChallengeDynamoDb.remove(account.getUuid(), HexFormat.of().parseHex(challengeTokenHex));
|
||||
success = pushChallengeDynamoDb.remove(account.getAccountIdentifier(), HexFormat.of().parseHex(challengeTokenHex));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -55,12 +55,12 @@ public class RateLimitChallengeManager {
|
||||
}
|
||||
|
||||
public boolean answerPushChallenge(final Account account, final String challenge) throws RateLimitExceededException {
|
||||
rateLimiters.getPushChallengeAttemptLimiter().validate(account.getUuid());
|
||||
rateLimiters.getPushChallengeAttemptLimiter().validate(account.getAccountIdentifier());
|
||||
|
||||
final boolean challengeSuccess = pushChallengeManager.answerChallenge(account, challenge);
|
||||
|
||||
if (challengeSuccess) {
|
||||
rateLimiters.getPushChallengeSuccessLimiter().validate(account.getUuid());
|
||||
rateLimiters.getPushChallengeSuccessLimiter().validate(account.getAccountIdentifier());
|
||||
resetRateLimits(account, ChallengeType.PUSH);
|
||||
}
|
||||
return challengeSuccess;
|
||||
@@ -73,10 +73,10 @@ public class RateLimitChallengeManager {
|
||||
final Optional<Float> scoreThreshold)
|
||||
throws RateLimitExceededException, IOException, InvalidCaptchaArgumentException {
|
||||
|
||||
rateLimiters.getCaptchaChallengeAttemptLimiter().validate(account.getUuid());
|
||||
rateLimiters.getCaptchaChallengeAttemptLimiter().validate(account.getAccountIdentifier());
|
||||
|
||||
final AssessmentResult assessmentResult =
|
||||
captchaChecker.verify(Optional.of(account.getUuid()), Action.CHALLENGE, captcha, mostRecentProxyIp, userAgent);
|
||||
captchaChecker.verify(Optional.of(account.getAccountIdentifier()), Action.CHALLENGE, captcha, mostRecentProxyIp, userAgent);
|
||||
|
||||
final boolean challengeSuccess = assessmentResult.isValid(scoreThreshold);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class RateLimitChallengeManager {
|
||||
"sendMessage");
|
||||
|
||||
if (challengeSuccess) {
|
||||
rateLimiters.getCaptchaChallengeSuccessLimiter().validate(account.getUuid());
|
||||
rateLimiters.getCaptchaChallengeSuccessLimiter().validate(account.getAccountIdentifier());
|
||||
resetRateLimits(account, ChallengeType.CAPTCHA);
|
||||
}
|
||||
return challengeSuccess;
|
||||
@@ -104,7 +104,7 @@ public class RateLimitChallengeManager {
|
||||
|
||||
private void resetRateLimits(final Account account, final ChallengeType type) throws RateLimitExceededException {
|
||||
try {
|
||||
rateLimiters.getRateLimitResetLimiter().validate(account.getUuid());
|
||||
rateLimiters.getRateLimitResetLimiter().validate(account.getAccountIdentifier());
|
||||
} catch (final RateLimitExceededException e) {
|
||||
Metrics.counter(RESET_RATE_LIMIT_EXCEEDED_COUNTER_NAME,
|
||||
SOURCE_COUNTRY_TAG_NAME, Util.getCountryCode(account.getNumber())).increment();
|
||||
|
||||
+4
-4
@@ -20,14 +20,14 @@ public class RateLimitChallengeOptionManager {
|
||||
public List<RateLimitChallengeOption> getChallengeOptions(final Account account) {
|
||||
final List<RateLimitChallengeOption> options = new ArrayList<>(2);
|
||||
|
||||
if (rateLimiters.getCaptchaChallengeAttemptLimiter().hasAvailablePermits(account.getUuid(), 1) &&
|
||||
rateLimiters.getCaptchaChallengeSuccessLimiter().hasAvailablePermits(account.getUuid(), 1)) {
|
||||
if (rateLimiters.getCaptchaChallengeAttemptLimiter().hasAvailablePermits(account.getAccountIdentifier(), 1) &&
|
||||
rateLimiters.getCaptchaChallengeSuccessLimiter().hasAvailablePermits(account.getAccountIdentifier(), 1)) {
|
||||
|
||||
options.add(RateLimitChallengeOption.CAPTCHA);
|
||||
}
|
||||
|
||||
if (rateLimiters.getPushChallengeAttemptLimiter().hasAvailablePermits(account.getUuid(), 1) &&
|
||||
rateLimiters.getPushChallengeSuccessLimiter().hasAvailablePermits(account.getUuid(), 1)) {
|
||||
if (rateLimiters.getPushChallengeAttemptLimiter().hasAvailablePermits(account.getAccountIdentifier(), 1) &&
|
||||
rateLimiters.getPushChallengeSuccessLimiter().hasAvailablePermits(account.getAccountIdentifier(), 1)) {
|
||||
|
||||
options.add(RateLimitChallengeOption.PUSH_CHALLENGE);
|
||||
}
|
||||
|
||||
+1
-3
@@ -12,8 +12,6 @@ import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.Tags;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
@@ -217,7 +215,7 @@ public class PushNotificationManager {
|
||||
// Reread the account to avoid marking the caller's account as stale. The consumers of this class tend to
|
||||
// promise not to modify accounts. There's no need to force the caller to be considered mutable just for
|
||||
// updating an uninstalled feedback timestamp though.
|
||||
accountsManager.getByAccountIdentifier(account.getUuid()).ifPresent(rereadAccount ->
|
||||
accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).ifPresent(rereadAccount ->
|
||||
rereadAccount.getDevice(device.getId()).ifPresent(rereadDevice ->
|
||||
accountsManager.updateDevice(rereadAccount.getIdentifier(IdentityType.ACI), device.getId(), d -> {
|
||||
// Don't clear the token if it's already changed
|
||||
|
||||
+1
-1
@@ -350,7 +350,7 @@ public class PushNotificationScheduler implements Managed {
|
||||
// the original device's id, the new device might get the old device's scheduled push, or the new device might
|
||||
// delay its own push because the old device had a recent push. An extra or delayed background push is harmless,
|
||||
// so this is okay.
|
||||
return account.getUuid() + ":" + device.getId();
|
||||
return account.getAccountIdentifier() + ":" + device.getId();
|
||||
}
|
||||
|
||||
static Pair<UUID, Byte> decodeAciAndDeviceId(final String encoded) {
|
||||
|
||||
@@ -150,20 +150,23 @@ public class Account {
|
||||
|
||||
public UUID getIdentifier(final IdentityType identityType) {
|
||||
return switch (identityType) {
|
||||
case ACI -> getUuid();
|
||||
case ACI -> getAccountIdentifier();
|
||||
case PNI -> getPhoneNumberIdentifier();
|
||||
};
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
/// Returns the core account identifier (ACI) for this account. An account's core identifier never changes.
|
||||
///
|
||||
/// @return the core account identifier for this account
|
||||
public UUID getAccountIdentifier() {
|
||||
// this is the one method that may be called on a stale account
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final UUID uuid) {
|
||||
public void setAccountIdentifier(final UUID accountIdentifier) {
|
||||
requireNotStale();
|
||||
|
||||
this.uuid = uuid;
|
||||
this.uuid = accountIdentifier;
|
||||
}
|
||||
|
||||
public UUID getPhoneNumberIdentifier() {
|
||||
|
||||
@@ -218,7 +218,7 @@ public class Accounts {
|
||||
final Timer.Sample sample = Timer.start();
|
||||
|
||||
try {
|
||||
final AttributeValue uuidAttr = AttributeValues.fromUUID(account.getUuid());
|
||||
final AttributeValue uuidAttr = AttributeValues.fromUUID(account.getAccountIdentifier());
|
||||
final AttributeValue numberAttr = AttributeValues.fromString(account.getNumber());
|
||||
final AttributeValue pniUuidAttr = AttributeValues.fromUUID(account.getPhoneNumberIdentifier());
|
||||
|
||||
@@ -303,12 +303,12 @@ public class Accounts {
|
||||
final Account accountToCreate,
|
||||
final Collection<TransactWriteItem> additionalWriteItems) {
|
||||
|
||||
if (!existingAccount.getUuid().equals(accountToCreate.getUuid()) ||
|
||||
if (!existingAccount.getAccountIdentifier().equals(accountToCreate.getAccountIdentifier()) ||
|
||||
!existingAccount.getPhoneNumberIdentifier().equals(accountToCreate.getPhoneNumberIdentifier())) {
|
||||
|
||||
log.error("Reclaimed accounts must match. Old account {}:{}:{}, New account {}:{}:{}",
|
||||
existingAccount.getUuid(), redactPhoneNumber(existingAccount.getNumber()), existingAccount.getPhoneNumberIdentifier(),
|
||||
accountToCreate.getUuid(), redactPhoneNumber(accountToCreate.getNumber()), accountToCreate.getPhoneNumberIdentifier());
|
||||
existingAccount.getAccountIdentifier(), redactPhoneNumber(existingAccount.getNumber()), existingAccount.getPhoneNumberIdentifier(),
|
||||
accountToCreate.getAccountIdentifier(), redactPhoneNumber(accountToCreate.getNumber()), accountToCreate.getPhoneNumberIdentifier());
|
||||
throw new IllegalArgumentException("reclaimed accounts must match");
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ public class Accounts {
|
||||
.tableName(usernamesConstraintTableName)
|
||||
.item(Map.of(
|
||||
UsernameTable.KEY_USERNAME_HASH, AttributeValues.fromByteArray(usernameHash),
|
||||
UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.fromUUID(accountToCreate.getUuid()),
|
||||
UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.fromUUID(accountToCreate.getAccountIdentifier()),
|
||||
UsernameTable.ATTR_TTL, AttributeValues.fromLong(expirationTime),
|
||||
UsernameTable.ATTR_CONFIRMED, AttributeValues.fromBool(false),
|
||||
UsernameTable.ATTR_RECLAIMABLE, AttributeValues.fromBool(true)))
|
||||
@@ -371,7 +371,7 @@ public class Accounts {
|
||||
"#uuid", UsernameTable.ATTR_ACCOUNT_UUID))
|
||||
.expressionAttributeValues(Map.of(
|
||||
":now", AttributeValues.fromLong(clock.instant().getEpochSecond()),
|
||||
":uuid", AttributeValues.fromUUID(accountToCreate.getUuid())))
|
||||
":uuid", AttributeValues.fromUUID(accountToCreate.getAccountIdentifier())))
|
||||
.returnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
|
||||
.build())
|
||||
.build());
|
||||
@@ -381,7 +381,7 @@ public class Accounts {
|
||||
// to reclaim the account.
|
||||
if (!existingAccount.getNumber().equals(accountToCreate.getNumber())) {
|
||||
if (getAlternateForms(existingAccount.getNumber()).contains(accountToCreate.getNumber())) {
|
||||
final AttributeValue uuidAttr = AttributeValues.fromUUID(existingAccount.getUuid());
|
||||
final AttributeValue uuidAttr = AttributeValues.fromUUID(existingAccount.getAccountIdentifier());
|
||||
final AttributeValue numberAttr = AttributeValues.fromString(accountToCreate.getNumber());
|
||||
final TransactWriteItem phoneNumberConstraintPut = buildConstraintTablePutIfAbsent(
|
||||
phoneNumberConstraintTableName, uuidAttr, ATTR_ACCOUNT_E164, numberAttr);
|
||||
@@ -390,8 +390,8 @@ public class Accounts {
|
||||
writeItems.add(phoneNumberConstraintPut);
|
||||
} else {
|
||||
throw new IllegalStateException(String.format("Reclaiming account with a non-equivalent phone number. Old account %s:%s:%s, new account %s:%s:%s",
|
||||
existingAccount.getUuid(), redactPhoneNumber(existingAccount.getNumber()), existingAccount.getPhoneNumberIdentifier(),
|
||||
accountToCreate.getUuid(), redactPhoneNumber(accountToCreate.getNumber()), accountToCreate.getPhoneNumberIdentifier()));
|
||||
existingAccount.getAccountIdentifier(), redactPhoneNumber(existingAccount.getNumber()), existingAccount.getPhoneNumberIdentifier(),
|
||||
accountToCreate.getAccountIdentifier(), redactPhoneNumber(accountToCreate.getNumber()), accountToCreate.getPhoneNumberIdentifier()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ public class Accounts {
|
||||
final String existingNumber = AttributeValues.getString(item, Accounts.ATTR_ACCOUNT_E164, null);
|
||||
if (!existingAccount.getNumber().equals(existingNumber)) {
|
||||
log.error("Failed to update account due to unexpected existing phone number. Account {}. Expected {}, got {}",
|
||||
existingAccount.getUuid(), existingAccount.getNumber(), existingNumber);
|
||||
existingAccount.getAccountIdentifier(), existingAccount.getNumber(), existingNumber);
|
||||
throw new UnexpectedExistingPhoneNumberException();
|
||||
}
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public class Accounts {
|
||||
int accountUpdateIndex = -1;
|
||||
try {
|
||||
final List<TransactWriteItem> writeItems = new ArrayList<>();
|
||||
final AttributeValue uuidAttr = AttributeValues.fromUUID(account.getUuid());
|
||||
final AttributeValue uuidAttr = AttributeValues.fromUUID(account.getAccountIdentifier());
|
||||
final AttributeValue numberAttr = AttributeValues.fromString(number);
|
||||
final AttributeValue pniAttr = AttributeValues.fromUUID(phoneNumberIdentifier);
|
||||
|
||||
@@ -599,7 +599,7 @@ public class Accounts {
|
||||
final long expirationTimeSeconds) throws ContestedOptimisticLockException, TtlConflictException, UsernameHashNotAvailableException {
|
||||
|
||||
// Use account UUID as a "reservation token" - by providing this, the client proves ownership of the hash
|
||||
final UUID uuid = updatedAccount.getUuid();
|
||||
final UUID uuid = updatedAccount.getAccountIdentifier();
|
||||
|
||||
final List<TransactWriteItem> writeItems = new ArrayList<>();
|
||||
|
||||
@@ -786,7 +786,7 @@ public class Accounts {
|
||||
writeItems.add(TransactWriteItem.builder().put(Put.builder()
|
||||
.tableName(usernamesConstraintTableName)
|
||||
.item(Map.of(
|
||||
UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.fromUUID(updatedAccount.getUuid()),
|
||||
UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.fromUUID(updatedAccount.getAccountIdentifier()),
|
||||
UsernameTable.KEY_USERNAME_HASH, AttributeValues.fromByteArray(usernameHash),
|
||||
UsernameTable.ATTR_CONFIRMED, AttributeValues.fromBool(true)))
|
||||
// it's not in the constraint table OR it's expired OR it was reserved by us
|
||||
@@ -798,7 +798,7 @@ public class Accounts {
|
||||
"#confirmed", UsernameTable.ATTR_CONFIRMED))
|
||||
.expressionAttributeValues(Map.of(
|
||||
":now", AttributeValues.fromLong(clock.instant().getEpochSecond()),
|
||||
":aci", AttributeValues.fromUUID(updatedAccount.getUuid()),
|
||||
":aci", AttributeValues.fromUUID(updatedAccount.getAccountIdentifier()),
|
||||
":confirmed", AttributeValues.fromBool(false)))
|
||||
.returnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
|
||||
.build())
|
||||
@@ -809,11 +809,11 @@ public class Accounts {
|
||||
|
||||
// 2?: Add a temporary hold for the old username to stop others from claiming it
|
||||
maybeOriginalUsernameHash.ifPresent(originalUsernameHash ->
|
||||
writeItems.add(holdUsernameTransactItem(updatedAccount.getUuid(), originalUsernameHash, now)));
|
||||
writeItems.add(holdUsernameTransactItem(updatedAccount.getAccountIdentifier(), originalUsernameHash, now)));
|
||||
|
||||
// 3?: Adding that hold may have caused our account to exceed our maximum holds. Release an old hold
|
||||
holdToRemove.ifPresent(oldHold ->
|
||||
writeItems.add(releaseHoldIfAllowedTransactItem(updatedAccount.getUuid(), oldHold, now)));
|
||||
writeItems.add(releaseHoldIfAllowedTransactItem(updatedAccount.getAccountIdentifier(), oldHold, now)));
|
||||
|
||||
try {
|
||||
dynamoDbClient.transactWriteItems(TransactWriteItemsRequest.builder().transactItems(writeItems).build());
|
||||
@@ -894,10 +894,10 @@ public class Accounts {
|
||||
items.add(UpdateAccountSpec.forAccount(accountsTableName, updatedAccount).transactItem());
|
||||
|
||||
// 1: Un-confirm our username, adding a temporary hold for the old username to stop others from claiming it
|
||||
items.add(holdUsernameTransactItem(updatedAccount.getUuid(), usernameHash, now));
|
||||
items.add(holdUsernameTransactItem(updatedAccount.getAccountIdentifier(), usernameHash, now));
|
||||
|
||||
// 2?: Adding that hold may have caused our account to exceed our maximum holds. Release an old hold
|
||||
holdToRemove.ifPresent(oldHold -> items.add(releaseHoldIfAllowedTransactItem(updatedAccount.getUuid(), oldHold, now)));
|
||||
holdToRemove.ifPresent(oldHold -> items.add(releaseHoldIfAllowedTransactItem(updatedAccount.getAccountIdentifier(), oldHold, now)));
|
||||
|
||||
try {
|
||||
dynamoDbClient.transactWriteItems(TransactWriteItemsRequest.builder().transactItems(items).build());
|
||||
@@ -1080,7 +1080,7 @@ public class Accounts {
|
||||
|
||||
return new UpdateAccountSpec(
|
||||
accountTableName,
|
||||
Map.of(KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())),
|
||||
Map.of(KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())),
|
||||
attrNames,
|
||||
attrValues,
|
||||
new UpdateExpression(setClauses, addClauses, removeClauses),
|
||||
@@ -1102,7 +1102,7 @@ public class Accounts {
|
||||
} catch (final ConditionalCheckFailedException e) {
|
||||
// the exception doesn't give details about which condition failed,
|
||||
// but we can infer it was an optimistic locking failure if the UUID is known
|
||||
if (getByAccountIdentifier(account.getUuid()).isPresent()) {
|
||||
if (getByAccountIdentifier(account.getAccountIdentifier()).isPresent()) {
|
||||
throw new ContestedOptimisticLockException();
|
||||
} else {
|
||||
throw e;
|
||||
@@ -1241,7 +1241,7 @@ public class Accounts {
|
||||
return TransactWriteItem.builder()
|
||||
.delete(Delete.builder()
|
||||
.tableName(accountsTableName)
|
||||
.key(Map.of(KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||
.key(Map.of(KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.conditionExpression("#version = :version")
|
||||
.expressionAttributeNames(Map.of("#version", ATTR_VERSION))
|
||||
.expressionAttributeValues(Map.of(":version", AttributeValues.fromInt(account.getVersion())))
|
||||
@@ -1680,7 +1680,7 @@ public class Accounts {
|
||||
}
|
||||
|
||||
account.setNumber(attributeNumber, phoneNumberIdentifierFromAttribute);
|
||||
account.setUuid(accountIdentifier);
|
||||
account.setAccountIdentifier(accountIdentifier);
|
||||
account.setUsernameHash(AttributeValues.getByteArray(item, ATTR_USERNAME_HASH, null));
|
||||
account.setUsernameLinkHandle(AttributeValues.getUUID(item, ATTR_USERNAME_LINK_UUID, null));
|
||||
account.setVersion(Integer.parseInt(item.get(ATTR_VERSION).n()));
|
||||
|
||||
+25
-25
@@ -322,7 +322,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
|
||||
// Reuse the ACI from any recently-deleted account with this number to cover cases where somebody is
|
||||
// re-registering.
|
||||
account.setUuid(maybeRecentlyDeletedAccountIdentifier.orElseGet(UUID::randomUUID));
|
||||
account.setAccountIdentifier(maybeRecentlyDeletedAccountIdentifier.orElseGet(UUID::randomUUID));
|
||||
account.setNumber(number, pni);
|
||||
account.setIdentityKey(aciIdentityKey);
|
||||
account.setPhoneNumberIdentityKey(pniIdentityKey);
|
||||
@@ -367,7 +367,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
}
|
||||
|
||||
final UUID aci = e.getExistingAccount().getIdentifier(IdentityType.ACI);
|
||||
account.setUuid(aci);
|
||||
account.setAccountIdentifier(aci);
|
||||
|
||||
final List<TransactWriteItem> additionalWriteItems = Stream.concat(
|
||||
keysManager.buildWriteItemsForNewDevice(account.getIdentifier(IdentityType.ACI),
|
||||
@@ -417,7 +417,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
.store(account.getIdentifier(IdentityType.PNI), registrationRecoveryPassword))
|
||||
.orElse(false);
|
||||
|
||||
changeNumberWaitingPeriodManager.handleAccountCreated(account.getUuid(), clock.instant());
|
||||
changeNumberWaitingPeriodManager.handleAccountCreated(account.getAccountIdentifier(), clock.instant());
|
||||
|
||||
Tags tags = Tags.of(UserAgentTagUtil.getPlatformTag(userAgent),
|
||||
Tag.of("type", accountCreationType),
|
||||
@@ -457,9 +457,9 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
final byte nextDeviceId = account.getNextDeviceId();
|
||||
|
||||
CompletableFuture.allOf(
|
||||
keysManager.deleteSingleUsePreKeys(account.getUuid(), nextDeviceId),
|
||||
keysManager.deleteSingleUsePreKeys(account.getAccountIdentifier(), nextDeviceId),
|
||||
keysManager.deleteSingleUsePreKeys(account.getPhoneNumberIdentifier(), nextDeviceId),
|
||||
messagesManager.clear(account.getUuid(), nextDeviceId))
|
||||
messagesManager.clear(account.getAccountIdentifier(), nextDeviceId))
|
||||
.join();
|
||||
|
||||
account.addDevice(deviceSpec.toDevice(nextDeviceId, clock, account.getIdentityKey(IdentityType.ACI)));
|
||||
@@ -650,8 +650,8 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
.orElseThrow(ContestedOptimisticLockException::new);
|
||||
|
||||
CompletableFuture.allOf(
|
||||
keysManager.deleteSingleUsePreKeys(account.getUuid(), deviceId),
|
||||
messagesManager.clear(account.getUuid(), deviceId))
|
||||
keysManager.deleteSingleUsePreKeys(account.getAccountIdentifier(), deviceId),
|
||||
messagesManager.clear(account.getAccountIdentifier(), deviceId))
|
||||
.join();
|
||||
|
||||
account.removeDevice(deviceId);
|
||||
@@ -669,8 +669,8 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
|
||||
// Ensure any messages/single-use pre-keys that came in while we were working are also removed
|
||||
CompletableFuture.allOf(
|
||||
keysManager.deleteSingleUsePreKeys(account.getUuid(), deviceId),
|
||||
messagesManager.clear(account.getUuid(), deviceId))
|
||||
keysManager.deleteSingleUsePreKeys(account.getAccountIdentifier(), deviceId),
|
||||
messagesManager.clear(account.getAccountIdentifier(), deviceId))
|
||||
.join();
|
||||
|
||||
disconnectionRequestManager.requestDisconnection(accountIdentifier, List.of(deviceId));
|
||||
@@ -743,13 +743,13 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
maybeDisplacedUuid = Optional.empty();
|
||||
} else {
|
||||
delete(maybeExistingAccount.get());
|
||||
maybeDisplacedUuid = maybeExistingAccount.map(Account::getUuid);
|
||||
maybeDisplacedUuid = maybeExistingAccount.map(Account::getAccountIdentifier);
|
||||
}
|
||||
} else {
|
||||
maybeDisplacedUuid = recentlyDeletedAci;
|
||||
}
|
||||
|
||||
final UUID uuid = account.getUuid();
|
||||
final UUID uuid = account.getAccountIdentifier();
|
||||
|
||||
CompletableFuture.allOf(
|
||||
keysManager.deleteSingleUsePreKeys(targetPhoneNumberIdentifier),
|
||||
@@ -868,7 +868,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
_ -> true,
|
||||
a -> reservedUsernameHash.set(
|
||||
checkAndReserveNextUsernameHash(a, new ArrayDeque<>(requestedUsernameHashes))),
|
||||
() -> accounts.getByAccountIdentifier(account.getUuid()).orElseThrow(),
|
||||
() -> accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow(),
|
||||
AccountChangeValidator.USERNAME_CHANGE_VALIDATOR);
|
||||
|
||||
redisDelete(updatedAccount);
|
||||
@@ -927,7 +927,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
final Account updatedAccount = updateWithRetries(
|
||||
_ -> true,
|
||||
a -> accounts.confirmUsernameHash(a, reservedUsernameHash, encryptedUsername),
|
||||
() -> accounts.getByAccountIdentifier(account.getUuid()).orElseThrow(),
|
||||
() -> accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow(),
|
||||
AccountChangeValidator.USERNAME_CHANGE_VALIDATOR);
|
||||
|
||||
redisDelete(updatedAccount);
|
||||
@@ -1209,17 +1209,17 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
.toList();
|
||||
|
||||
CompletableFuture.allOf(
|
||||
secureStorageClient.deleteStoredData(account.getUuid()),
|
||||
secureValueRecovery2Client.removeData(account.getUuid()),
|
||||
keysManager.deleteSingleUsePreKeys(account.getUuid()),
|
||||
secureStorageClient.deleteStoredData(account.getAccountIdentifier()),
|
||||
secureValueRecovery2Client.removeData(account.getAccountIdentifier()),
|
||||
keysManager.deleteSingleUsePreKeys(account.getAccountIdentifier()),
|
||||
keysManager.deleteSingleUsePreKeys(account.getPhoneNumberIdentifier()),
|
||||
messagesManager.clear(account.getUuid()),
|
||||
profilesManager.deleteAll(account.getUuid(), true))
|
||||
messagesManager.clear(account.getAccountIdentifier()),
|
||||
profilesManager.deleteAll(account.getAccountIdentifier(), true))
|
||||
.join();
|
||||
|
||||
registrationRecoveryPasswordsManager.remove(account.getIdentifier(IdentityType.PNI));
|
||||
|
||||
accounts.delete(account.getUuid(), additionalWriteItems);
|
||||
accounts.delete(account.getAccountIdentifier(), additionalWriteItems);
|
||||
redisDelete(account);
|
||||
|
||||
disconnectionRequestManager.requestDisconnection(account);
|
||||
@@ -1242,8 +1242,8 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
final RedisAdvancedClusterCommands<String, String> commands = connection.sync();
|
||||
|
||||
commands.setex(getAccountMapKey(account.getPhoneNumberIdentifier().toString()), CACHE_TTL_SECONDS,
|
||||
account.getUuid().toString());
|
||||
commands.setex(getAccountEntityKey(account.getUuid()), CACHE_TTL_SECONDS, accountJson);
|
||||
account.getAccountIdentifier().toString());
|
||||
commands.setex(getAccountEntityKey(account.getAccountIdentifier()), CACHE_TTL_SECONDS, accountJson);
|
||||
});
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
@@ -1263,9 +1263,9 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
return cacheCluster.withCluster(connection -> CompletableFuture.allOf(
|
||||
connection.async().setex(
|
||||
getAccountMapKey(account.getPhoneNumberIdentifier().toString()), CACHE_TTL_SECONDS,
|
||||
account.getUuid().toString())
|
||||
account.getAccountIdentifier().toString())
|
||||
.toCompletableFuture(),
|
||||
connection.async().setex(getAccountEntityKey(account.getUuid()), CACHE_TTL_SECONDS, accountJson)
|
||||
connection.async().setex(getAccountEntityKey(account.getAccountIdentifier()), CACHE_TTL_SECONDS, accountJson)
|
||||
.toCompletableFuture()));
|
||||
}
|
||||
|
||||
@@ -1372,7 +1372,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
try {
|
||||
if (StringUtils.isNotBlank(accountJson)) {
|
||||
Account account = SystemMapper.jsonMapper().readValue(accountJson, Account.class);
|
||||
account.setUuid(uuid);
|
||||
account.setAccountIdentifier(uuid);
|
||||
|
||||
if (account.getPhoneNumberIdentifier() == null) {
|
||||
logger.warn("Account {} loaded from Redis is missing a PNI", uuid);
|
||||
@@ -1398,7 +1398,7 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||
redisDeleteTimer.record(() ->
|
||||
cacheCluster.useCluster(connection ->
|
||||
connection.sync().del(getAccountMapKey(account.getPhoneNumberIdentifier().toString()),
|
||||
getAccountEntityKey(account.getUuid())))));
|
||||
getAccountEntityKey(account.getAccountIdentifier())))));
|
||||
}
|
||||
|
||||
public CompletableFuture<Optional<DeviceInfo>> waitForNewLinkedDevice(
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ public class ChangeNumberManager {
|
||||
// Only verify and check reglock if there's a data change to be made...
|
||||
if (!account.getNumber().equals(number)) {
|
||||
|
||||
final Optional<Duration> waitingPeriodRemaining = changeNumberWaitingPeriodManager.getWaitingPeriodRemaining(account.getUuid());
|
||||
final Optional<Duration> waitingPeriodRemaining = changeNumberWaitingPeriodManager.getWaitingPeriodRemaining(account.getAccountIdentifier());
|
||||
if (waitingPeriodRemaining.isPresent()) {
|
||||
Metrics.counter(POST_REGISTRATION_WAITING_PERIOD_NOT_MET_COUNTER_NAME).increment();
|
||||
throw new RateLimitExceededException(waitingPeriodRemaining.get());
|
||||
|
||||
+2
-2
@@ -270,7 +270,7 @@ public class MessagePersister implements Managed {
|
||||
|
||||
@VisibleForTesting
|
||||
Mono<Void> persistQueue(final Account account, final Device device, final Tags baseTags) {
|
||||
final UUID accountUuid = account.getUuid();
|
||||
final UUID accountUuid = account.getAccountIdentifier();
|
||||
final byte deviceId = device.getId();
|
||||
|
||||
final Tag platformTag = Tag.of("platform", DevicePlatformUtil.getDevicePlatform(device)
|
||||
@@ -305,7 +305,7 @@ public class MessagePersister implements Managed {
|
||||
// may throw, in which case we'll retry later by the usual mechanism
|
||||
if (isPrimary) {
|
||||
logger.warn("Failed to persist queue {}::{} due to overfull queue; will trim oldest messages",
|
||||
account.getUuid(), deviceId);
|
||||
account.getAccountIdentifier(), deviceId);
|
||||
|
||||
return trimQueue(account, device)
|
||||
.then(Mono.error(new MessagePersistenceException("Could not persist due to an overfull queue. Trimmed primary queue, a subsequent retry may succeed")));
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ public class ReportMessageManager {
|
||||
connection ->
|
||||
Math.max(
|
||||
connection.sync().pfcount(getReportedSenderPniKey(account.getPhoneNumberIdentifier())).intValue(),
|
||||
connection.sync().pfcount(getReportedSenderAciKey(account.getUuid())).intValue()));
|
||||
connection.sync().pfcount(getReportedSenderAciKey(account.getAccountIdentifier())).intValue()));
|
||||
} catch (final RedisException e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-3
@@ -115,7 +115,7 @@ public class AppleDeviceCheckManager {
|
||||
throw new TooManyKeysException();
|
||||
}
|
||||
|
||||
final String redisChallengeKey = challengeKey(ChallengeType.ATTEST, account.getUuid());
|
||||
final String redisChallengeKey = challengeKey(ChallengeType.ATTEST, account.getAccountIdentifier());
|
||||
|
||||
@Nullable final String challenge = ResilienceUtil.getGeneralRedisRetry(RETRY_NAME)
|
||||
.executeSupplier(() -> redisClient.withCluster(cluster -> cluster.sync().get(redisChallengeKey)));
|
||||
@@ -175,7 +175,7 @@ public class AppleDeviceCheckManager {
|
||||
final byte[] assertion)
|
||||
throws ChallengeNotFoundException, DeviceCheckVerificationFailedException, DeviceCheckKeyIdNotFoundException, RequestReuseException {
|
||||
|
||||
final String redisChallengeKey = challengeKey(challengeType, account.getUuid());
|
||||
final String redisChallengeKey = challengeKey(challengeType, account.getAccountIdentifier());
|
||||
@Nullable final String storedChallenge = ResilienceUtil.getGeneralRedisRetry(RETRY_NAME)
|
||||
.executeSupplier(() -> redisClient.withCluster(cluster -> cluster.sync().get(redisChallengeKey)));
|
||||
|
||||
@@ -220,7 +220,7 @@ public class AppleDeviceCheckManager {
|
||||
* @return The challenge to be included as part of an attestation or assertion
|
||||
*/
|
||||
public String createChallenge(final ChallengeType challengeType, final Account account) {
|
||||
final UUID accountIdentifier = account.getUuid();
|
||||
final UUID accountIdentifier = account.getAccountIdentifier();
|
||||
|
||||
final String challengeKey = challengeKey(challengeType, accountIdentifier);
|
||||
return ResilienceUtil.getGeneralRedisRetry(RETRY_NAME)
|
||||
|
||||
+6
-6
@@ -94,7 +94,7 @@ public class AppleDeviceChecks {
|
||||
.tableName(deviceCheckTableName)
|
||||
.keyConditionExpression("#aci = :aci")
|
||||
.expressionAttributeNames(Map.of("#aci", KEY_ACCOUNT_UUID, "#kid", KEY_PUBLIC_KEY_ID))
|
||||
.expressionAttributeValues(Map.of(":aci", AttributeValues.fromUUID(account.getUuid())))
|
||||
.expressionAttributeValues(Map.of(":aci", AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.projectionExpression("#kid")
|
||||
.build())
|
||||
.items()
|
||||
@@ -136,12 +136,12 @@ public class AppleDeviceChecks {
|
||||
.tableName(publicKeyConstraintTableName)
|
||||
.item(Map.of(
|
||||
KEY_PUBLIC_KEY, AttributeValues.fromByteArray(extractPublicKey(appleDevice).getEncoded()),
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())
|
||||
))
|
||||
// Enforces public key uniqueness, as described in https://developer.apple.com/documentation/devicecheck/validating-apps-that-connect-to-your-server#Store-the-public-key-and-receipt
|
||||
.conditionExpression("attribute_not_exists(#pk) or #aci = :aci")
|
||||
.expressionAttributeNames(Map.of("#aci", KEY_ACCOUNT_UUID, "#pk", KEY_PUBLIC_KEY))
|
||||
.expressionAttributeValues(Map.of(":aci", AttributeValues.fromUUID(account.getUuid())))
|
||||
.expressionAttributeValues(Map.of(":aci", AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.build()).build()).build());
|
||||
return true;
|
||||
|
||||
@@ -170,7 +170,7 @@ public class AppleDeviceChecks {
|
||||
final GetItemResponse item = dynamoDbClient.getItem(GetItemRequest.builder()
|
||||
.tableName(deviceCheckTableName)
|
||||
.key(Map.of(
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier()),
|
||||
KEY_PUBLIC_KEY_ID, AttributeValues.fromByteArray(keyId))).build());
|
||||
return item.hasItem() ? Optional.of(fromItem(item.item())) : Optional.empty();
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class AppleDeviceChecks {
|
||||
dynamoDbClient.updateItem(UpdateItemRequest.builder()
|
||||
.tableName(deviceCheckTableName)
|
||||
.key(Map.of(
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier()),
|
||||
KEY_PUBLIC_KEY_ID, AttributeValues.fromByteArray(keyId)))
|
||||
.expressionAttributeNames(Map.of("#counter", ATTR_COUNTER))
|
||||
.expressionAttributeValues(Map.of(":counter", AttributeValues.n(newCounter)))
|
||||
@@ -217,7 +217,7 @@ public class AppleDeviceChecks {
|
||||
.writeValueAsBytes(appleDevice.getAuthenticatorExtensions());
|
||||
|
||||
return Map.of(
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
||||
KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier()),
|
||||
KEY_PUBLIC_KEY_ID, AttributeValues.fromByteArray(keyId),
|
||||
ATTR_CRED_DATA, AttributeValues.fromByteArray(attestedCredentialData),
|
||||
ATTR_STATEMENT, AttributeValues.fromByteArray(attestationStatement),
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class RemoveExpiredAccountsCommand extends AbstractSinglePassCrawlAccount
|
||||
.doOnSuccess(ignored -> deletedAccountCounter.increment())
|
||||
.retryWhen(Retry.backoff(8, Duration.ofSeconds(1)).maxBackoff(Duration.ofSeconds(4)))
|
||||
.onErrorResume(throwable -> {
|
||||
log.warn("Failed to delete account {}", expiredAccount.getUuid(), throwable);
|
||||
log.warn("Failed to delete account {}", expiredAccount.getAccountIdentifier(), throwable);
|
||||
return Mono.empty();
|
||||
});
|
||||
}, MAX_CONCURRENCY)
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ public class RemoveExpiredLinkedDevicesCommand extends AbstractSinglePassCrawlAc
|
||||
return accountUpdate
|
||||
.doOnNext(successCounter::increment)
|
||||
.onErrorResume(t -> {
|
||||
logger.warn("Failed to remove expired linked devices for {}", account.getUuid(), t);
|
||||
logger.warn("Failed to remove expired linked devices for {}", account.getAccountIdentifier(), t);
|
||||
return Mono.empty();
|
||||
});
|
||||
}, maxConcurrency)
|
||||
@@ -136,7 +136,7 @@ public class RemoveExpiredLinkedDevicesCommand extends AbstractSinglePassCrawlAc
|
||||
.doAfterRetry(ignored -> retryCounter.increment())
|
||||
.onRetryExhaustedThrow((spec, rs) -> rs.failure()))
|
||||
.onErrorResume(t -> {
|
||||
logger.info("Failed to remove expired linked device {}.{}", account.getUuid(), deviceId, t);
|
||||
logger.info("Failed to remove expired linked device {}.{}", account.getAccountIdentifier(), deviceId, t);
|
||||
errorCounter.increment();
|
||||
return Mono.empty();
|
||||
}),
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ public class RemoveExpiredUsernameHoldsCommand extends AbstractSinglePassCrawlAc
|
||||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(1)))
|
||||
.doOnSuccess(ignored -> deletedHoldsCounter.increment(holdsToRemove))
|
||||
.onErrorResume(throwable -> {
|
||||
log.warn("Failed to purge {} expired holds on account {}", holdsToRemove, account.getUuid());
|
||||
log.warn("Failed to purge {} expired holds on account {}", holdsToRemove, account.getAccountIdentifier());
|
||||
return Mono.empty();
|
||||
});
|
||||
}, maxConcurrency)
|
||||
|
||||
+5
-5
@@ -153,7 +153,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
@@ -181,7 +181,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
@@ -210,7 +210,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(authenticatedDevice));
|
||||
when(account.getPrimaryDevice()).thenReturn(authenticatedDevice);
|
||||
@@ -250,7 +250,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
@@ -277,7 +277,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
clock.unpin();
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ class CertificateGeneratorTest {
|
||||
SIGNING_CERTIFICATE_DATA, SIGNING_KEY, 1, embedSigner);
|
||||
|
||||
when(account.getIdentityKey(IdentityType.ACI)).thenReturn(IDENTITY_KEY);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
when(account.getNumber()).thenReturn(E164);
|
||||
|
||||
final byte[] contents = certificateGenerator.createFor(account, deviceId, includeE164);
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
|
||||
account = mock(Account.class);
|
||||
final UUID accountIdentifier = UUID.randomUUID();
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.getNumber()).thenReturn("+18005551212");
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -106,7 +106,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
} else {
|
||||
verify(registrationRecoveryPasswordsManager, never()).remove(any());
|
||||
}
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of(Device.PRIMARY_ID));
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getAccountIdentifier(), List.of(Device.PRIMARY_ID));
|
||||
try {
|
||||
verify(pushNotificationManager).sendAttemptLoginNotification(any(), eq("failedRegistrationLock"));
|
||||
} catch (final NotPushRegisteredException ignored) {
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ public class BackupAuthManagerTest {
|
||||
final BackupAuthManager authManager = create();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(aci);
|
||||
|
||||
AccountsHelper.setupMockGet(accountsManager, account);
|
||||
@@ -556,7 +556,7 @@ public class BackupAuthManagerTest {
|
||||
private final Account account = mock(Account.class);
|
||||
|
||||
MockAccountBuilder() {
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
}
|
||||
|
||||
MockAccountBuilder backupLevel(BackupLevel backupLevel) {
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class BackupAuthTestUtil {
|
||||
final BackupAuthManager issuer = new BackupAuthManager(
|
||||
mock(ExperimentEnrollmentManager.class), null, null, null, null, params, clock);
|
||||
Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getBackupCredentialRequest(any())).thenReturn(Optional.of(request.serialize()));
|
||||
when(account.getBackupVoucher()).thenReturn(switch (backupLevel) {
|
||||
case FREE -> null;
|
||||
|
||||
+4
-4
@@ -185,7 +185,7 @@ class AccountControllerTest {
|
||||
when(senderPinAccount.getRegistrationLock()).thenReturn(
|
||||
new StoredRegistrationLock(Optional.empty(), Optional.empty(), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
|
||||
when(senderHasStorage.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(senderHasStorage.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
when(senderHasStorage.hasCapability(DeviceCapability.STORAGE)).thenReturn(true);
|
||||
when(senderHasStorage.getRegistrationLock()).thenReturn(
|
||||
new StoredRegistrationLock(Optional.empty(), Optional.empty(), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
@@ -194,12 +194,12 @@ class AccountControllerTest {
|
||||
new StoredRegistrationLock(Optional.of(registrationLockCredentials.hash()),
|
||||
Optional.of(registrationLockCredentials.salt()), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
when(senderRegLockAccount.getLastSeen()).thenReturn(System.currentTimeMillis());
|
||||
when(senderRegLockAccount.getUuid()).thenReturn(SENDER_REG_LOCK_UUID);
|
||||
when(senderRegLockAccount.getAccountIdentifier()).thenReturn(SENDER_REG_LOCK_UUID);
|
||||
when(senderRegLockAccount.getNumber()).thenReturn(SENDER_REG_LOCK);
|
||||
|
||||
when(senderTransfer.getRegistrationLock()).thenReturn(
|
||||
new StoredRegistrationLock(Optional.empty(), Optional.empty(), Instant.ofEpochMilli(System.currentTimeMillis())));
|
||||
when(senderTransfer.getUuid()).thenReturn(SENDER_TRANSFER_UUID);
|
||||
when(senderTransfer.getAccountIdentifier()).thenReturn(SENDER_TRANSFER_UUID);
|
||||
when(senderTransfer.getNumber()).thenReturn(SENDER_TRANSFER);
|
||||
|
||||
when(accountsManager.getByE164(eq(SENDER_PIN))).thenReturn(Optional.of(senderPinAccount));
|
||||
@@ -975,7 +975,7 @@ class AccountControllerTest {
|
||||
void testLookupUsername() {
|
||||
final Account account = mock(Account.class);
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
|
||||
when(accountsManager.getByUsernameHash(any())).thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
Response response = resources.getJerseyTest()
|
||||
|
||||
+4
-4
@@ -126,7 +126,7 @@ class AccountControllerV2Test {
|
||||
final List<Device> devices = account.getDevices();
|
||||
|
||||
final Account updatedAccount = mock(Account.class);
|
||||
when(updatedAccount.getUuid()).thenReturn(uuid);
|
||||
when(updatedAccount.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(updatedAccount.getNumber()).thenReturn(number);
|
||||
when(updatedAccount.getIdentityKey(IdentityType.PNI)).thenReturn(pniIdentityKey);
|
||||
if (number.equals(account.getNumber())) {
|
||||
@@ -469,13 +469,13 @@ class AccountControllerV2Test {
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(AccountsTestHelper.AccountsDataReportArgumentProvider.class)
|
||||
void testGetAccountDataReport(final Account account, final String expectedTextAfterHeader) throws Exception {
|
||||
when(AuthHelper.ACCOUNTS_MANAGER.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(AuthHelper.ACCOUNTS_MANAGER.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final Response response = resources.getJerseyTest()
|
||||
.target("/v2/accounts/data_report")
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getAuthHeader(account.getUuid(), "password"))
|
||||
.header("Authorization", AuthHelper.getAuthHeader(account.getAccountIdentifier(), "password"))
|
||||
.get();
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ class DeviceControllerTest {
|
||||
|
||||
when(account.getNextDeviceId()).thenReturn(NEXT_DEVICE_ID);
|
||||
when(account.getNumber()).thenReturn(AuthHelper.VALID_NUMBER);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI);
|
||||
when(account.getIdentifier(IdentityType.PNI)).thenReturn(AuthHelper.VALID_PNI);
|
||||
|
||||
+1
-1
@@ -211,7 +211,7 @@ class KeysControllerTest {
|
||||
when(KEYS.takeDevicePreKeys(eq(SAMPLE_DEVICE_ID), eq(EXISTS_PNI_SERVICE_ID), any()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(pniKeys)));
|
||||
|
||||
when(existsAccount.getUuid()).thenReturn(EXISTS_UUID);
|
||||
when(existsAccount.getAccountIdentifier()).thenReturn(EXISTS_UUID);
|
||||
when(existsAccount.isIdentifiedBy(new AciServiceIdentifier(EXISTS_UUID))).thenReturn(true);
|
||||
when(existsAccount.getPhoneNumberIdentifier()).thenReturn(EXISTS_PNI);
|
||||
when(existsAccount.isIdentifiedBy(new PniServiceIdentifier(EXISTS_PNI))).thenReturn(true);
|
||||
|
||||
+6
-6
@@ -722,7 +722,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -754,7 +754,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -786,7 +786,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -819,7 +819,7 @@ class MessageControllerTest {
|
||||
final UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -851,7 +851,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
@@ -914,7 +914,7 @@ class MessageControllerTest {
|
||||
UUID messageGuid = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(senderAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(senderAci);
|
||||
when(account.getNumber()).thenReturn(senderNumber);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(senderPni);
|
||||
|
||||
|
||||
+6
-6
@@ -211,7 +211,7 @@ class ProfileControllerTest {
|
||||
|
||||
when(profileAccount.getIdentityKey(IdentityType.ACI)).thenReturn(ACCOUNT_TWO_IDENTITY_KEY);
|
||||
when(profileAccount.getIdentityKey(IdentityType.PNI)).thenReturn(ACCOUNT_TWO_PHONE_NUMBER_IDENTITY_KEY);
|
||||
when(profileAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID_TWO);
|
||||
when(profileAccount.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID_TWO);
|
||||
when(profileAccount.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID_TWO);
|
||||
when(profileAccount.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI_TWO);
|
||||
when(profileAccount.getCurrentProfileVersion()).thenReturn(Optional.empty());
|
||||
@@ -222,7 +222,7 @@ class ProfileControllerTest {
|
||||
|
||||
capabilitiesAccount = mock(Account.class);
|
||||
|
||||
when(capabilitiesAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(capabilitiesAccount.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(capabilitiesAccount.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(capabilitiesAccount.getIdentityKey(IdentityType.ACI)).thenReturn(ACCOUNT_IDENTITY_KEY);
|
||||
when(capabilitiesAccount.getIdentityKey(IdentityType.PNI)).thenReturn(ACCOUNT_PHONE_NUMBER_IDENTITY_KEY);
|
||||
@@ -1037,7 +1037,7 @@ class ProfileControllerTest {
|
||||
@Test
|
||||
void testGetProfileWithExpiringProfileKeyCredentialVersionNotFound() throws VerificationFailedException {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version("version")));
|
||||
|
||||
@@ -1249,7 +1249,7 @@ class ProfileControllerTest {
|
||||
final ProfileKeyCredentialRequest credentialRequest = profileKeyCredentialRequestContext.getRequest();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version));
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(UNIDENTIFIED_ACCESS_KEY));
|
||||
@@ -1318,7 +1318,7 @@ class ProfileControllerTest {
|
||||
final ProfileKeyCredentialRequest credentialRequest = profileKeyCredentialRequestContext.getRequest();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(UNIDENTIFIED_ACCESS_KEY));
|
||||
when(account.isIdentifiedBy(new AciServiceIdentifier(AuthHelper.VALID_UUID))).thenReturn(true);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version));
|
||||
@@ -1366,7 +1366,7 @@ class ProfileControllerTest {
|
||||
final ProfileKeyCredentialRequest credentialRequest = profileKeyCredentialRequestContext.getRequest();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(UNIDENTIFIED_ACCESS_KEY));
|
||||
when(account.isIdentifiedBy(new AciServiceIdentifier(AuthHelper.VALID_UUID))).thenReturn(true);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version("the-current-version")));
|
||||
|
||||
+1
-1
@@ -619,7 +619,7 @@ class RegistrationControllerTest {
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
final Account account = MockUtils.buildMock(Account.class, a -> {
|
||||
when(a.getUuid()).thenReturn(accountIdentifier);
|
||||
when(a.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(a.getPhoneNumberIdentifier()).thenReturn(phoneNumberIdentifier);
|
||||
when(a.getPrimaryDevice()).thenReturn(device);
|
||||
});
|
||||
|
||||
+1
-1
@@ -385,7 +385,7 @@ public class SecureValueRecovery2ControllerTest {
|
||||
|
||||
private static Account account(final UUID uuid) {
|
||||
final Account a = new Account();
|
||||
a.setUuid(uuid);
|
||||
a.setAccountIdentifier(uuid);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-18
@@ -81,25 +81,25 @@ class ExperimentEnrollmentManagerTest {
|
||||
.thenReturn(Optional.of(e164ExperimentEnrollmentConfiguration));
|
||||
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACCOUNT_UUID);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsEnrolled_UuidExperiment() {
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(
|
||||
experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME + "-unrelated-experiment"));
|
||||
experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME + "-unrelated-experiment"));
|
||||
|
||||
when(uuidSelector.getUuids()).thenReturn(Set.of(ACCOUNT_UUID));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(uuidSelector.getUuids()).thenReturn(Collections.emptySet());
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(0);
|
||||
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(experimentEnrollmentConfiguration.getExcludedUuids()).thenReturn(Set.of(EXCLUDED_UUID));
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
@@ -112,14 +112,14 @@ class ExperimentEnrollmentManagerTest {
|
||||
void testIsEnrolled_UuidExperimentPercentage() {
|
||||
when(uuidSelector.getUuids()).thenReturn(Set.of(ACCOUNT_UUID));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(0);
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME));
|
||||
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(75);
|
||||
final Map<Boolean, Long> counts = IntStream.range(0, 100).mapToObj(i -> {
|
||||
when(random.nextInt(100)).thenReturn(i);
|
||||
return experimentEnrollmentManager.isEnrolled(account.getUuid(), UUID_EXPERIMENT_NAME);
|
||||
return experimentEnrollmentManager.isEnrolled(account.getAccountIdentifier(), UUID_EXPERIMENT_NAME);
|
||||
})
|
||||
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||
assertEquals(25, counts.get(false));
|
||||
@@ -137,24 +137,24 @@ class ExperimentEnrollmentManagerTest {
|
||||
// test UUID enrollment is prioritized
|
||||
when(uuidSelector.getUuids()).thenReturn(Set.of(ACCOUNT_UUID));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
when(uuidSelector.getUuidEnrollmentPercentage()).thenReturn(0);
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
|
||||
// test fallback from UUID enrollment to general enrollment percentage
|
||||
when(uuidSelector.getUuids()).thenReturn(Collections.emptySet());
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
|
||||
// test fallback from UUID/general enrollment to e164 enrollment
|
||||
when(experimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(0);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertFalse(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
when(e164ExperimentEnrollmentConfiguration.getEnrollmentPercentage()).thenReturn(100);
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getUuid(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
assertTrue(experimentEnrollmentManager.isEnrolled(NOT_ENROLLED_164, account.getAccountIdentifier(), E164_AND_UUID_EXPERIMENT_NAME));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ class AccountsAnonymousGrpcServiceTest extends
|
||||
final byte[] usernameHash = TestRandomUtil.nextBytes(AccountController.USERNAME_HASH_LENGTH);
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
|
||||
when(accountsManager.getByUsernameHash(usernameHash))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
|
||||
+8
-8
@@ -170,7 +170,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
final UUID usernameLinkHandle = UUID.randomUUID();
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(phoneNumberIdentifier);
|
||||
when(account.getNumber()).thenReturn(e164);
|
||||
when(account.getUsernameHash()).thenReturn(Optional.of(usernameHash));
|
||||
@@ -759,7 +759,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
final Duration retryDuration = Duration.ofDays(1);
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI))
|
||||
.thenReturn(Optional.of(account));
|
||||
@@ -787,7 +787,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
|
||||
when(account.getBackupVoucher()).thenReturn(new Account.BackupVoucher(100, expiration));
|
||||
when(account.getBadges()).thenReturn(List.of(badge1, badge2));
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI)).thenReturn(Optional.of(account));
|
||||
|
||||
final GetEntitlementsResponse entitlements = authenticatedServiceStub()
|
||||
@@ -827,7 +827,7 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
final UUID updatedPni = UUID.randomUUID();
|
||||
|
||||
final Account updatedAccount = mock(Account.class);
|
||||
when(updatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(updatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(updatedAccount.getNumber()).thenReturn(newNumber);
|
||||
when(updatedAccount.getPhoneNumberIdentifier()).thenReturn(updatedPni);
|
||||
when(updatedAccount.getUsernameHash()).thenReturn(Optional.empty());
|
||||
@@ -996,8 +996,8 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
@ParameterizedTest
|
||||
@ArgumentsSource(AccountsTestHelper.AccountsDataReportArgumentProvider.class)
|
||||
void getAccountDataReport(final Account account, final String expectedTextAfterHeader) {
|
||||
getMockAuthenticationInterceptor().setAuthenticatedDevice(account.getUuid(), Device.PRIMARY_ID);
|
||||
when(accountsManager.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
getMockAuthenticationInterceptor().setAuthenticatedDevice(account.getAccountIdentifier(), Device.PRIMARY_ID);
|
||||
when(accountsManager.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final GetAccountDataReportResponse response =
|
||||
authenticatedServiceStub().getAccountDataReport(GetAccountDataReportRequest.newBuilder().build());
|
||||
@@ -1009,12 +1009,12 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
@Test
|
||||
void getCapabilities() {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
// public-visible and self-visible capabilities should be returned on the authenticated RPC
|
||||
when(account.hasCapability(DeviceCapability.SPARSE_POST_QUANTUM_RATCHET)).thenReturn(true);
|
||||
when(account.hasCapability(DeviceCapability.USERNAME_CHANGE_SYNC_MESSAGE)).thenReturn(true);
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI)).thenReturn(Optional.of(account));
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class ChallengeGrpcServiceTest extends
|
||||
|
||||
@Override
|
||||
protected ChallengeGrpcService createServiceBeforeEachTest() {
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI)).thenReturn(Optional.of(account));
|
||||
return new ChallengeGrpcService(
|
||||
accountsManager,
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class CredentialsAnonymousGrpcServiceTest extends
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(USER_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(USER_UUID);
|
||||
|
||||
when(accountsManager.getByE164(USER_E164)).thenReturn(Optional.of(account));
|
||||
}
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ public class CredentialsGrpcServiceTest
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getNumber()).thenReturn(PHONE_NUMBER);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.PNI)).thenReturn(AUTHENTICATED_PNI);
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ class DevicesGrpcServiceTest extends SimpleBaseGrpcTest<DevicesGrpcService, Devi
|
||||
|
||||
@Override
|
||||
protected DevicesGrpcService createServiceBeforeEachTest() {
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI))
|
||||
|
||||
+1
-1
@@ -381,7 +381,7 @@ class KeysAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<KeysAnonymousGrpcS
|
||||
final byte[] unidentifiedAccessKey = TestRandomUtil.nextBytes(UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH);
|
||||
|
||||
final Account targetAccount = mock(Account.class);
|
||||
when(targetAccount.getUuid()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getIdentityKey(IdentityType.ACI)).thenReturn(new IdentityKey(ECKeyPair.generate().getPublicKey()));
|
||||
when(targetAccount.getDevices()).thenReturn(Collections.emptyList());
|
||||
when(targetAccount.getDevice(anyByte())).thenReturn(Optional.empty());
|
||||
|
||||
+5
-6
@@ -72,7 +72,6 @@ import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||
import org.whispersystems.textsecuregcm.storage.Device;
|
||||
import org.whispersystems.textsecuregcm.storage.DeviceCapability;
|
||||
import org.whispersystems.textsecuregcm.storage.KeyIdUtil;
|
||||
import org.whispersystems.textsecuregcm.storage.KeysManager;
|
||||
import org.whispersystems.textsecuregcm.tests.util.KeysHelper;
|
||||
@@ -111,7 +110,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
when(authenticatedDevice.getId()).thenReturn(AUTHENTICATED_DEVICE_ID);
|
||||
|
||||
final Account authenticatedAccount = mock(Account.class);
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getPhoneNumberIdentifier()).thenReturn(AUTHENTICATED_PNI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.PNI)).thenReturn(AUTHENTICATED_PNI);
|
||||
@@ -470,7 +469,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
case ACI -> new AciServiceIdentifier(identifier);
|
||||
};
|
||||
|
||||
when(targetAccount.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getIdentifier(identityType)).thenReturn(identifier);
|
||||
when(targetAccount.getIdentityKey(identityType)).thenReturn(identityKey);
|
||||
when(accountsManager.getByServiceIdentifier(serviceIdentifier))
|
||||
@@ -587,7 +586,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
final UUID accountIdentifier = UUID.randomUUID();
|
||||
|
||||
final Account targetAccount = mock(Account.class);
|
||||
when(targetAccount.getUuid()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(targetAccount.getIdentityKey(IdentityType.ACI)).thenReturn(new IdentityKey(ECKeyPair.generate().getPublicKey()));
|
||||
when(targetAccount.getDevices()).thenReturn(Collections.emptyList());
|
||||
when(targetAccount.getDevice(anyByte())).thenReturn(Optional.empty());
|
||||
@@ -618,7 +617,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
when(mockDevice.getRegistrationId(IdentityType.ACI)).thenReturn(registrationId);
|
||||
|
||||
final Account targetAccount = mock(Account.class);
|
||||
when(targetAccount.getUuid()).thenReturn(targetAccountId);
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(targetAccountId);
|
||||
when(targetAccount.getIdentityKey(IdentityType.ACI)).thenReturn(new IdentityKey(ECKeyPair.generate().getPublicKey()));
|
||||
when(targetAccount.getDevice(targetDeviceId)).thenReturn(Optional.of(mockDevice));
|
||||
when(targetAccount.getDevices()).thenReturn(List.of(mockDevice));
|
||||
@@ -667,7 +666,7 @@ class KeysGrpcServiceTest extends SimpleBaseGrpcTest<KeysGrpcService, KeysGrpc.K
|
||||
case ACI -> new AciServiceIdentifier(identifier);
|
||||
};
|
||||
|
||||
when(targetAccount.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
when(targetAccount.getIdentifier(identityType)).thenReturn(identifier);
|
||||
when(targetAccount.getIdentityKey(identityType)).thenReturn(identityKey);
|
||||
when(accountsManager.getByServiceIdentifier(serviceIdentifier))
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class MessageDispatcherTest {
|
||||
void setUp() {
|
||||
account = mock(Account.class);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(ACI);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
|
||||
device = mock(Device.class);
|
||||
messagesManager = mock(MessagesManager.class);
|
||||
|
||||
+1
-3
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.when;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Empty;
|
||||
import io.grpc.Channel;
|
||||
import io.grpc.Grpc;
|
||||
import io.grpc.Status;
|
||||
import io.grpc.StatusException;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
@@ -45,7 +44,6 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
import org.junit.jupiter.api.function.ThrowingSupplier;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
@@ -173,7 +171,7 @@ class MessagesGrpcServiceTest extends SimpleBaseGrpcTest<MessagesGrpcService, Me
|
||||
when(secondLinkedDevice.getId()).thenReturn(SECOND_LINKED_DEVICE_ID);
|
||||
when(secondLinkedDevice.getRegistrationId(IdentityType.ACI)).thenReturn(SECOND_LINKED_DEVICE_REGISTRATION_ID);
|
||||
|
||||
when(authenticatedAccount.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getIdentifier(IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(authenticatedAccount.getDevice(anyByte())).thenReturn(Optional.empty());
|
||||
when(authenticatedAccount.getDevice(AUTHENTICATED_DEVICE_ID)).thenReturn(Optional.of(authenticatedDevice));
|
||||
|
||||
+4
-4
@@ -517,7 +517,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
final VersionedProfileV1 profile = mock(VersionedProfileV1.class);
|
||||
when(profile.commitment()).thenReturn(profileKeyCommitment.serialize());
|
||||
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(Optional.of(account));
|
||||
when(profilesManager.getV1(targetUuid, HexFormat.of().formatHex(profileKeyBytes))).thenReturn(Optional.of(profile));
|
||||
@@ -554,7 +554,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
final byte[] unidentifiedAccessKey = TestRandomUtil.nextBytes(UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH);
|
||||
final UUID targetUuid = UUID.randomUUID();
|
||||
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(
|
||||
missingAccount ? Optional.empty() : Optional.of(account));
|
||||
@@ -604,7 +604,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
final byte[] version = TestRandomUtil.nextBytes(32);
|
||||
final String versionHex = HexFormat.of().formatHex(version);
|
||||
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(
|
||||
Optional.of(account));
|
||||
@@ -643,7 +643,7 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest<ProfileA
|
||||
|
||||
final VersionedProfileV1 profile = mock(VersionedProfileV1.class);
|
||||
when(profile.commitment()).thenReturn("commitment".getBytes(StandardCharsets.UTF_8));
|
||||
when(account.getUuid()).thenReturn(targetUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetUuid);
|
||||
when(account.getUnidentifiedAccessKey()).thenReturn(Optional.of(unidentifiedAccessKey));
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetUuid))).thenReturn(Optional.of(account));
|
||||
when(profilesManager.getV1(targetUuid, versionHex)).thenReturn(Optional.of(profile));
|
||||
|
||||
+4
-4
@@ -182,7 +182,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
when(dynamicConfigurationManager.getConfiguration()).thenReturn(dynamicConfiguration);
|
||||
when(dynamicConfiguration.getPaymentsConfiguration()).thenReturn(dynamicPaymentsConfiguration);
|
||||
|
||||
when(account.getUuid()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getIdentifier(org.whispersystems.textsecuregcm.identity.IdentityType.ACI)).thenReturn(AUTHENTICATED_ACI);
|
||||
when(account.getNumber()).thenReturn(phoneNumber);
|
||||
when(account.getBadges()).thenReturn(Collections.emptyList());
|
||||
@@ -241,7 +241,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
final ArgumentCaptor<VersionedProfileV1> profileV1ArgumentCaptor = ArgumentCaptor.forClass(VersionedProfileV1.class);
|
||||
final ArgumentCaptor<VersionedProfile> profileArgumentCaptor = ArgumentCaptor.forClass(VersionedProfile.class);
|
||||
|
||||
verify(profilesManager).set(eq(account.getUuid()), profileV1ArgumentCaptor.capture(), profileArgumentCaptor.capture(), isNull());
|
||||
verify(profilesManager).set(eq(account.getAccountIdentifier()), profileV1ArgumentCaptor.capture(), profileArgumentCaptor.capture(), isNull());
|
||||
|
||||
final VersionedProfile profile = profileArgumentCaptor.getValue();
|
||||
|
||||
@@ -684,7 +684,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
final UUID targetAci = UUID.randomUUID();
|
||||
final VersionedProfile v2Profile = new VersionedProfile(version, data, paymentAddress, commitment);
|
||||
|
||||
when(account.getUuid()).thenReturn(targetAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetAci);
|
||||
when(account.getCurrentProfileVersion()).thenReturn(Optional.of(version));
|
||||
when(account.hasCapability(DeviceCapability.PROFILES_V2)).thenReturn(true);
|
||||
when(account.getIdentityKey(org.whispersystems.textsecuregcm.identity.IdentityType.ACI)).thenReturn(identityKey);
|
||||
@@ -737,7 +737,7 @@ public class ProfileGrpcServiceTest extends SimpleBaseGrpcTest<ProfileGrpcServic
|
||||
final VersionedProfile v2Profile = new VersionedProfile(version, data, paymentAddress, commitment);
|
||||
|
||||
final UUID targetAci = UUID.randomUUID();
|
||||
when(account.getUuid()).thenReturn(targetAci);
|
||||
when(account.getAccountIdentifier()).thenReturn(targetAci);
|
||||
when(account.hasCapability(DeviceCapability.PROFILES_V2)).thenReturn(true);
|
||||
when(accountsManager.getByServiceIdentifier(new AciServiceIdentifier(targetAci))).thenReturn(Optional.of(account));
|
||||
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ class RateLimitChallengeManagerTest {
|
||||
@ValueSource(booleans = {true, false})
|
||||
void answerPushChallenge(final boolean successfulChallenge) throws RateLimitExceededException {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(account.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
when(pushChallengeManager.answerChallenge(eq(account), any())).thenReturn(successfulChallenge);
|
||||
|
||||
@@ -84,7 +84,7 @@ class RateLimitChallengeManagerTest {
|
||||
throws RateLimitExceededException, IOException, InvalidCaptchaArgumentException {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getNumber()).thenReturn("+18005551234");
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(account.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
when(captchaChecker.verify(any(), eq(Action.CHALLENGE), any(), any(), any()))
|
||||
.thenReturn(AssessmentResult.fromScore(actualScore, DEFAULT_SCORE_THRESHOLD));
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ class RateLimitChallengeOptionManagerTest {
|
||||
final int expectedLength = (expectCaptcha ? 1 : 0) + (expectPushChallenge ? 1 : 0);
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(account.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
final List<RateLimitChallengeOption> options = rateLimitChallengeOptionManager.getChallengeOptions(account);
|
||||
assertEquals(expectedLength, options.size());
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class MessageMetricsTest {
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(pni);
|
||||
when(account.isIdentifiedBy(any())).thenReturn(false);
|
||||
when(account.isIdentifiedBy(new AciServiceIdentifier(aci))).thenReturn(true);
|
||||
|
||||
@@ -111,7 +111,7 @@ class MessageSenderTest {
|
||||
.setUrgent(urgent)
|
||||
.build();
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -168,7 +168,7 @@ class MessageSenderTest {
|
||||
final Device device = mock(Device.class);
|
||||
final MessageProtos.Envelope message = MessageProtos.Envelope.newBuilder().build();
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -209,7 +209,7 @@ class MessageSenderTest {
|
||||
final Device device = mock(Device.class);
|
||||
final MessageProtos.Envelope message = MessageProtos.Envelope.newBuilder().build();
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -245,7 +245,7 @@ class MessageSenderTest {
|
||||
final Account account = mock(Account.class);
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -306,7 +306,7 @@ class MessageSenderTest {
|
||||
final Account account = mock(Account.class);
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -361,7 +361,7 @@ class MessageSenderTest {
|
||||
final Account account = mock(Account.class);
|
||||
final Device device = mock(Device.class);
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
@@ -686,7 +686,7 @@ class MessageSenderTest {
|
||||
final byte deviceId = Device.PRIMARY_ID;
|
||||
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountIdentifier);
|
||||
when(account.isIdentifiedBy(serviceIdentifier)).thenReturn(true);
|
||||
|
||||
|
||||
+5
-5
@@ -190,7 +190,7 @@ class PushNotificationManagerTest {
|
||||
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
|
||||
final PushNotification pushNotification = new PushNotification(
|
||||
"token", tokenType, PushNotification.NotificationType.NOTIFICATION, null, account, device, urgent, null);
|
||||
@@ -226,7 +226,7 @@ class PushNotificationManagerTest {
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
when(device.getGcmId()).thenReturn("token");
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(aci);
|
||||
when(accountsManager.getByAccountIdentifier(aci)).thenReturn(Optional.of(account));
|
||||
|
||||
@@ -252,7 +252,7 @@ class PushNotificationManagerTest {
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
when(device.getApnId()).thenReturn("apns-token");
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(aci);
|
||||
when(accountsManager.getByAccountIdentifier(aci)).thenReturn(Optional.of(account));
|
||||
|
||||
@@ -284,7 +284,7 @@ class PushNotificationManagerTest {
|
||||
when(device.getApnId()).thenReturn("apns-token");
|
||||
when(device.getPushTimestamp()).thenReturn(tokenTimestamp.toEpochMilli());
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getUuid()).thenReturn(aci);
|
||||
when(account.getAccountIdentifier()).thenReturn(aci);
|
||||
when(accountsManager.getByAccountIdentifier(aci)).thenReturn(Optional.of(account));
|
||||
|
||||
final PushNotification pushNotification = new PushNotification(
|
||||
@@ -311,7 +311,7 @@ class PushNotificationManagerTest {
|
||||
final Device device = mock(Device.class);
|
||||
final String userAgent = HttpHeaders.USER_AGENT;
|
||||
|
||||
when(account.getUuid()).thenReturn(accountIdentifier);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountIdentifier);
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
|
||||
when(pushNotificationScheduler.cancelScheduledNotifications(account, device))
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class PushNotificationSchedulerTest {
|
||||
when(device.getLastSeen()).thenReturn(System.currentTimeMillis());
|
||||
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getNumber()).thenReturn(ACCOUNT_NUMBER);
|
||||
when(account.getDevice(DEVICE_ID)).thenReturn(Optional.of(device));
|
||||
|
||||
+6
-6
@@ -254,9 +254,9 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
aciPqLastResortPreKey,
|
||||
pniPqLastResortPreKey);
|
||||
|
||||
assertEquals(Optional.of(aciSignedPreKey), keysManager.getEcSignedPreKey(account.getUuid(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(aciSignedPreKey), keysManager.getEcSignedPreKey(account.getAccountIdentifier(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(pniSignedPreKey), keysManager.getEcSignedPreKey(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(aciPqLastResortPreKey), keysManager.getLastResort(account.getUuid(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(aciPqLastResortPreKey), keysManager.getLastResort(account.getAccountIdentifier(), Device.PRIMARY_ID).join());
|
||||
assertEquals(Optional.of(pniPqLastResortPreKey), keysManager.getLastResort(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join());
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
pniPqLastResortPreKey),
|
||||
null);
|
||||
|
||||
existingAccountUuid = existingAccount.getUuid();
|
||||
existingAccountUuid = existingAccount.getAccountIdentifier();
|
||||
}
|
||||
|
||||
final String password = RandomStringUtils.secure().nextAlphanumeric(16);
|
||||
@@ -394,7 +394,7 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
aciPqLastResortPreKey,
|
||||
pniPqLastResortPreKey);
|
||||
|
||||
assertEquals(existingAccountUuid, reregisteredAccount.getUuid());
|
||||
assertEquals(existingAccountUuid, reregisteredAccount.getAccountIdentifier());
|
||||
|
||||
verify(disconnectionRequestManager).requestDisconnection(argThat(account ->
|
||||
account.getIdentifier(IdentityType.ACI).equals(existingAccountUuid) && account != reregisteredAccount));
|
||||
@@ -464,9 +464,9 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
accountsManager.delete(account.getIdentifier(IdentityType.ACI), AccountsManager.DeletionReason.ADMIN_DELETED);
|
||||
|
||||
assertFalse(accountsManager.getByAccountIdentifier(aci).isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(account.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(account.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(account.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(account.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(account.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
|
||||
verify(disconnectionRequestManager).requestDisconnection(argThat(disconnectedAccount ->
|
||||
|
||||
@@ -135,7 +135,7 @@ class AccountTest {
|
||||
account.markStale();
|
||||
|
||||
assertThrows(AssertionError.class, account::getNumber);
|
||||
assertDoesNotThrow(account::getUuid);
|
||||
assertDoesNotThrow(account::getAccountIdentifier);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+15
-15
@@ -162,7 +162,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
final String secondNumber = "+18005552222";
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -177,7 +177,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isEmpty());
|
||||
|
||||
final Account updatedAccount = accountsManager.getByE164(secondNumber).orElseThrow();
|
||||
assertEquals(originalUuid, updatedAccount.getUuid());
|
||||
assertEquals(originalUuid, updatedAccount.getAccountIdentifier());
|
||||
assertEquals(secondNumber, updatedAccount.getNumber());
|
||||
assertNotEquals(originalPni, updatedAccount.getPhoneNumberIdentifier());
|
||||
|
||||
@@ -190,7 +190,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
final String originalNumber = "+18005551111";
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -203,7 +203,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
Map.of(Device.PRIMARY_ID, 1));
|
||||
|
||||
final Account updatedAccount = accountsManager.getByE164(originalNumber).orElseThrow();
|
||||
assertEquals(originalUuid, updatedAccount.getUuid());
|
||||
assertEquals(originalUuid, updatedAccount.getAccountIdentifier());
|
||||
assertEquals(originalNumber, updatedAccount.getNumber());
|
||||
assertEquals(originalPni, updatedAccount.getPhoneNumberIdentifier());
|
||||
|
||||
@@ -225,7 +225,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
keysManager.storeEcSignedPreKeys(account.getIdentifier(IdentityType.ACI),
|
||||
Device.PRIMARY_ID, KeysHelper.signedECPreKey(1, rotatedPniIdentityKeyPair)).join();
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final IdentityKey pniIdentityKey = new IdentityKey(rotatedPniIdentityKeyPair.getPublicKey());
|
||||
@@ -239,7 +239,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isEmpty());
|
||||
|
||||
assertTrue(accountsManager.getByE164(secondNumber).isPresent());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(secondNumber).map(Account::getUuid).orElseThrow());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(secondNumber).map(Account::getAccountIdentifier).orElseThrow());
|
||||
assertNotEquals(originalPni, secondPni);
|
||||
assertEquals(secondPni, accountsManager.getByE164(secondNumber).map(Account::getPhoneNumberIdentifier).orElseThrow());
|
||||
|
||||
@@ -262,7 +262,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair originalIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -285,7 +285,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
Map.of(Device.PRIMARY_ID, 2));
|
||||
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isPresent());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(originalNumber).map(Account::getUuid).orElseThrow());
|
||||
assertEquals(originalUuid, accountsManager.getByE164(originalNumber).map(Account::getAccountIdentifier).orElseThrow());
|
||||
assertEquals(originalPni, accountsManager.getByE164(originalNumber).map(Account::getPhoneNumberIdentifier).orElseThrow());
|
||||
|
||||
assertTrue(accountsManager.getByE164(secondNumber).isEmpty());
|
||||
@@ -303,7 +303,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final ECKeyPair originalIdentityKeyPair = ECKeyPair.generate();
|
||||
@@ -311,7 +311,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account existingAccount = AccountsHelper.createAccount(accountsManager, secondNumber);
|
||||
|
||||
final UUID existingAccountUuid = existingAccount.getUuid();
|
||||
final UUID existingAccountUuid = existingAccount.getAccountIdentifier();
|
||||
|
||||
accountsManager.changeNumber(originalUuid,
|
||||
secondNumber,
|
||||
@@ -325,7 +325,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
assertTrue(accountsManager.getByE164(originalNumber).isEmpty());
|
||||
|
||||
assertTrue(accountsManager.getByE164(secondNumber).isPresent());
|
||||
assertEquals(Optional.of(originalUuid), accountsManager.getByE164(secondNumber).map(Account::getUuid));
|
||||
assertEquals(Optional.of(originalUuid), accountsManager.getByE164(secondNumber).map(Account::getAccountIdentifier));
|
||||
|
||||
assertEquals(secondNumber, accountsManager.getByAccountIdentifier(originalUuid).map(Account::getNumber).orElseThrow());
|
||||
|
||||
@@ -344,7 +344,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account existingAccount2 = AccountsHelper.createAccount(accountsManager, secondNumber);
|
||||
|
||||
assertEquals(existingAccountUuid, existingAccount2.getUuid());
|
||||
assertEquals(existingAccountUuid, existingAccount2.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -354,12 +354,12 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
final UUID originalUuid = account.getUuid();
|
||||
final UUID originalUuid = account.getAccountIdentifier();
|
||||
final UUID originalPni = account.getPhoneNumberIdentifier();
|
||||
|
||||
final Account existingAccount = AccountsHelper.createAccount(accountsManager, secondNumber);
|
||||
|
||||
final UUID existingAccountUuid = existingAccount.getUuid();
|
||||
final UUID existingAccountUuid = existingAccount.getAccountIdentifier();
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account changedNumberAccount = accountsManager.changeNumber(originalUuid,
|
||||
@@ -373,7 +373,7 @@ class AccountsManagerChangeNumberIntegrationTest {
|
||||
|
||||
final Account reRegisteredAccount = AccountsHelper.createAccount(accountsManager, originalNumber);
|
||||
|
||||
assertEquals(existingAccountUuid, reRegisteredAccount.getUuid());
|
||||
assertEquals(existingAccountUuid, reRegisteredAccount.getAccountIdentifier());
|
||||
assertEquals(originalPni, reRegisteredAccount.getPhoneNumberIdentifier());
|
||||
|
||||
assertEquals(Optional.empty(), accountsManager.findRecentlyDeletedAccountIdentifier(originalPni));
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ class AccountsManagerConcurrentModificationIntegrationTest {
|
||||
a.addDevice(DevicesHelper.createDevice(Device.PRIMARY_ID));
|
||||
});
|
||||
|
||||
uuid = account.getUuid();
|
||||
uuid = account.getAccountIdentifier();
|
||||
}
|
||||
|
||||
final boolean discoverableByPhoneNumber = false;
|
||||
|
||||
+20
-20
@@ -286,7 +286,7 @@ class AccountsManagerTest {
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
assertEquals(account.get().getNumber(), "+14152222222");
|
||||
assertEquals(account.get().getUuid(), uuid);
|
||||
assertEquals(account.get().getAccountIdentifier(), uuid);
|
||||
assertEquals(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e"), account.get().getPhoneNumberIdentifier());
|
||||
|
||||
verify(clusterCommands, times(1)).get(eq("Account3::" + uuid));
|
||||
@@ -308,7 +308,7 @@ class AccountsManagerTest {
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
assertEquals(account.get().getNumber(), "+14152222222");
|
||||
assertEquals(account.get().getUuid(), uuid);
|
||||
assertEquals(account.get().getAccountIdentifier(), uuid);
|
||||
assertEquals(UUID.fromString("de24dc73-fbd8-41be-a7d5-764c70d9da7e"), account.get().getPhoneNumberIdentifier());
|
||||
|
||||
verify(asyncClusterCommands, times(1)).get(eq("Account3::" + uuid));
|
||||
@@ -669,7 +669,7 @@ class AccountsManagerTest {
|
||||
|
||||
Account account = AccountsHelper.generateTestAccount("+14152222222", List.of(primaryDevice, linkedDevice));
|
||||
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
when(keysManager.deleteSingleUsePreKeys(any(), anyByte())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(messagesManager.clear(any(), anyByte())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
|
||||
@@ -678,10 +678,10 @@ class AccountsManagerTest {
|
||||
account = accountsManager.removeDevice(account.getIdentifier(IdentityType.ACI), linkedDevice.getId());
|
||||
|
||||
assertFalse(account.getDevice(linkedDevice.getId()).isPresent());
|
||||
verify(messagesManager, times(2)).clear(account.getUuid(), linkedDevice.getId());
|
||||
verify(keysManager, times(2)).deleteSingleUsePreKeys(account.getUuid(), linkedDevice.getId());
|
||||
verify(keysManager).buildWriteItemsForRemovedDevice(account.getUuid(), account.getPhoneNumberIdentifier(), linkedDevice.getId());
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of(linkedDevice.getId()));
|
||||
verify(messagesManager, times(2)).clear(account.getAccountIdentifier(), linkedDevice.getId());
|
||||
verify(keysManager, times(2)).deleteSingleUsePreKeys(account.getAccountIdentifier(), linkedDevice.getId());
|
||||
verify(keysManager).buildWriteItemsForRemovedDevice(account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), linkedDevice.getId());
|
||||
verify(disconnectionRequestManager).requestDisconnection(account.getAccountIdentifier(), List.of(linkedDevice.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -714,7 +714,7 @@ class AccountsManagerTest {
|
||||
|
||||
verify(accounts).create(argThat(account -> e164.equals(account.getNumber())), any());
|
||||
verify(keysManager).buildWriteItemsForNewDevice(
|
||||
eq(createdAccount.getUuid()),
|
||||
eq(createdAccount.getAccountIdentifier()),
|
||||
eq(createdAccount.getPhoneNumberIdentifier()),
|
||||
eq(Device.PRIMARY_ID),
|
||||
notNull(),
|
||||
@@ -722,7 +722,7 @@ class AccountsManagerTest {
|
||||
notNull(),
|
||||
notNull());
|
||||
|
||||
verify(changeNumberWaitingPeriodManager).handleAccountCreated(eq(createdAccount.getUuid()), any(Instant.class));
|
||||
verify(changeNumberWaitingPeriodManager).handleAccountCreated(eq(createdAccount.getAccountIdentifier()), any(Instant.class));
|
||||
|
||||
verifyNoInteractions(messagesManager);
|
||||
verifyNoInteractions(profilesManager);
|
||||
@@ -746,7 +746,7 @@ class AccountsManagerTest {
|
||||
final Account requestedAccount = invocation.getArgument(0);
|
||||
|
||||
final Account existingAccount = mock(Account.class);
|
||||
when(existingAccount.getUuid()).thenReturn(existingUuid);
|
||||
when(existingAccount.getAccountIdentifier()).thenReturn(existingUuid);
|
||||
when(existingAccount.getIdentifier(IdentityType.ACI)).thenReturn(existingUuid);
|
||||
when(existingAccount.getNumber()).thenReturn(existingAccountE164);
|
||||
when(existingAccount.getPhoneNumberIdentifier()).thenReturn(requestedAccount.getIdentifier(IdentityType.PNI));
|
||||
@@ -764,10 +764,10 @@ class AccountsManagerTest {
|
||||
assertEquals(e164, reregisteredAccount.getNumber());
|
||||
|
||||
verify(accounts)
|
||||
.create(argThat(account -> e164.equals(account.getNumber()) && existingUuid.equals(account.getUuid())), any());
|
||||
.create(argThat(account -> e164.equals(account.getNumber()) && existingUuid.equals(account.getAccountIdentifier())), any());
|
||||
|
||||
verify(keysManager).buildWriteItemsForNewDevice(
|
||||
eq(reregisteredAccount.getUuid()),
|
||||
eq(reregisteredAccount.getAccountIdentifier()),
|
||||
eq(reregisteredAccount.getPhoneNumberIdentifier()),
|
||||
eq(Device.PRIMARY_ID),
|
||||
notNull(),
|
||||
@@ -797,7 +797,7 @@ class AccountsManagerTest {
|
||||
final Account account = createAccount(e164, attributes);
|
||||
|
||||
verify(accounts).create(
|
||||
argThat(a -> e164.equals(a.getNumber()) && recentlyDeletedUuid.equals(a.getUuid())),
|
||||
argThat(a -> e164.equals(a.getNumber()) && recentlyDeletedUuid.equals(a.getAccountIdentifier())),
|
||||
any());
|
||||
|
||||
verify(keysManager).buildWriteItemsForNewDevice(eq(account.getIdentifier(IdentityType.ACI)),
|
||||
@@ -1124,7 +1124,7 @@ class AccountsManagerTest {
|
||||
@Test
|
||||
void testReserveUsernameHash() throws UsernameHashNotAvailableException {
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final List<byte[]> usernameHashes = List.of(TestRandomUtil.nextBytes(32), TestRandomUtil.nextBytes(32));
|
||||
|
||||
@@ -1138,7 +1138,7 @@ class AccountsManagerTest {
|
||||
final byte[] oldUsernameHash = TestRandomUtil.nextBytes(32);
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
account.setUsernameHash(oldUsernameHash);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final List<byte[]> usernameHashes = List.of(TestRandomUtil.nextBytes(32), oldUsernameHash, TestRandomUtil.nextBytes(32));
|
||||
|
||||
@@ -1150,7 +1150,7 @@ class AccountsManagerTest {
|
||||
@Test
|
||||
void testReserveUsernameOptimisticLockingFailure() throws UsernameHashNotAvailableException {
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
final List<byte[]> usernameHashes = List.of(TestRandomUtil.nextBytes(32), TestRandomUtil.nextBytes(32));
|
||||
|
||||
@@ -1190,7 +1190,7 @@ class AccountsManagerTest {
|
||||
void testConfirmReservedUsernameHashOptimisticLockingFailure() throws UsernameHashNotAvailableException, UsernameReservationNotFoundException {
|
||||
final Account account = AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), new ArrayList<>(), new byte[UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH]);
|
||||
setReservationHash(account, USERNAME_HASH_1);
|
||||
when(accounts.getByAccountIdentifier(account.getUuid())).thenReturn(Optional.of(account));
|
||||
when(accounts.getByAccountIdentifier(account.getAccountIdentifier())).thenReturn(Optional.of(account));
|
||||
|
||||
doThrow(new ContestedOptimisticLockException())
|
||||
.doNothing()
|
||||
@@ -1275,7 +1275,7 @@ class AccountsManagerTest {
|
||||
final Account account = AccountsHelper.generateTestAccount("+14152222222", List.of(primaryDevice, linkedDevice));
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> accountsManager.waitForNewLinkedDevice(account.getUuid(), linkedDevice, "", Duration.ofSeconds(1)));
|
||||
() -> accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(), linkedDevice, "", Duration.ofSeconds(1)));
|
||||
|
||||
}
|
||||
|
||||
@@ -1292,9 +1292,9 @@ class AccountsManagerTest {
|
||||
UUID.fromString("111111-1111-1111-1111-111111111111")).orElseThrow();
|
||||
|
||||
final String serialized = AccountsManager.writeRedisAccountJson(originalAccount);
|
||||
final Account parsedAccount = AccountsManager.parseAccountJson(serialized, originalAccount.getUuid()).orElseThrow();
|
||||
final Account parsedAccount = AccountsManager.parseAccountJson(serialized, originalAccount.getAccountIdentifier()).orElseThrow();
|
||||
|
||||
assertEquals(originalAccount.getUuid(), parsedAccount.getUuid());
|
||||
assertEquals(originalAccount.getAccountIdentifier(), parsedAccount.getAccountIdentifier());
|
||||
assertEquals(originalAccount.getPhoneNumberIdentifier(), parsedAccount.getPhoneNumberIdentifier());
|
||||
assertEquals(originalAccount.getIdentityKey(IdentityType.ACI), parsedAccount.getIdentityKey(IdentityType.ACI));
|
||||
assertEquals(originalAccount.getIdentityKey(IdentityType.PNI), parsedAccount.getIdentityKey(IdentityType.PNI));
|
||||
|
||||
+8
-8
@@ -180,7 +180,7 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
() -> accountsManager.reserveUsernameHash(account.getIdentifier(IdentityType.ACI), usernameHashes));
|
||||
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,16 +227,16 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
reservation.reservedUsernameHash(),
|
||||
ENCRYPTED_USERNAME_1);
|
||||
assertArrayEquals(account.getUsernameHash().orElseThrow(), USERNAME_HASH_1);
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid()).isEqualTo(
|
||||
account.getUuid());
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier()).isEqualTo(
|
||||
account.getAccountIdentifier());
|
||||
assertThat(account.getUsernameLinkHandle()).isNotNull();
|
||||
assertThat(accountsManager.getByUsernameLinkHandle(account.getUsernameLinkHandle()).join().orElseThrow().getUuid())
|
||||
.isEqualTo(account.getUuid());
|
||||
assertThat(accountsManager.getByUsernameLinkHandle(account.getUsernameLinkHandle()).join().orElseThrow().getAccountIdentifier())
|
||||
.isEqualTo(account.getAccountIdentifier());
|
||||
|
||||
// clear
|
||||
account = accountsManager.clearUsernameHash(account.getIdentifier(IdentityType.ACI));
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,7 +256,7 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
// clear
|
||||
account = accountsManager.clearUsernameHash(account.getIdentifier(IdentityType.ACI));
|
||||
assertThat(accountsManager.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
assertThat(accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getUsernameHash()).isEmpty();
|
||||
|
||||
assertThat(accountsManager.getByUsernameHash(reservation.reservedUsernameHash()).join()).isEmpty();
|
||||
|
||||
@@ -294,7 +294,7 @@ class AccountsManagerUsernameIntegrationTest {
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
() -> accountsManager.confirmReservedUsernameHash(reservation1.account().getIdentifier(IdentityType.ACI), USERNAME_HASH_1, ENCRYPTED_USERNAME_1));
|
||||
account2 = accountsManager.confirmReservedUsernameHash(reservation2.account().getIdentifier(IdentityType.ACI), USERNAME_HASH_1, ENCRYPTED_USERNAME_1);
|
||||
assertEquals(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid(), account2.getUuid());
|
||||
assertEquals(accountsManager.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier(), account2.getAccountIdentifier());
|
||||
assertArrayEquals(account2.getUsernameHash().orElseThrow(), USERNAME_HASH_1);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class AccountsTest {
|
||||
final BiConsumer<Optional<Account>, byte[]> validator = (maybeAccount, expectedEncryptedUsername) -> {
|
||||
assertTrue(maybeAccount.isPresent());
|
||||
assertTrue(maybeAccount.get().getEncryptedUsername().isPresent());
|
||||
assertEquals(account.getUuid(), maybeAccount.get().getUuid());
|
||||
assertEquals(account.getAccountIdentifier(), maybeAccount.get().getAccountIdentifier());
|
||||
assertArrayEquals(expectedEncryptedUsername, maybeAccount.get().getEncryptedUsername().get());
|
||||
};
|
||||
|
||||
@@ -189,17 +189,17 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
freshUser = createAccount(account);
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,20 +212,20 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
accounts.delete(originalUuid, Collections.emptyList());
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(account.getPhoneNumberIdentifier())).hasValue(originalUuid);
|
||||
|
||||
freshUser = createAccount(account);
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(account.getPhoneNumberIdentifier())).isEmpty();
|
||||
}
|
||||
@@ -237,10 +237,10 @@ class AccountsTest {
|
||||
|
||||
createAccount(account);
|
||||
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -251,10 +251,10 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
account.setNumber("+14153334444", UUID.randomUUID());
|
||||
assertThrows(IllegalArgumentException.class, () -> createAccount(account),
|
||||
@@ -269,10 +269,10 @@ class AccountsTest {
|
||||
boolean freshUser = createAccount(account1);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
verifyStoredState("+14151112222", account1.getUuid(), account1.getPhoneNumberIdentifier(), null, account1, true);
|
||||
verifyStoredState("+14151112222", account1.getAccountIdentifier(), account1.getPhoneNumberIdentifier(), null, account1, true);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account1.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account1.getPhoneNumberIdentifier(), account1.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account1.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account1.getPhoneNumberIdentifier(), account1.getAccountIdentifier());
|
||||
|
||||
Device device2 = generateDevice(DEVICE_ID_1);
|
||||
Account account2 = generateAccount("+14151112222", UUID.randomUUID(), account1.getPhoneNumberIdentifier(),
|
||||
@@ -399,7 +399,7 @@ class AccountsTest {
|
||||
assertThrows(AccountAlreadyExistsException.class,
|
||||
() -> accounts.create(reregisteredAccount, Collections.emptyList()));
|
||||
|
||||
reregisteredAccount.setUuid(accountAlreadyExistsException.getExistingAccount().getUuid());
|
||||
reregisteredAccount.setAccountIdentifier(accountAlreadyExistsException.getExistingAccount().getAccountIdentifier());
|
||||
|
||||
// Phone number canonicalization means that a user can re-register with a different phone number
|
||||
// in the same equivalence class and get back the same phone number identifier.
|
||||
@@ -459,7 +459,7 @@ class AccountsTest {
|
||||
accounts.confirmUsernameHash(existingAccount, usernameHash, encryptedUsername);
|
||||
final UUID usernameLinkHandle = existingAccount.getUsernameLinkHandle();
|
||||
|
||||
verifyStoredState(e164, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), usernameHash, existingAccount, true);
|
||||
verifyStoredState(e164, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), usernameHash, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(e164, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(existingPni, existingUuid);
|
||||
@@ -516,7 +516,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(firstNumber, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(firstNumber, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(firstNumber, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(pni, existingUuid);
|
||||
@@ -560,7 +560,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(beninPhoneNumber, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(pni, existingUuid);
|
||||
@@ -578,7 +578,7 @@ class AccountsTest {
|
||||
assertThrows(AccountAlreadyExistsException.class,
|
||||
() -> accounts.create(secondAccount, Collections.emptyList()));
|
||||
|
||||
secondAccount.setUuid(accountAlreadyExistsException.getExistingAccount().getUuid());
|
||||
secondAccount.setAccountIdentifier(accountAlreadyExistsException.getExistingAccount().getAccountIdentifier());
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> accounts.reclaimAccount(existingAccount,
|
||||
secondAccount,
|
||||
@@ -595,7 +595,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(beninPhoneNumber, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(beninPhoneNumber, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(existingPni, existingUuid);
|
||||
@@ -626,7 +626,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(existingAccount);
|
||||
|
||||
verifyStoredState(newFormatBeninE164, existingAccount.getUuid(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
verifyStoredState(newFormatBeninE164, existingAccount.getAccountIdentifier(), existingAccount.getPhoneNumberIdentifier(), null, existingAccount, true);
|
||||
|
||||
assertPhoneNumberConstraintExists(newFormatBeninE164, existingUuid);
|
||||
assertPhoneNumberIdentifierConstraintExists(existingPni, existingUuid);
|
||||
@@ -652,25 +652,25 @@ class AccountsTest {
|
||||
|
||||
createAccount(account);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
device.setName("foobar".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
accounts.update(account);
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getAccountIdentifier());
|
||||
|
||||
Optional<Account> retrieved = accounts.getByE164("+14151112222");
|
||||
|
||||
assertThat(retrieved.isPresent()).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
|
||||
retrieved = accounts.getByAccountIdentifier(account.getUuid());
|
||||
retrieved = accounts.getByAccountIdentifier(account.getAccountIdentifier());
|
||||
|
||||
assertThat(retrieved.isPresent()).isTrue();
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
device = generateDevice(DEVICE_ID_1);
|
||||
Account unknownAccount = generateAccount("+14151113333", UUID.randomUUID(), UUID.randomUUID(), List.of(device));
|
||||
@@ -681,7 +681,7 @@ class AccountsTest {
|
||||
|
||||
assertThat(account.getVersion()).isEqualTo(2);
|
||||
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
|
||||
account.setVersion(1);
|
||||
|
||||
@@ -691,7 +691,7 @@ class AccountsTest {
|
||||
|
||||
accounts.update(account);
|
||||
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -725,7 +725,7 @@ class AccountsTest {
|
||||
final byte[] deviceName = "device-name".getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
assertNotEquals(deviceName,
|
||||
accounts.getByAccountIdentifier(account.getUuid()).orElseThrow().getPrimaryDevice().getName());
|
||||
accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getPrimaryDevice().getName());
|
||||
|
||||
assertFalse(DYNAMO_DB_EXTENSION.getDynamoDbClient().getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.CLIENT_RELEASES.tableName())
|
||||
@@ -749,7 +749,7 @@ class AccountsTest {
|
||||
.build()));
|
||||
|
||||
assertArrayEquals(deviceName,
|
||||
accounts.getByAccountIdentifier(account.getUuid()).orElseThrow().getPrimaryDevice().getName());
|
||||
accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getPrimaryDevice().getName());
|
||||
|
||||
assertTrue(DYNAMO_DB_EXTENSION.getDynamoDbClient().getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.CLIENT_RELEASES.tableName())
|
||||
@@ -822,8 +822,8 @@ class AccountsTest {
|
||||
accounts.getAll(2, Schedulers.parallel()).collectList().block();
|
||||
|
||||
assertNotNull(retrievedAccounts);
|
||||
assertEquals(expectedAccounts.stream().map(Account::getUuid).collect(Collectors.toSet()),
|
||||
retrievedAccounts.stream().map(Account::getUuid).collect(Collectors.toSet()));
|
||||
assertEquals(expectedAccounts.stream().map(Account::getAccountIdentifier).collect(Collectors.toSet()),
|
||||
retrievedAccounts.stream().map(Account::getAccountIdentifier).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -856,24 +856,24 @@ class AccountsTest {
|
||||
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(deletedAccount.getPhoneNumberIdentifier())).isEmpty();
|
||||
|
||||
assertPhoneNumberConstraintExists("+14151112222", deletedAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(deletedAccount.getPhoneNumberIdentifier(), deletedAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112345", retainedAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(retainedAccount.getPhoneNumberIdentifier(), retainedAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists("+14151112222", deletedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(deletedAccount.getPhoneNumberIdentifier(), deletedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberConstraintExists("+14151112345", retainedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(retainedAccount.getPhoneNumberIdentifier(), retainedAccount.getAccountIdentifier());
|
||||
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifier(retainedAccount.getUuid())).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getAccountIdentifier())).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifier(retainedAccount.getAccountIdentifier())).isPresent();
|
||||
|
||||
accounts.delete(deletedAccount.getUuid(), Collections.emptyList());
|
||||
accounts.delete(deletedAccount.getAccountIdentifier(), Collections.emptyList());
|
||||
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isNotPresent();
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(deletedAccount.getPhoneNumberIdentifier())).hasValue(deletedAccount.getUuid());
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getAccountIdentifier())).isNotPresent();
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(deletedAccount.getPhoneNumberIdentifier())).hasValue(deletedAccount.getAccountIdentifier());
|
||||
|
||||
assertPhoneNumberConstraintDoesNotExist(deletedAccount.getNumber());
|
||||
assertPhoneNumberIdentifierConstraintDoesNotExist(deletedAccount.getPhoneNumberIdentifier());
|
||||
|
||||
verifyStoredState(retainedAccount.getNumber(), retainedAccount.getUuid(), retainedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(retainedAccount.getUuid()).orElseThrow(), retainedAccount);
|
||||
verifyStoredState(retainedAccount.getNumber(), retainedAccount.getAccountIdentifier(), retainedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(retainedAccount.getAccountIdentifier()).orElseThrow(), retainedAccount);
|
||||
|
||||
{
|
||||
final Account recreatedAccount = generateAccount(deletedAccount.getNumber(), UUID.randomUUID(),
|
||||
@@ -882,12 +882,12 @@ class AccountsTest {
|
||||
final boolean freshUser = createAccount(recreatedAccount);
|
||||
|
||||
assertThat(freshUser).isTrue();
|
||||
assertThat(accounts.getByAccountIdentifier(recreatedAccount.getUuid())).isPresent();
|
||||
verifyStoredState(recreatedAccount.getNumber(), recreatedAccount.getUuid(), recreatedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(recreatedAccount.getUuid()).orElseThrow(), recreatedAccount);
|
||||
assertThat(accounts.getByAccountIdentifier(recreatedAccount.getAccountIdentifier())).isPresent();
|
||||
verifyStoredState(recreatedAccount.getNumber(), recreatedAccount.getAccountIdentifier(), recreatedAccount.getPhoneNumberIdentifier(),
|
||||
null, accounts.getByAccountIdentifier(recreatedAccount.getAccountIdentifier()).orElseThrow(), recreatedAccount);
|
||||
|
||||
assertPhoneNumberConstraintExists(recreatedAccount.getNumber(), recreatedAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(recreatedAccount.getPhoneNumberIdentifier(), recreatedAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists(recreatedAccount.getNumber(), recreatedAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(recreatedAccount.getPhoneNumberIdentifier(), recreatedAccount.getAccountIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(account);
|
||||
|
||||
assertThat(accounts.getByAccountIdentifierAsync(account.getUuid()).join()).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifierAsync(account.getAccountIdentifier()).join()).isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -949,13 +949,13 @@ class AccountsTest {
|
||||
Account account = generateAccount("+14151112222", UUID.randomUUID(), UUID.randomUUID(), List.of(device));
|
||||
account.setDiscoverableByPhoneNumber(false);
|
||||
createAccount(account);
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
account.setDiscoverableByPhoneNumber(true);
|
||||
accounts.update(account);
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, true);
|
||||
account.setDiscoverableByPhoneNumber(false);
|
||||
accounts.update(account);
|
||||
verifyStoredState("+14151112222", account.getUuid(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
verifyStoredState("+14151112222", account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, account, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
@@ -975,14 +975,14 @@ class AccountsTest {
|
||||
|
||||
assertThat(accounts.getByPhoneNumberIdentifier(originalPni)).isPresent();
|
||||
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getUuid());
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getAccountIdentifier());
|
||||
|
||||
{
|
||||
final Optional<Account> retrieved = accounts.getByE164(originalNumber);
|
||||
assertThat(retrieved).isPresent();
|
||||
|
||||
verifyStoredState(originalNumber, account.getUuid(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
verifyStoredState(originalNumber, account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
}
|
||||
|
||||
accounts.changeNumber(account, targetNumber, targetPni, maybeDisplacedAccountIdentifier, Collections.emptyList());
|
||||
@@ -992,14 +992,14 @@ class AccountsTest {
|
||||
|
||||
assertPhoneNumberConstraintDoesNotExist(originalNumber);
|
||||
assertPhoneNumberIdentifierConstraintDoesNotExist(originalPni);
|
||||
assertPhoneNumberConstraintExists(targetNumber, account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, account.getUuid());
|
||||
assertPhoneNumberConstraintExists(targetNumber, account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, account.getAccountIdentifier());
|
||||
|
||||
{
|
||||
final Optional<Account> retrieved = accounts.getByE164(targetNumber);
|
||||
assertThat(retrieved).isPresent();
|
||||
|
||||
verifyStoredState(targetNumber, account.getUuid(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
verifyStoredState(targetNumber, account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), null, retrieved.get(), account);
|
||||
|
||||
assertThat(retrieved.get().getPhoneNumberIdentifier()).isEqualTo(targetPni);
|
||||
assertThat(accounts.getByPhoneNumberIdentifier(targetPni)).isPresent();
|
||||
@@ -1032,12 +1032,12 @@ class AccountsTest {
|
||||
createAccount(account);
|
||||
createAccount(existingAccount);
|
||||
|
||||
assertThrows(TransactionCanceledException.class, () -> accounts.changeNumber(account, targetNumber, targetPni, Optional.of(existingAccount.getUuid()), Collections.emptyList()));
|
||||
assertThrows(TransactionCanceledException.class, () -> accounts.changeNumber(account, targetNumber, targetPni, Optional.of(existingAccount.getAccountIdentifier()), Collections.emptyList()));
|
||||
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getUuid());
|
||||
assertPhoneNumberConstraintExists(targetNumber, existingAccount.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, existingAccount.getUuid());
|
||||
assertPhoneNumberConstraintExists(originalNumber, account.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(originalPni, account.getAccountIdentifier());
|
||||
assertPhoneNumberConstraintExists(targetNumber, existingAccount.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, existingAccount.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1085,7 +1085,7 @@ class AccountsTest {
|
||||
|
||||
createAccount(firstAccountInstance);
|
||||
|
||||
final Account secondAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getUuid()).orElseThrow();
|
||||
final Account secondAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getAccountIdentifier()).orElseThrow();
|
||||
|
||||
// update via the first instance, which will update the version
|
||||
firstAccountInstance.setCurrentProfileVersion(new byte[32]);
|
||||
@@ -1095,15 +1095,15 @@ class AccountsTest {
|
||||
() -> accounts.changeNumber(secondAccountInstance, targetNumber, targetPni, Optional.empty(),
|
||||
Collections.emptyList()), "Second account instance has stale version");
|
||||
|
||||
final Account refreshedAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getUuid())
|
||||
final Account refreshedAccountInstance = accounts.getByAccountIdentifier(firstAccountInstance.getAccountIdentifier())
|
||||
.orElseThrow();
|
||||
accounts.changeNumber(refreshedAccountInstance, targetNumber, targetPni, Optional.empty(),
|
||||
Collections.emptyList());
|
||||
|
||||
assertPhoneNumberConstraintDoesNotExist(originalNumber);
|
||||
assertPhoneNumberIdentifierConstraintDoesNotExist(originalPni);
|
||||
assertPhoneNumberConstraintExists(targetNumber, firstAccountInstance.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, firstAccountInstance.getUuid());
|
||||
assertPhoneNumberConstraintExists(targetNumber, firstAccountInstance.getAccountIdentifier());
|
||||
assertPhoneNumberIdentifierConstraintExists(targetPni, firstAccountInstance.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1119,10 +1119,10 @@ class AccountsTest {
|
||||
|
||||
{
|
||||
final Optional<Account> maybeAccount = accounts.getByUsernameHash(USERNAME_HASH_1).join();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.orElseThrow(), account);
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.orElseThrow(), account);
|
||||
|
||||
final Optional<Account> maybeAccount2 = accounts.getByUsernameLinkHandle(oldHandle).join();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount2.orElseThrow(), account);
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount2.orElseThrow(), account);
|
||||
}
|
||||
|
||||
accounts.reserveUsernameHash(account, USERNAME_HASH_2, Duration.ofDays(1));
|
||||
@@ -1133,7 +1133,7 @@ class AccountsTest {
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(getUsernameConstraintTableItem(USERNAME_HASH_1)).containsExactlyInAnyOrderEntriesOf(Map.of(
|
||||
Accounts.UsernameTable.KEY_USERNAME_HASH, AttributeValues.b(USERNAME_HASH_1),
|
||||
Accounts.UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.b(account.getUuid()),
|
||||
Accounts.UsernameTable.ATTR_ACCOUNT_UUID, AttributeValues.b(account.getAccountIdentifier()),
|
||||
Accounts.UsernameTable.ATTR_CONFIRMED, AttributeValues.fromBool(false),
|
||||
Accounts.UsernameTable.ATTR_TTL,
|
||||
AttributeValues.n(clock.instant().plus(Accounts.USERNAME_HOLD_DURATION).getEpochSecond())));
|
||||
@@ -1143,10 +1143,10 @@ class AccountsTest {
|
||||
final Optional<Account> maybeAccount = accounts.getByUsernameHash(USERNAME_HASH_2).join();
|
||||
|
||||
assertThat(maybeAccount).isPresent();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(),
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(),
|
||||
USERNAME_HASH_2, maybeAccount.orElseThrow(), account);
|
||||
final Optional<Account> maybeAccount2 = accounts.getByUsernameLinkHandle(newHandle).join();
|
||||
verifyStoredState(account.getNumber(), account.getUuid(), account.getPhoneNumberIdentifier(),
|
||||
verifyStoredState(account.getNumber(), account.getAccountIdentifier(), account.getPhoneNumberIdentifier(),
|
||||
USERNAME_HASH_2, maybeAccount2.orElseThrow(), account);
|
||||
}
|
||||
}
|
||||
@@ -1168,7 +1168,7 @@ class AccountsTest {
|
||||
final Optional<Account> maybeAccount = accounts.getByUsernameHash(USERNAME_HASH_1).join();
|
||||
|
||||
assertThat(maybeAccount).isPresent();
|
||||
verifyStoredState(firstAccount.getNumber(), firstAccount.getUuid(), firstAccount.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.get(), firstAccount);
|
||||
verifyStoredState(firstAccount.getNumber(), firstAccount.getAccountIdentifier(), firstAccount.getPhoneNumberIdentifier(), USERNAME_HASH_1, maybeAccount.get(), firstAccount);
|
||||
|
||||
// throw an error if second account tries to reserve or confirm the same username hash
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
@@ -1305,7 +1305,7 @@ class AccountsTest {
|
||||
accounts.clearUsernameHash(account);
|
||||
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join()).isEmpty();
|
||||
assertThat(accounts.getByAccountIdentifier(account.getUuid()))
|
||||
assertThat(accounts.getByAccountIdentifier(account.getAccountIdentifier()))
|
||||
.hasValueSatisfying(clearedAccount -> {
|
||||
assertThat(clearedAccount.getUsernameHash()).isEmpty();
|
||||
assertThat(clearedAccount.getUsernameLinkHandle()).isNull();
|
||||
@@ -1411,7 +1411,7 @@ class AccountsTest {
|
||||
accounts.confirmUsernameHash(account1, USERNAME_HASH_1, ENCRYPTED_USERNAME_1);
|
||||
assertThat(account1.getReservedUsernameHash()).isEmpty();
|
||||
assertArrayEquals(USERNAME_HASH_1, account1.getUsernameHash().orElseThrow());
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid()).isEqualTo(account1.getUuid());
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier()).isEqualTo(account1.getAccountIdentifier());
|
||||
|
||||
final Map<String, AttributeValue> usernameConstraintRecord = getUsernameConstraintTableItem(USERNAME_HASH_1);
|
||||
|
||||
@@ -1518,7 +1518,7 @@ class AccountsTest {
|
||||
() -> accounts.reserveUsernameHash(account1, USERNAME_HASH_1, Duration.ofDays(2)));
|
||||
assertThrows(UsernameHashNotAvailableException.class,
|
||||
() -> accounts.confirmUsernameHash(account1, USERNAME_HASH_1, ENCRYPTED_USERNAME_1));
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getUuid()).isEqualTo(account2.getUuid());
|
||||
assertThat(accounts.getByUsernameHash(USERNAME_HASH_1).join().orElseThrow().getAccountIdentifier()).isEqualTo(account2.getAccountIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1552,7 +1552,7 @@ class AccountsTest {
|
||||
accounts.confirmUsernameHash(account, username, ENCRYPTED_USERNAME_1);
|
||||
assertThat(accounts.getByUsernameHash(username).join()).isPresent();
|
||||
|
||||
final Account read = accounts.getByAccountIdentifier(account.getUuid()).orElseThrow();
|
||||
final Account read = accounts.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow();
|
||||
assertThat(read.getUsernameHolds().stream().map(Account.UsernameHold::usernameHash).toList())
|
||||
.containsExactlyElementsOf(expectedHolds);
|
||||
|
||||
@@ -1751,7 +1751,7 @@ class AccountsTest {
|
||||
final Map<String, AttributeValue> accountRecord = DYNAMO_DB_EXTENSION.getDynamoDbClient()
|
||||
.getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.ACCOUNTS.tableName())
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.build())
|
||||
.item();
|
||||
final Map<?, ?> dataMap = SystemMapper.jsonMapper()
|
||||
@@ -1785,7 +1785,7 @@ class AccountsTest {
|
||||
|
||||
final GetItemResponse response = DYNAMO_DB_EXTENSION.getDynamoDbAsyncClient().getItem(GetItemRequest.builder()
|
||||
.tableName(Tables.ACCOUNTS.tableName())
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.build()).join();
|
||||
|
||||
final Map<?, ?> accountData = SystemMapper.jsonMapper()
|
||||
@@ -1800,7 +1800,7 @@ class AccountsTest {
|
||||
|
||||
DYNAMO_DB_EXTENSION.getDynamoDbAsyncClient().updateItem(UpdateItemRequest.builder()
|
||||
.tableName(Tables.ACCOUNTS.tableName())
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid())))
|
||||
.key(Map.of(Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier())))
|
||||
.updateExpression("SET #data = :data")
|
||||
.expressionAttributeNames(Map.of("#data", Accounts.ATTR_ACCOUNT_DATA))
|
||||
.expressionAttributeValues(
|
||||
@@ -1808,7 +1808,7 @@ class AccountsTest {
|
||||
.build()).join();
|
||||
|
||||
final CompletionException e = assertThrows(CompletionException.class,
|
||||
() -> accounts.getByAccountIdentifierAsync(account.getUuid()).join());
|
||||
() -> accounts.getByAccountIdentifierAsync(account.getAccountIdentifier()).join());
|
||||
|
||||
Throwable cause = e.getCause();
|
||||
while (cause.getCause() != null) {
|
||||
@@ -1944,7 +1944,7 @@ class AccountsTest {
|
||||
}
|
||||
|
||||
final Map<String, AttributeValue> item = new HashMap<>(Map.of(
|
||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getUuid()),
|
||||
Accounts.KEY_ACCOUNT_UUID, AttributeValues.fromUUID(account.getAccountIdentifier()),
|
||||
Accounts.ATTR_ACCOUNT_E164, AttributeValues.fromString(account.getNumber()),
|
||||
Accounts.ATTR_PNI_UUID, AttributeValues.fromUUID(account.getPhoneNumberIdentifier()),
|
||||
Accounts.ATTR_ACCOUNT_DATA, accountData,
|
||||
@@ -2125,7 +2125,7 @@ class AccountsTest {
|
||||
assertThat(result.getNumber()).isEqualTo(number);
|
||||
assertThat(result.getPhoneNumberIdentifier()).isEqualTo(pni);
|
||||
assertThat(result.getLastSeen()).isEqualTo(expecting.getLastSeen());
|
||||
assertThat(result.getUuid()).isEqualTo(uuid);
|
||||
assertThat(result.getAccountIdentifier()).isEqualTo(uuid);
|
||||
assertThat(result.getVersion()).isEqualTo(expecting.getVersion());
|
||||
assertArrayEquals(result.getUsernameHash().orElse(null), usernameHash);
|
||||
assertArrayEquals(expecting.getUnidentifiedAccessKey().orElseThrow(), result.getUnidentifiedAccessKey().orElseThrow());
|
||||
|
||||
+27
-27
@@ -179,7 +179,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final Pair<Account, Device> updatedAccountAndDevice =
|
||||
accountsManager.addDevice(account.getIdentifier(IdentityType.ACI), new DeviceSpec(
|
||||
@@ -201,17 +201,17 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
assertEquals(2, updatedAccountAndDevice.first().getDevices().size());
|
||||
|
||||
assertEquals(2,
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getUuid()).orElseThrow().getDevices()
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getAccountIdentifier()).orElseThrow().getDevices()
|
||||
.size());
|
||||
|
||||
final byte addedDeviceId = updatedAccountAndDevice.second().getId();
|
||||
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(updatedAccountAndDevice.first().getUuid(), addedDeviceId).join().isPresent());
|
||||
keysManager.getEcSignedPreKey(updatedAccountAndDevice.first().getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(updatedAccountAndDevice.first().getPhoneNumberIdentifier(), addedDeviceId).join()
|
||||
.isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccountAndDevice.first().getUuid(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccountAndDevice.first().getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(updatedAccountAndDevice.first().getPhoneNumberIdentifier(), addedDeviceId).join()
|
||||
.isPresent());
|
||||
@@ -227,7 +227,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final String linkDeviceToken = accountsManager.generateLinkDeviceToken(account.getIdentifier(IdentityType.ACI));
|
||||
|
||||
@@ -249,7 +249,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
linkDeviceToken);
|
||||
|
||||
assertEquals(2,
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getUuid()).orElseThrow().getDevices()
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getAccountIdentifier()).orElseThrow().getDevices()
|
||||
.size());
|
||||
|
||||
assertThrows(LinkDeviceTokenAlreadyUsedException.class,
|
||||
@@ -270,7 +270,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
linkDeviceToken));
|
||||
|
||||
assertEquals(2,
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getUuid()).orElseThrow().getDevices()
|
||||
accountsManager.getByAccountIdentifier(updatedAccountAndDevice.first().getAccountIdentifier()).orElseThrow().getDevices()
|
||||
.size());
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final Pair<Account, Device> updatedAccountAndDevice =
|
||||
accountsManager.addDevice(account.getIdentifier(IdentityType.ACI), new DeviceSpec(
|
||||
@@ -309,16 +309,16 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
|
||||
assertEquals(1, updatedAccount.getDevices().size());
|
||||
|
||||
assertFalse(keysManager.getEcSignedPreKey(updatedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(updatedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertFalse(
|
||||
keysManager.getEcSignedPreKey(updatedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(updatedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(updatedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertFalse(keysManager.getLastResort(updatedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
|
||||
assertTrue(keysManager.getEcSignedPreKey(updatedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(updatedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(updatedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(updatedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(updatedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final ECKeyPair pniKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = AccountsHelper.createAccount(accountsManager, number);
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getUuid()).orElseThrow().getDevices().size());
|
||||
assertEquals(1, accountsManager.getByAccountIdentifier(account.getAccountIdentifier()).orElseThrow().getDevices().size());
|
||||
|
||||
final UUID aci = account.getIdentifier(IdentityType.ACI);
|
||||
|
||||
@@ -366,17 +366,17 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
|
||||
assertEquals(2, retrievedAccount.getDevices().size());
|
||||
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getEcSignedPreKey(retrievedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getUuid(), addedDeviceId).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getAccountIdentifier(), addedDeviceId).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(retrievedAccount.getPhoneNumberIdentifier(), addedDeviceId).join().isPresent());
|
||||
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getEcSignedPreKey(retrievedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join()
|
||||
.isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(keysManager.getLastResort(retrievedAccount.getAccountIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
assertTrue(
|
||||
keysManager.getLastResort(retrievedAccount.getPhoneNumberIdentifier(), Device.PRIMARY_ID).join().isPresent());
|
||||
}
|
||||
@@ -396,13 +396,13 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final String linkDeviceTokenIdentifier = AccountsManager.getLinkDeviceTokenIdentifier(linkDeviceToken);
|
||||
|
||||
final CompletableFuture<Optional<DeviceInfo>> displacedFuture = accountsManager.waitForNewLinkedDevice(
|
||||
account.getUuid(), account.getPrimaryDevice(),
|
||||
account.getAccountIdentifier(), account.getPrimaryDevice(),
|
||||
linkDeviceTokenIdentifier, Duration.ofSeconds(5));
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.empty()));
|
||||
final CompletableFuture<Optional<DeviceInfo>> activeFuture =
|
||||
accountsManager.waitForNewLinkedDevice(account.getUuid(), account.getPrimaryDevice(), linkDeviceTokenIdentifier,
|
||||
accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(), account.getPrimaryDevice(), linkDeviceTokenIdentifier,
|
||||
Duration.ofSeconds(5));
|
||||
|
||||
assertEquals(Optional.empty(), displacedFuture.join());
|
||||
@@ -465,11 +465,11 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
KeysHelper.signedKEMPreKey(4, pniKeyPair)),
|
||||
linkDeviceToken);
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.empty()));
|
||||
|
||||
final CompletableFuture<Optional<DeviceInfo>> linkedDeviceFuture = accountsManager.waitForNewLinkedDevice(
|
||||
account.getUuid(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMinutes(1));
|
||||
account.getAccountIdentifier(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMinutes(1));
|
||||
|
||||
final Optional<DeviceInfo> maybeDeviceInfo = linkedDeviceFuture.join();
|
||||
|
||||
@@ -492,7 +492,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
final String linkDeviceTokenIdentifier = AccountsManager.getLinkDeviceTokenIdentifier(linkDeviceToken);
|
||||
|
||||
final CompletableFuture<Optional<DeviceInfo>> linkedDeviceFuture = accountsManager.waitForNewLinkedDevice(
|
||||
account.getUuid(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMillis(1));
|
||||
account.getAccountIdentifier(), account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofMillis(1));
|
||||
|
||||
final Optional<DeviceInfo> maybeDeviceInfo = linkedDeviceFuture.join();
|
||||
|
||||
@@ -534,12 +534,12 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
KeysHelper.signedKEMPreKey(4, pniKeyPair)),
|
||||
linkDeviceToken);
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.ofNullable(oldestMessage).map(Instant::ofEpochMilli)));
|
||||
|
||||
clock.pin(Instant.ofEpochMilli(currentTime));
|
||||
Duration timeout = shouldWait ? Duration.ofMillis(5) : Duration.ofMillis(1000);
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getUuid(),
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(),
|
||||
account.getPrimaryDevice(), linkDeviceTokenIdentifier, timeout).join();
|
||||
assertEquals(result.isEmpty(), shouldWait);
|
||||
}
|
||||
@@ -577,7 +577,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
KeysHelper.signedKEMPreKey(4, pniKeyPair)),
|
||||
linkDeviceToken);
|
||||
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getUuid(), account.getPrimaryDevice()))
|
||||
when(messagesManager.getEarliestUndeliveredTimestampForDevice(account.getAccountIdentifier(), account.getPrimaryDevice()))
|
||||
// Has a message older than the message epoch
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(Instant.ofEpochMilli(1000))))
|
||||
// The message was fetched
|
||||
@@ -588,7 +588,7 @@ public class AddRemoveDeviceIntegrationTest {
|
||||
x.getArgument(0, Runnable.class).run();
|
||||
return null;
|
||||
});
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getUuid(),
|
||||
Optional<DeviceInfo> result = accountsManager.waitForNewLinkedDevice(account.getAccountIdentifier(),
|
||||
account.getPrimaryDevice(), linkDeviceTokenIdentifier, Duration.ofSeconds(10)).join();
|
||||
assertTrue(result.isPresent());
|
||||
}
|
||||
|
||||
+6
-6
@@ -127,7 +127,7 @@ class MessagePersisterIntegrationTest {
|
||||
final UUID accountUuid = UUID.randomUUID();
|
||||
|
||||
when(account.getNumber()).thenReturn("+18005551234");
|
||||
when(account.getUuid()).thenReturn(accountUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountUuid);
|
||||
when(accountsManager.getByAccountIdentifier(accountUuid)).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifierAsync(accountUuid)).thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(DevicesHelper.createDevice(Device.PRIMARY_ID)));
|
||||
@@ -166,13 +166,13 @@ class MessagePersisterIntegrationTest {
|
||||
|
||||
final MessageProtos.Envelope message = generateRandomMessage(messageGuid, timestamp, false);
|
||||
|
||||
messagesCache.insert(messageGuid, account.getUuid(), Device.PRIMARY_ID, message).join();
|
||||
messagesCache.insert(messageGuid, account.getAccountIdentifier(), Device.PRIMARY_ID, message).join();
|
||||
expectedMessages.add(message);
|
||||
}
|
||||
|
||||
final CountDownLatch messagesPersistedLatch = new CountDownLatch(1);
|
||||
|
||||
redisMessageAvailabilityManager.handleClientConnected(account.getUuid(), Device.PRIMARY_ID,
|
||||
redisMessageAvailabilityManager.handleClientConnected(account.getAccountIdentifier(), Device.PRIMARY_ID,
|
||||
new MessageAvailabilityListener() {
|
||||
@Override
|
||||
public void handleNewMessageAvailable() {
|
||||
@@ -226,7 +226,7 @@ class MessagePersisterIntegrationTest {
|
||||
|
||||
final MessageProtos.Envelope message = generateRandomMessage(messageGuid, timestamp, true);
|
||||
|
||||
messagesCache.insert(messageGuid, account.getUuid(), Device.PRIMARY_ID, message).join();
|
||||
messagesCache.insert(messageGuid, account.getAccountIdentifier(), Device.PRIMARY_ID, message).join();
|
||||
}
|
||||
|
||||
final List<MessageProtos.Envelope> expectedMessages = new ArrayList<>(persistableMessages);
|
||||
@@ -237,7 +237,7 @@ class MessagePersisterIntegrationTest {
|
||||
|
||||
final MessageProtos.Envelope message = generateRandomMessage(messageGuid, timestamp, false);
|
||||
|
||||
messagesCache.insert(messageGuid, account.getUuid(), Device.PRIMARY_ID, message).join();
|
||||
messagesCache.insert(messageGuid, account.getAccountIdentifier(), Device.PRIMARY_ID, message).join();
|
||||
expectedMessages.add(message);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ class MessagePersisterIntegrationTest {
|
||||
.toList();
|
||||
|
||||
assertEquals(expectedMessages, persistedMessages);
|
||||
assertFalse(messagesCache.hasMessagesAsync(account.getUuid(), Device.PRIMARY_ID).join());
|
||||
assertFalse(messagesCache.hasMessagesAsync(account.getAccountIdentifier(), Device.PRIMARY_ID).join());
|
||||
}
|
||||
|
||||
private MessageProtos.Envelope generateRandomMessage(final UUID messageGuid, final long serverTimestamp, final boolean ephemeral) {
|
||||
|
||||
+2
-2
@@ -118,7 +118,7 @@ class MessagePersisterTest {
|
||||
when(accountsManager.removeDevice(any(), anyByte()))
|
||||
.thenAnswer(invocation -> accountsManager.getByAccountIdentifier(invocation.getArgument(0)).orElseThrow());
|
||||
|
||||
when(destinationAccount.getUuid()).thenReturn(DESTINATION_ACCOUNT_UUID);
|
||||
when(destinationAccount.getAccountIdentifier()).thenReturn(DESTINATION_ACCOUNT_UUID);
|
||||
when(destinationAccount.getIdentifier(IdentityType.ACI)).thenReturn(DESTINATION_ACCOUNT_UUID);
|
||||
when(destinationAccount.getNumber()).thenReturn(DESTINATION_ACCOUNT_NUMBER);
|
||||
when(destinationAccount.getDevice(DESTINATION_DEVICE_ID)).thenReturn(Optional.of(DESTINATION_DEVICE));
|
||||
@@ -249,7 +249,7 @@ class MessagePersisterTest {
|
||||
when(accountsManager.getByAccountIdentifierAsync(accountUuid))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(account)));
|
||||
|
||||
when(account.getUuid()).thenReturn(accountUuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(accountUuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(accountUuid);
|
||||
when(account.getDevice(anyByte())).thenAnswer(invocation -> Optional.of(DevicesHelper.createDevice(invocation.getArgument(0))));
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class ReportMessageManagerTest {
|
||||
reporterUuid = UUID.randomUUID();
|
||||
|
||||
sourceAccount = mock(Account.class);
|
||||
when(sourceAccount.getUuid()).thenReturn(sourceAci);
|
||||
when(sourceAccount.getAccountIdentifier()).thenReturn(sourceAci);
|
||||
when(sourceAccount.getNumber()).thenReturn(sourceNumber);
|
||||
when(sourceAccount.getPhoneNumberIdentifier()).thenReturn(sourcePni);
|
||||
}
|
||||
|
||||
+6
-6
@@ -54,7 +54,7 @@ class AppleDeviceCheckManagerTest {
|
||||
void setupDeviceChecks() {
|
||||
clock.pin(Instant.now());
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
|
||||
final DeviceCheckManager deviceCheckManager = DeviceCheckTestUtil.appleDeviceCheckManager();
|
||||
appleDeviceChecks = new AppleDeviceChecks(DYNAMO_DB_EXTENSION.getDynamoDbClient(),
|
||||
@@ -112,7 +112,7 @@ class AppleDeviceCheckManagerTest {
|
||||
public void duplicateKeys() {
|
||||
assertThatNoException().isThrownBy(() -> registerAttestation(account));
|
||||
final Account duplicator = mock(Account.class);
|
||||
when(duplicator.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(duplicator.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
// Both accounts use the attestation keyId, the second registration should fail
|
||||
assertThatExceptionOfType(DuplicatePublicKeyException.class)
|
||||
@@ -124,7 +124,7 @@ class AppleDeviceCheckManagerTest {
|
||||
final String challenge =
|
||||
appleDeviceCheckManager.createChallenge(AppleDeviceCheckManager.ChallengeType.ATTEST, account);
|
||||
final String redisKey = AppleDeviceCheckManager.challengeKey(AppleDeviceCheckManager.ChallengeType.ATTEST,
|
||||
account.getUuid());
|
||||
account.getAccountIdentifier());
|
||||
|
||||
final String storedChallenge = CLUSTER_EXTENSION.getRedisCluster()
|
||||
.withCluster(cluster -> cluster.sync().get(redisKey));
|
||||
@@ -165,7 +165,7 @@ class AppleDeviceCheckManagerTest {
|
||||
// Rig redis to return our sample challenge for the assert
|
||||
final String assertChallengeKey = AppleDeviceCheckManager.challengeKey(
|
||||
AppleDeviceCheckManager.ChallengeType.ASSERT_BACKUP_REDEMPTION,
|
||||
account.getUuid());
|
||||
account.getAccountIdentifier());
|
||||
CLUSTER_EXTENSION.getRedisCluster().useCluster(cluster ->
|
||||
cluster.sync().set(assertChallengeKey, DeviceCheckTestUtil.SAMPLE_CHALLENGE));
|
||||
|
||||
@@ -196,7 +196,7 @@ class AppleDeviceCheckManagerTest {
|
||||
CLUSTER_EXTENSION.getRedisCluster().useCluster(cluster -> cluster.sync().set(
|
||||
AppleDeviceCheckManager.challengeKey(
|
||||
AppleDeviceCheckManager.ChallengeType.ASSERT_BACKUP_REDEMPTION,
|
||||
account.getUuid()),
|
||||
account.getAccountIdentifier()),
|
||||
DeviceCheckTestUtil.SAMPLE_CHALLENGE));
|
||||
|
||||
assertThatExceptionOfType(RequestReuseException.class).isThrownBy(() ->
|
||||
@@ -217,7 +217,7 @@ class AppleDeviceCheckManagerTest {
|
||||
throws DeviceCheckVerificationFailedException, ChallengeNotFoundException, TooManyKeysException, DuplicatePublicKeyException {
|
||||
final String attestChallengeKey = AppleDeviceCheckManager.challengeKey(
|
||||
AppleDeviceCheckManager.ChallengeType.ATTEST,
|
||||
account.getUuid());
|
||||
account.getAccountIdentifier());
|
||||
CLUSTER_EXTENSION.getRedisCluster().useCluster(cluster ->
|
||||
cluster.sync().set(attestChallengeKey, DeviceCheckTestUtil.SAMPLE_CHALLENGE));
|
||||
try (MockedStatic<Instant> mocked = mockStatic(Instant.class, Mockito.CALLS_REAL_METHODS)) {
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ class AppleDeviceChecksTest {
|
||||
@BeforeEach
|
||||
void setupDeviceChecks() {
|
||||
account = mock(Account.class);
|
||||
when(account.getUuid()).thenReturn(ACI);
|
||||
when(account.getAccountIdentifier()).thenReturn(ACI);
|
||||
deviceChecks = new AppleDeviceChecks(DYNAMO_DB_EXTENSION.getDynamoDbClient(),
|
||||
DeviceCheckManager.createObjectConverter(),
|
||||
DynamoDbExtensionSchema.Tables.APPLE_DEVICE_CHECKS.tableName(),
|
||||
@@ -78,7 +78,7 @@ class AppleDeviceChecksTest {
|
||||
final byte[] keyId = appleDevice.getAttestedCredentialData().getCredentialId();
|
||||
|
||||
final Account dupliateAccount = mock(Account.class);
|
||||
when(dupliateAccount.getUuid()).thenReturn(UUID.randomUUID());
|
||||
when(dupliateAccount.getAccountIdentifier()).thenReturn(UUID.randomUUID());
|
||||
|
||||
deviceChecks.storeAttestation(account, keyId, appleDevice);
|
||||
|
||||
|
||||
+4
-4
@@ -47,7 +47,7 @@ public class AccountsHelper {
|
||||
public static Account generateTestAccount(String number, UUID uuid, final UUID phoneNumberIdentifier, List<Device> devices, byte[] unidentifiedAccessKey) {
|
||||
final Account account = new Account();
|
||||
account.setNumber(number, phoneNumberIdentifier);
|
||||
account.setUuid(uuid);
|
||||
account.setAccountIdentifier(uuid);
|
||||
devices.forEach(account::addDevice);
|
||||
account.setUnidentifiedAccessKey(unidentifiedAccessKey);
|
||||
|
||||
@@ -160,9 +160,9 @@ public class AccountsHelper {
|
||||
}
|
||||
|
||||
public static void setupMockGet(final AccountsManager mockAccountsManager, final Account account) {
|
||||
if (account.getUuid() != null || account.getIdentifier(IdentityType.ACI) != null) {
|
||||
if (account.getAccountIdentifier() != null || account.getIdentifier(IdentityType.ACI) != null) {
|
||||
final UUID accountIdentifier =
|
||||
Objects.requireNonNullElseGet(account.getIdentifier(IdentityType.ACI), account::getUuid);
|
||||
Objects.requireNonNullElseGet(account.getIdentifier(IdentityType.ACI), account::getAccountIdentifier);
|
||||
|
||||
when(mockAccountsManager.getByAccountIdentifier(accountIdentifier))
|
||||
.thenReturn(Optional.of(account));
|
||||
@@ -219,7 +219,7 @@ public class AccountsHelper {
|
||||
|
||||
for (Stubbing stubbing : mockingDetails.getStubbings()) {
|
||||
switch (stubbing.getInvocation().getMethod().getName()) {
|
||||
case "getUuid" -> when(updatedAccount.getUuid()).thenAnswer(stubbing);
|
||||
case "getAccountIdentifier" -> when(updatedAccount.getAccountIdentifier()).thenAnswer(stubbing);
|
||||
case "getPhoneNumberIdentifier" -> when(updatedAccount.getPhoneNumberIdentifier()).thenAnswer(stubbing);
|
||||
case "getIdentifier" -> when(updatedAccount.getIdentifier(stubbing.getInvocation().getArgument(0))).thenAnswer(stubbing);
|
||||
case "isIdentifiedBy" -> when(updatedAccount.isIdentifiedBy(stubbing.getInvocation().getArgument(0))).thenAnswer(stubbing);
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public class AccountsTestHelper {
|
||||
final ECKeyPair pniIdentityKeyPair = ECKeyPair.generate();
|
||||
|
||||
final Account account = new Account();
|
||||
account.setUuid(aci);
|
||||
account.setAccountIdentifier(aci);
|
||||
account.setNumber(number, UUID.randomUUID());
|
||||
account.setUnrestrictedUnidentifiedAccess(unrestrictedUnidentifiedAccess);
|
||||
account.setDiscoverableByPhoneNumber(discoverableByPhoneNumber);
|
||||
|
||||
@@ -158,22 +158,22 @@ public class AuthHelper {
|
||||
when(VALID_ACCOUNT_3.getDevices()).thenReturn(List.of(VALID_DEVICE_3_PRIMARY, VALID_DEVICE_3_LINKED));
|
||||
|
||||
when(VALID_ACCOUNT.getNumber()).thenReturn(VALID_NUMBER);
|
||||
when(VALID_ACCOUNT.getUuid()).thenReturn(VALID_UUID);
|
||||
when(VALID_ACCOUNT.getAccountIdentifier()).thenReturn(VALID_UUID);
|
||||
when(VALID_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(VALID_PNI);
|
||||
when(VALID_ACCOUNT.getIdentifier(IdentityType.ACI)).thenReturn(VALID_UUID);
|
||||
when(VALID_ACCOUNT.getIdentifier(IdentityType.PNI)).thenReturn(VALID_PNI);
|
||||
when(VALID_ACCOUNT_TWO.getNumber()).thenReturn(VALID_NUMBER_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getUuid()).thenReturn(VALID_UUID_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getAccountIdentifier()).thenReturn(VALID_UUID_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getPhoneNumberIdentifier()).thenReturn(VALID_PNI_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getIdentifier(IdentityType.ACI)).thenReturn(VALID_UUID_TWO);
|
||||
when(VALID_ACCOUNT_TWO.getIdentifier(IdentityType.PNI)).thenReturn(VALID_PNI_TWO);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getNumber()).thenReturn(UNDISCOVERABLE_NUMBER);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getUuid()).thenReturn(UNDISCOVERABLE_UUID);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getAccountIdentifier()).thenReturn(UNDISCOVERABLE_UUID);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getPhoneNumberIdentifier()).thenReturn(UNDISCOVERABLE_PNI);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getIdentifier(IdentityType.ACI)).thenReturn(UNDISCOVERABLE_UUID);
|
||||
when(UNDISCOVERABLE_ACCOUNT.getIdentifier(IdentityType.PNI)).thenReturn(UNDISCOVERABLE_PNI);
|
||||
when(VALID_ACCOUNT_3.getNumber()).thenReturn(VALID_NUMBER_3);
|
||||
when(VALID_ACCOUNT_3.getUuid()).thenReturn(VALID_UUID_3);
|
||||
when(VALID_ACCOUNT_3.getAccountIdentifier()).thenReturn(VALID_UUID_3);
|
||||
when(VALID_ACCOUNT_3.getPhoneNumberIdentifier()).thenReturn(VALID_PNI_3);
|
||||
when(VALID_ACCOUNT_3.getIdentifier(IdentityType.ACI)).thenReturn(VALID_UUID_3);
|
||||
when(VALID_ACCOUNT_3.getIdentifier(IdentityType.PNI)).thenReturn(VALID_PNI_3);
|
||||
@@ -276,7 +276,7 @@ public class AuthHelper {
|
||||
when(account.getDevice(Device.PRIMARY_ID)).thenReturn(Optional.of(device));
|
||||
when(account.getPrimaryDevice()).thenReturn(device);
|
||||
when(account.getNumber()).thenReturn(number);
|
||||
when(account.getUuid()).thenReturn(uuid);
|
||||
when(account.getAccountIdentifier()).thenReturn(uuid);
|
||||
when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid);
|
||||
when(accountsManager.getByE164(number)).thenReturn(Optional.of(account));
|
||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||
|
||||
Reference in new issue
Block a user