@@ -22,7 +22,6 @@
2222import com.fasterxml.uuid.UUIDComparator;
2323import java.nio.charset.StandardCharsets;
2424import java.security.SecureRandom;
25-import java.time.Clock;
2625import java.time.Duration;
2726import java.time.Instant;
2827import java.util.ArrayList;
@@ -35,14 +34,12 @@
3534import java.util.UUID;
3635import java.util.concurrent.CompletableFuture;
3736import java.util.concurrent.CompletionException;
38-import java.util.concurrent.Executor;
3937import java.util.concurrent.atomic.AtomicInteger;
4038import java.util.function.BiConsumer;
4139import java.util.stream.Collectors;
4240import java.util.stream.Stream;
4341import org.apache.commons.lang3.RandomUtils;
4442import org.junit.jupiter.api.BeforeEach;
45-import org.junit.jupiter.api.Disabled;
4643import org.junit.jupiter.api.Test;
4744import org.junit.jupiter.api.Timeout;
4845import org.junit.jupiter.api.extension.RegisterExtension;
@@ -51,12 +48,7 @@
5148import org.junit.jupiter.params.provider.MethodSource;
5249import org.junit.jupiter.params.provider.ValueSource;
5350import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
54-import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager;
5551import org.whispersystems.textsecuregcm.identity.IdentityType;
56-import org.whispersystems.textsecuregcm.push.ClientPresenceManager;
57-import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
58-import org.whispersystems.textsecuregcm.securestorage.SecureStorageClient;
59-import org.whispersystems.textsecuregcm.securevaluerecovery.SecureValueRecovery2Client;
6052import org.whispersystems.textsecuregcm.storage.DynamoDbExtensionSchema.Tables;
6153import org.whispersystems.textsecuregcm.tests.util.AccountsHelper;
6254import org.whispersystems.textsecuregcm.tests.util.DevicesHelper;
@@ -131,7 +123,7 @@ void setupAccountsDao() {
131123 }
132124133125@Test
134-public void testStoreAndLookupUsernameLink() throws Exception {
126+public void testStoreAndLookupUsernameLink() {
135127final Account account = nextRandomAccount();
136128account.setUsernameHash(RandomUtils.nextBytes(16));
137129accounts.create(account);
@@ -165,54 +157,6 @@ public void testStoreAndLookupUsernameLink() throws Exception {
165157assertTrue(accounts.getByUsernameLinkHandle(linkHandle2).join().isEmpty());
166158 }
167159168-@Test
169-@Disabled
170-// TODO: @Sergey: what's the story with this test?
171-public void testUsernameLinksViaAccountsManager() {
172-final AccountsManager accountsManager = new AccountsManager(
173-accounts,
174-mock(PhoneNumberIdentifiers.class),
175-mock(FaultTolerantRedisCluster.class),
176-mock(AccountLockManager.class),
177-mock(KeysManager.class),
178-mock(MessagesManager.class),
179-mock(ProfilesManager.class),
180-mock(SecureStorageClient.class),
181-mock(SecureValueRecovery2Client.class),
182-mock(ClientPresenceManager.class),
183-mock(ExperimentEnrollmentManager.class),
184-mock(RegistrationRecoveryPasswordsManager.class),
185-mock(Executor.class),
186-mock(Clock.class));
187-188-final Account account = nextRandomAccount();
189-account.setUsernameHash(RandomUtils.nextBytes(16));
190-accounts.create(account);
191-192-final UUID linkHandle = UUID.randomUUID();
193-final byte[] encryptedUsername = RandomUtils.nextBytes(32);
194-accountsManager.update(account, a -> a.setUsernameLinkDetails(linkHandle, encryptedUsername));
195-196-final Optional<Account> maybeAccount = accountsManager.getByUsernameLinkHandle(linkHandle).join();
197-assertTrue(maybeAccount.isPresent());
198-assertTrue(maybeAccount.get().getEncryptedUsername().isPresent());
199-assertArrayEquals(encryptedUsername, maybeAccount.get().getEncryptedUsername().get());
200-201-// making some unrelated change and updating account to check that username link data is still there
202-final Optional<Account> accountToChange = accountsManager.getByAccountIdentifier(account.getUuid());
203-assertTrue(accountToChange.isPresent());
204-accountsManager.update(accountToChange.get(), a -> a.setDiscoverableByPhoneNumber(!a.isDiscoverableByPhoneNumber()));
205-final Optional<Account> accountAfterChange = accountsManager.getByUsernameLinkHandle(linkHandle).join();
206-assertTrue(accountAfterChange.isPresent());
207-assertTrue(accountAfterChange.get().getEncryptedUsername().isPresent());
208-assertArrayEquals(encryptedUsername, accountAfterChange.get().getEncryptedUsername().get());
209-210-// now deleting the link
211-final Optional<Account> accountToDeleteLink = accountsManager.getByAccountIdentifier(account.getUuid());
212-accountsManager.update(accountToDeleteLink.get(), a -> a.setUsernameLinkDetails(null, null));
213-assertTrue(accounts.getByUsernameLinkHandle(linkHandle).join().isEmpty());
214- }
215-216160@Test
217161void testStore() {
218162Device device = generateDevice(1);