mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 11:18:06 +01:00
Remove expiration check from Device#isEnabled()
This commit is contained in:
@@ -163,7 +163,7 @@ class AccountAuthenticatorTest {
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.isEnabled()).thenReturn(true);
|
||||
when(device.getId()).thenReturn(deviceId);
|
||||
when(device.isEnabled()).thenReturn(true);
|
||||
when(device.hasMessageDeliveryChannel()).thenReturn(true);
|
||||
when(device.getAuthTokenHash()).thenReturn(credentials);
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
@@ -193,7 +193,7 @@ class AccountAuthenticatorTest {
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.isEnabled()).thenReturn(true);
|
||||
when(device.getId()).thenReturn(deviceId);
|
||||
when(device.isEnabled()).thenReturn(true);
|
||||
when(device.hasMessageDeliveryChannel()).thenReturn(true);
|
||||
when(device.getAuthTokenHash()).thenReturn(credentials);
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
@@ -226,7 +226,7 @@ class AccountAuthenticatorTest {
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(authenticatedDevice));
|
||||
when(account.isEnabled()).thenReturn(accountEnabled);
|
||||
when(authenticatedDevice.getId()).thenReturn(deviceId);
|
||||
when(authenticatedDevice.isEnabled()).thenReturn(deviceEnabled);
|
||||
when(authenticatedDevice.hasMessageDeliveryChannel()).thenReturn(deviceEnabled);
|
||||
when(authenticatedDevice.getAuthTokenHash()).thenReturn(credentials);
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
@@ -262,7 +262,7 @@ class AccountAuthenticatorTest {
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.isEnabled()).thenReturn(true);
|
||||
when(device.getId()).thenReturn(deviceId);
|
||||
when(device.isEnabled()).thenReturn(true);
|
||||
when(device.hasMessageDeliveryChannel()).thenReturn(true);
|
||||
when(device.getAuthTokenHash()).thenReturn(credentials);
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.Version.V1);
|
||||
@@ -299,7 +299,7 @@ class AccountAuthenticatorTest {
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.isEnabled()).thenReturn(true);
|
||||
when(device.getId()).thenReturn(deviceId);
|
||||
when(device.isEnabled()).thenReturn(true);
|
||||
when(device.hasMessageDeliveryChannel()).thenReturn(true);
|
||||
when(device.getAuthTokenHash()).thenReturn(credentials);
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
@@ -327,7 +327,7 @@ class AccountAuthenticatorTest {
|
||||
when(account.getDevice(deviceId)).thenReturn(Optional.of(device));
|
||||
when(account.isEnabled()).thenReturn(true);
|
||||
when(device.getId()).thenReturn(deviceId);
|
||||
when(device.isEnabled()).thenReturn(true);
|
||||
when(device.hasMessageDeliveryChannel()).thenReturn(true);
|
||||
when(device.getAuthTokenHash()).thenReturn(credentials);
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
|
||||
@@ -136,7 +136,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
void testDeviceEnabledChanged(final Map<Byte, Boolean> initialEnabled, final Map<Byte, Boolean> finalEnabled) {
|
||||
assert initialEnabled.size() == finalEnabled.size();
|
||||
|
||||
assert account.getPrimaryDevice().isEnabled();
|
||||
assert account.getPrimaryDevice().hasMessageDeliveryChannel();
|
||||
|
||||
initialEnabled.forEach((deviceId, enabled) ->
|
||||
DevicesHelper.setEnabled(account.getDevice(deviceId).orElseThrow(), enabled));
|
||||
@@ -177,7 +177,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
|
||||
@Test
|
||||
void testDeviceAdded() {
|
||||
assert account.getPrimaryDevice().isEnabled();
|
||||
assert account.getPrimaryDevice().hasMessageDeliveryChannel();
|
||||
|
||||
final int initialDeviceCount = account.getDevices().size();
|
||||
|
||||
@@ -204,7 +204,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
@ParameterizedTest
|
||||
@ValueSource(ints = {1, 2})
|
||||
void testDeviceRemoved(final int removedDeviceCount) {
|
||||
assert account.getPrimaryDevice().isEnabled();
|
||||
assert account.getPrimaryDevice().hasMessageDeliveryChannel();
|
||||
|
||||
final List<Byte> initialDeviceIds = account.getDevices().stream().map(Device::getId).toList();
|
||||
|
||||
@@ -367,7 +367,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
|
||||
DevicesHelper.setEnabled(device, enabled);
|
||||
|
||||
assert device.isEnabled() == enabled;
|
||||
assert device.hasMessageDeliveryChannel() == enabled;
|
||||
|
||||
return String.format("Set account to %s", enabled);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ContainerRequestUtilTest {
|
||||
.forEach(id -> {
|
||||
final Device device = mock(Device.class);
|
||||
when(device.getId()).thenReturn((byte) id);
|
||||
when(device.isEnabled()).thenReturn(id != disabledDeviceId);
|
||||
when(device.hasMessageDeliveryChannel()).thenReturn(id != disabledDeviceId);
|
||||
devices.add(device);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user