diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java b/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java index 26a45ee60..71fb66beb 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticator.java @@ -10,7 +10,6 @@ import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name; import com.google.common.annotations.VisibleForTesting; import io.dropwizard.auth.Authenticator; import io.dropwizard.auth.basic.BasicCredentials; -import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.Metrics; import io.micrometer.core.instrument.Tags; import java.time.Clock; @@ -36,9 +35,6 @@ public class AccountAuthenticator implements Authenticator implemen }); } - public Account updateDeviceAuthentication(final Account account, final Device device, final SaltedTokenHash credentials) { - Preconditions.checkArgument(credentials.getVersion() == SaltedTokenHash.CURRENT_VERSION); - return updateDevice(account, device.getId(), device1 -> device1.setAuthTokenHash(credentials)); - } - /** * @param account account to update * @param updater must return {@code true} if the account was actually updated diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticatorTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticatorTest.java index 4ee52b251..9f9866b61 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticatorTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/auth/AccountAuthenticatorTest.java @@ -175,7 +175,6 @@ class AccountAuthenticatorTest { assertThat(maybeAuthenticatedAccount).isPresent(); assertThat(maybeAuthenticatedAccount.orElseThrow().accountIdentifier()).isEqualTo(uuid); assertThat(maybeAuthenticatedAccount.orElseThrow().deviceId()).isEqualTo(device.getId()); - verify(accountsManager, never()).updateDeviceAuthentication(any(), any(), any()); } @Test @@ -205,7 +204,6 @@ class AccountAuthenticatorTest { assertThat(maybeAuthenticatedAccount).isPresent(); assertThat(maybeAuthenticatedAccount.orElseThrow().accountIdentifier()).isEqualTo(uuid); assertThat(maybeAuthenticatedAccount.orElseThrow().deviceId()).isEqualTo(device.getId()); - verify(accountsManager, never()).updateDeviceAuthentication(any(), any(), any()); } @CartesianTest @@ -244,37 +242,6 @@ class AccountAuthenticatorTest { assertThat(maybeAuthenticatedAccount.orElseThrow().deviceId()).isEqualTo(authenticatedDevice.getId()); } - @Test - void testAuthenticateV1() { - final UUID uuid = UUID.randomUUID(); - final byte deviceId = 1; - final String password = "12345"; - - final Account account = mock(Account.class); - final Device device = mock(Device.class); - final SaltedTokenHash credentials = mock(SaltedTokenHash.class); - - clock.unpin(); - when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account)); - when(account.getUuid()).thenReturn(uuid); - when(account.getIdentifier(IdentityType.ACI)).thenReturn(uuid); - when(account.getDevice(deviceId)).thenReturn(Optional.of(device)); - when(account.getPrimaryDevice()).thenReturn(device); - when(device.getId()).thenReturn(deviceId); - when(device.getAuthTokenHash()).thenReturn(credentials); - when(credentials.verify(password)).thenReturn(true); - when(credentials.getVersion()).thenReturn(SaltedTokenHash.Version.V1); - - final Optional maybeAuthenticatedAccount = - accountAuthenticator.authenticate(new BasicCredentials(uuid.toString(), password)); - - assertThat(maybeAuthenticatedAccount).isPresent(); - assertThat(maybeAuthenticatedAccount.orElseThrow().accountIdentifier()).isEqualTo(uuid); - assertThat(maybeAuthenticatedAccount.orElseThrow().deviceId()).isEqualTo(device.getId()); - verify(accountsManager, times(1)).updateDeviceAuthentication( - any(), // this won't be 'account', because it'll already be updated by updateDeviceLastSeen - eq(device), any()); - } @Test void testAuthenticateAccountNotFound() { assertThat(accountAuthenticator.authenticate(new BasicCredentials(UUID.randomUUID().toString(), "password"))) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java index 68cae7e80..dbdc9b028 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java @@ -25,7 +25,6 @@ import org.mockito.MockingDetails; import org.mockito.stubbing.Stubbing; import org.signal.libsignal.protocol.IdentityKey; import org.signal.libsignal.protocol.ecc.ECKeyPair; -import org.whispersystems.textsecuregcm.auth.SaltedTokenHash; import org.whispersystems.textsecuregcm.entities.AccountAttributes; import org.whispersystems.textsecuregcm.storage.Account; import org.whispersystems.textsecuregcm.storage.AccountsManager; @@ -122,11 +121,6 @@ public class AccountsHelper { answer.getArgument(1, Device.class).setLastSeen(answer.getArgument(2, Long.class)); return mockAccountsManager.update(answer.getArgument(0, Account.class), account -> {}); }); - - when(mockAccountsManager.updateDeviceAuthentication(any(), any(), any())).thenAnswer(answer -> { - answer.getArgument(1, Device.class).setAuthTokenHash(answer.getArgument(2, SaltedTokenHash.class)); - return mockAccountsManager.update(answer.getArgument(0, Account.class), account -> {}); - }); } public static void setupMockGet(final AccountsManager mockAccountsManager, final Set mockAccounts) {