mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 14:48:07 +01:00
Make account deletion a blocking operation
This commit is contained in:
committed by
Jon Chambers
parent
405b04f07b
commit
ec2cb8581c
@@ -92,7 +92,6 @@ import org.whispersystems.textsecuregcm.storage.UsernameHashNotAvailableExceptio
|
||||
import org.whispersystems.textsecuregcm.storage.UsernameReservationNotFoundException;
|
||||
import org.whispersystems.textsecuregcm.tests.util.AccountsHelper;
|
||||
import org.whispersystems.textsecuregcm.tests.util.AuthHelper;
|
||||
import org.whispersystems.textsecuregcm.util.CompletableFutureTestUtil;
|
||||
import org.whispersystems.textsecuregcm.util.MockUtils;
|
||||
import org.whispersystems.textsecuregcm.util.SystemMapper;
|
||||
import org.whispersystems.textsecuregcm.util.TestRandomUtil;
|
||||
@@ -846,8 +845,6 @@ class AccountControllerTest {
|
||||
|
||||
@Test
|
||||
void testDeleteAccount() {
|
||||
when(accountsManager.delete(any(), any())).thenReturn(CompletableFutureTestUtil.almostCompletedFuture(null));
|
||||
|
||||
try (final Response response = resources.getJerseyTest()
|
||||
.target("/v1/accounts/me")
|
||||
.request()
|
||||
@@ -861,7 +858,8 @@ class AccountControllerTest {
|
||||
|
||||
@Test
|
||||
void testDeleteAccountException() {
|
||||
when(accountsManager.delete(any(), any())).thenReturn(CompletableFuture.failedFuture(new RuntimeException("OH NO")));
|
||||
doThrow(new RuntimeException("OH NO"))
|
||||
.when(accountsManager).delete(any(), any());
|
||||
|
||||
try (final Response response = resources.getJerseyTest()
|
||||
.target("/v1/accounts/me")
|
||||
|
||||
@@ -154,9 +154,6 @@ class AccountsGrpcServiceTest extends SimpleBaseGrpcTest<AccountsGrpcService, Ac
|
||||
when(accountsManager.getByAccountIdentifier(AUTHENTICATED_ACI))
|
||||
.thenReturn(Optional.of(account));
|
||||
|
||||
when(accountsManager.delete(any(), any()))
|
||||
.thenReturn(CompletableFuture.completedFuture(null));
|
||||
|
||||
final DeleteAccountResponse ignored =
|
||||
authenticatedServiceStub().deleteAccount(DeleteAccountRequest.newBuilder().build());
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ public class AccountCreationDeletionIntegrationTest {
|
||||
|
||||
assertTrue(accountsManager.getByAccountIdentifier(aci).isPresent());
|
||||
|
||||
accountsManager.delete(account, AccountsManager.DeletionReason.ADMIN_DELETED).join();
|
||||
accountsManager.delete(account, AccountsManager.DeletionReason.ADMIN_DELETED);
|
||||
|
||||
assertFalse(accountsManager.getByAccountIdentifier(aci).isPresent());
|
||||
assertFalse(keysManager.getEcSignedPreKey(account.getUuid(), Device.PRIMARY_ID).join().isPresent());
|
||||
|
||||
@@ -160,8 +160,6 @@ class AccountsManagerTest {
|
||||
when(asyncClusterCommands.set(any(), any(), any())).thenReturn(MockRedisFuture.completedFuture("OK"));
|
||||
when(asyncClusterCommands.setex(any(), anyLong(), any())).thenReturn(MockRedisFuture.completedFuture("OK"));
|
||||
|
||||
when(accounts.delete(any(), any())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
|
||||
doAnswer((Answer<Void>) invocation -> {
|
||||
final Account account = invocation.getArgument(0, Account.class);
|
||||
final String number = invocation.getArgument(1, String.class);
|
||||
|
||||
@@ -214,7 +214,7 @@ class AccountsTest {
|
||||
assertPhoneNumberConstraintExists("+14151112222", account.getUuid());
|
||||
assertPhoneNumberIdentifierConstraintExists(account.getPhoneNumberIdentifier(), account.getUuid());
|
||||
|
||||
accounts.delete(originalUuid, Collections.emptyList()).join();
|
||||
accounts.delete(originalUuid, Collections.emptyList());
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(account.getPhoneNumberIdentifier())).hasValue(originalUuid);
|
||||
|
||||
freshUser = createAccount(account);
|
||||
@@ -773,7 +773,7 @@ class AccountsTest {
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isPresent();
|
||||
assertThat(accounts.getByAccountIdentifier(retainedAccount.getUuid())).isPresent();
|
||||
|
||||
accounts.delete(deletedAccount.getUuid(), Collections.emptyList()).join();
|
||||
accounts.delete(deletedAccount.getUuid(), Collections.emptyList());
|
||||
|
||||
assertThat(accounts.getByAccountIdentifier(deletedAccount.getUuid())).isNotPresent();
|
||||
assertThat(accounts.findRecentlyDeletedAccountIdentifier(deletedAccount.getPhoneNumberIdentifier())).hasValue(deletedAccount.getUuid());
|
||||
@@ -1813,7 +1813,7 @@ class AccountsTest {
|
||||
.build())
|
||||
.items());
|
||||
|
||||
accounts.delete(account.getIdentifier(IdentityType.ACI), Collections.emptyList()).join();
|
||||
accounts.delete(account.getIdentifier(IdentityType.ACI), Collections.emptyList());
|
||||
|
||||
writeAccountRecordWithoutConstraints(account);
|
||||
accounts.regenerateConstraints(account).join();
|
||||
|
||||
@@ -16,7 +16,6 @@ import static org.mockito.Mockito.when;
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Stream;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
@@ -61,7 +60,6 @@ class RemoveExpiredAccountsCommandTest {
|
||||
final Clock clock = Clock.fixed(Instant.now(), ZoneId.systemDefault());
|
||||
|
||||
final AccountsManager accountsManager = mock(AccountsManager.class);
|
||||
when(accountsManager.delete(any(), any())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
|
||||
final RemoveExpiredAccountsCommand removeExpiredAccountsCommand =
|
||||
new TestRemoveExpiredAccountsCommand(clock, accountsManager, isDryRun);
|
||||
|
||||
Reference in New Issue
Block a user