Retire the legacy disconnection request system

This commit is contained in:
Jon Chambers
2024-11-11 11:36:07 -05:00
committed by Jon Chambers
parent d6f890c7b9
commit 3fefb24d71
18 changed files with 20 additions and 136 deletions

View File

@@ -59,7 +59,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;
import org.whispersystems.textsecuregcm.filters.RemoteAddressFilter;
import org.whispersystems.textsecuregcm.push.WebSocketConnectionEventManager;
import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.AccountsManager;
import org.whispersystems.textsecuregcm.storage.Device;
@@ -96,7 +95,6 @@ class LinkedDeviceRefreshRequirementProviderTest {
private AccountsManager accountsManager;
private DisconnectionRequestManager disconnectionRequestManager;
private WebSocketConnectionEventManager webSocketConnectionEventManager;
private LinkedDeviceRefreshRequirementProvider provider;
@@ -104,12 +102,11 @@ class LinkedDeviceRefreshRequirementProviderTest {
void setup() {
accountsManager = mock(AccountsManager.class);
disconnectionRequestManager = mock(DisconnectionRequestManager.class);
webSocketConnectionEventManager = mock(WebSocketConnectionEventManager.class);
provider = new LinkedDeviceRefreshRequirementProvider(accountsManager);
final WebsocketRefreshRequestEventListener listener =
new WebsocketRefreshRequestEventListener(disconnectionRequestManager, webSocketConnectionEventManager, provider);
new WebsocketRefreshRequestEventListener(disconnectionRequestManager, provider);
when(applicationEventListener.onRequest(any())).thenReturn(listener);
@@ -141,10 +138,6 @@ class LinkedDeviceRefreshRequirementProviderTest {
assertEquals(initialDeviceCount + addedDeviceNames.size(), account.getDevices().size());
verify(webSocketConnectionEventManager).requestDisconnection(account.getUuid(), List.of((byte) 1));
verify(webSocketConnectionEventManager).requestDisconnection(account.getUuid(), List.of((byte) 2));
verify(webSocketConnectionEventManager).requestDisconnection(account.getUuid(), List.of((byte) 3));
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of((byte) 1));
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of((byte) 2));
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of((byte) 3));
@@ -175,12 +168,10 @@ class LinkedDeviceRefreshRequirementProviderTest {
assertEquals(200, response.getStatus());
initialDeviceIds.forEach(deviceId -> {
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of(deviceId));
verify(webSocketConnectionEventManager).requestDisconnection(account.getUuid(), List.of(deviceId));
});
initialDeviceIds.forEach(deviceId ->
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of(deviceId)));
verifyNoMoreInteractions(webSocketConnectionEventManager);
verifyNoMoreInteractions(disconnectionRequestManager);
}
@Test

View File

@@ -47,7 +47,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.whispersystems.textsecuregcm.filters.RemoteAddressFilter;
import org.whispersystems.textsecuregcm.push.WebSocketConnectionEventManager;
import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.AccountsManager;
import org.whispersystems.textsecuregcm.storage.Device;
@@ -77,9 +76,6 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
private static final DisconnectionRequestManager DISCONNECTION_REQUEST_MANAGER =
mock(DisconnectionRequestManager.class);
private static final WebSocketConnectionEventManager WEB_SOCKET_CONNECTION_EVENT_MANAGER =
mock(WebSocketConnectionEventManager.class);
private WebSocketClient client;
private final Account account1 = new Account();
private final Account account2 = new Account();
@@ -88,7 +84,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
@BeforeEach
void setUp() throws Exception {
reset(AUTHENTICATOR, ACCOUNTS_MANAGER, WEB_SOCKET_CONNECTION_EVENT_MANAGER);
reset(AUTHENTICATOR, ACCOUNTS_MANAGER, DISCONNECTION_REQUEST_MANAGER);
client = new WebSocketClient();
client.start();
@@ -127,9 +123,9 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
webSocketEnvironment.jersey().register(new RemoteAddressFilter());
webSocketEnvironment.jersey()
.register(new WebsocketRefreshApplicationEventListener(ACCOUNTS_MANAGER, DISCONNECTION_REQUEST_MANAGER, WEB_SOCKET_CONNECTION_EVENT_MANAGER));
.register(new WebsocketRefreshApplicationEventListener(ACCOUNTS_MANAGER, DISCONNECTION_REQUEST_MANAGER));
environment.jersey()
.register(new WebsocketRefreshApplicationEventListener(ACCOUNTS_MANAGER, DISCONNECTION_REQUEST_MANAGER, WEB_SOCKET_CONNECTION_EVENT_MANAGER));
.register(new WebsocketRefreshApplicationEventListener(ACCOUNTS_MANAGER, DISCONNECTION_REQUEST_MANAGER));
webSocketEnvironment.setConnectListener(webSocketSessionContext -> {
});
@@ -203,7 +199,6 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
// Event listeners can fire after responses are sent
verify(ACCOUNTS_MANAGER, timeout(5000).times(1)).getByAccountIdentifier(eq(account1.getUuid()));
verifyNoMoreInteractions(WEB_SOCKET_CONNECTION_EVENT_MANAGER);
verifyNoMoreInteractions(ACCOUNTS_MANAGER);
}
@@ -220,11 +215,6 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
verify(DISCONNECTION_REQUEST_MANAGER, timeout(5000))
.requestDisconnection(account1.getUuid(), List.of(authenticatedDevice.getId()));
verifyNoMoreInteractions(DISCONNECTION_REQUEST_MANAGER);
verify(WEB_SOCKET_CONNECTION_EVENT_MANAGER, timeout(5000))
.requestDisconnection(account1.getUuid(), List.of(authenticatedDevice.getId()));
verifyNoMoreInteractions(WEB_SOCKET_CONNECTION_EVENT_MANAGER);
}
@Test
@@ -241,10 +231,6 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
verify(DISCONNECTION_REQUEST_MANAGER, timeout(5000))
.requestDisconnection(account1.getUuid(), List.of(authenticatedDevice.getId()));
verifyNoMoreInteractions(DISCONNECTION_REQUEST_MANAGER);
verify(WEB_SOCKET_CONNECTION_EVENT_MANAGER, timeout(5000))
.requestDisconnection(account1.getUuid(), List.of(authenticatedDevice.getId()));
verifyNoMoreInteractions(WEB_SOCKET_CONNECTION_EVENT_MANAGER);
}
@ParameterizedTest

View File

@@ -47,7 +47,6 @@ class RegistrationLockVerificationManagerTest {
private final AccountsManager accountsManager = mock(AccountsManager.class);
private final DisconnectionRequestManager disconnectionRequestManager = mock(DisconnectionRequestManager.class);
private final WebSocketConnectionEventManager webSocketConnectionEventManager = mock(WebSocketConnectionEventManager.class);
private final ExternalServiceCredentialsGenerator svr2CredentialsGenerator = mock(
ExternalServiceCredentialsGenerator.class);
private final ExternalServiceCredentialsGenerator svr3CredentialsGenerator = mock(
@@ -57,7 +56,7 @@ class RegistrationLockVerificationManagerTest {
private static PushNotificationManager pushNotificationManager = mock(PushNotificationManager.class);
private final RateLimiters rateLimiters = mock(RateLimiters.class);
private final RegistrationLockVerificationManager registrationLockVerificationManager = new RegistrationLockVerificationManager(
accountsManager, disconnectionRequestManager, webSocketConnectionEventManager, svr2CredentialsGenerator,
accountsManager, disconnectionRequestManager, svr2CredentialsGenerator,
svr3CredentialsGenerator, registrationRecoveryPasswordsManager, pushNotificationManager, rateLimiters);
private final RateLimiter pinLimiter = mock(RateLimiter.class);
@@ -109,7 +108,6 @@ class RegistrationLockVerificationManagerTest {
verify(registrationRecoveryPasswordsManager, never()).removeForNumber(account.getNumber());
}
verify(disconnectionRequestManager).requestDisconnection(account.getUuid(), List.of(Device.PRIMARY_ID));
verify(webSocketConnectionEventManager).requestDisconnection(account.getUuid(), List.of(Device.PRIMARY_ID));
try {
verify(pushNotificationManager).sendAttemptLoginNotification(any(), eq("failedRegistrationLock"));
} catch (NotPushRegisteredException npre) {}
@@ -133,7 +131,6 @@ class RegistrationLockVerificationManagerTest {
} catch (NotPushRegisteredException npre) {}
verify(registrationRecoveryPasswordsManager, never()).removeForNumber(account.getNumber());
verify(disconnectionRequestManager, never()).requestDisconnection(any(), any());
verify(webSocketConnectionEventManager, never()).requestDisconnection(any(), any());
});
}
};
@@ -172,7 +169,6 @@ class RegistrationLockVerificationManagerTest {
verify(account, never()).lockAuthTokenHash();
verify(registrationRecoveryPasswordsManager, never()).removeForNumber(account.getNumber());
verify(disconnectionRequestManager, never()).requestDisconnection(any(), any());
verify(webSocketConnectionEventManager, never()).requestDisconnection(any(), any());
}
static Stream<Arguments> testSuccess() {