mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 09:38:03 +01:00
Only consider desktop devices GV2-capable if they send the third-gen GV2 capability.
This commit is contained in:
committed by
Jon Chambers
parent
9ed16478f4
commit
656e6db846
@@ -12,23 +12,40 @@ public class DeviceTest {
|
||||
|
||||
@Test
|
||||
@Parameters(method = "argumentsForTestIsGroupsV2Supported")
|
||||
public void testIsGroupsV2Supported(final String gcmId, final boolean gv2Capability, final boolean gv2_2Capability, final boolean expectGv2Supported) {
|
||||
final Device.DeviceCapabilities capabilities = new Device.DeviceCapabilities(gv2Capability, gv2_2Capability, false, false);
|
||||
final Device device = new Device(1, "test", "auth-token", "salt", "signaling-key", gcmId, "apn-id", "apn-voip-id", false, 1, null, 0, 0, "user-agent", 0, capabilities);
|
||||
public void testIsGroupsV2Supported(final String gcmId, final String apnId, final boolean gv2Capability, final boolean gv2_2Capability, final boolean gv2_3Capability, final boolean expectGv2Supported) {
|
||||
final Device.DeviceCapabilities capabilities = new Device.DeviceCapabilities(gv2Capability, gv2_2Capability, gv2_3Capability, false, false);
|
||||
final Device device = new Device(1, "test", "auth-token", "salt", "signaling-key", gcmId, apnId, null, false, 1, null, 0, 0, "user-agent", 0, capabilities);
|
||||
|
||||
assertEquals(expectGv2Supported, device.isGroupsV2Supported());
|
||||
}
|
||||
|
||||
private static Object argumentsForTestIsGroupsV2Supported() {
|
||||
return new Object[] {
|
||||
new Object[] { "gcm-id", false, false, false },
|
||||
new Object[] { "gcm-id", true, false, true },
|
||||
new Object[] { "gcm-id", false, true, true },
|
||||
new Object[] { "gcm-id", true, true, true },
|
||||
new Object[] { null, false, false, false },
|
||||
new Object[] { null, true, false, false },
|
||||
new Object[] { null, false, true, true },
|
||||
new Object[] { null, true, true, true }
|
||||
// gcmId apnId gv2 gv2-2 gv2-3 capable
|
||||
new Object[] { "gcm-id", null, false, false, false, false },
|
||||
new Object[] { "gcm-id", null, true, false, false, true },
|
||||
new Object[] { "gcm-id", null, false, true, false, true },
|
||||
new Object[] { "gcm-id", null, true, true, false, true },
|
||||
new Object[] { "gcm-id", null, false, false, true, true },
|
||||
new Object[] { "gcm-id", null, true, false, true, true },
|
||||
new Object[] { "gcm-id", null, false, true, true, true },
|
||||
new Object[] { "gcm-id", null, true, true, true, true },
|
||||
new Object[] { null, "apn-id", false, false, false, false },
|
||||
new Object[] { null, "apn-id", true, false, false, false },
|
||||
new Object[] { null, "apn-id", false, true, false, true },
|
||||
new Object[] { null, "apn-id", true, true, false, true },
|
||||
new Object[] { null, "apn-id", false, false, true, true },
|
||||
new Object[] { null, "apn-id", true, false, true, true },
|
||||
new Object[] { null, "apn-id", false, true, true, true },
|
||||
new Object[] { null, "apn-id", true, true, true, true },
|
||||
new Object[] { null, null, false, false, false, false },
|
||||
new Object[] { null, null, true, false, false, false },
|
||||
new Object[] { null, null, false, true, false, false },
|
||||
new Object[] { null, null, true, true, false, false },
|
||||
new Object[] { null, null, false, false, true, true },
|
||||
new Object[] { null, null, true, false, true, true },
|
||||
new Object[] { null, null, false, true, true, true },
|
||||
new Object[] { null, null, true, true, true, true }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class DeviceControllerTest {
|
||||
|
||||
@Test
|
||||
public void deviceDowngradeCapabilitiesTest() throws Exception {
|
||||
Device.DeviceCapabilities deviceCapabilities = new Device.DeviceCapabilities(false, false, true, false);
|
||||
Device.DeviceCapabilities deviceCapabilities = new Device.DeviceCapabilities(false, false, false, true, false);
|
||||
AccountAttributes accountAttributes = new AccountAttributes("keykeykeykey", false, 1234, null, null, null, null, true, deviceCapabilities);
|
||||
Response response = resources.getJerseyTest()
|
||||
.target("/v1/devices/5678901")
|
||||
|
||||
@@ -85,13 +85,13 @@ public class MessageControllerTest {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
Set<Device> singleDeviceList = new HashSet<Device>() {{
|
||||
add(new Device(1, null, "foo", "bar", "baz", "isgcm", null, null, false, 111, new SignedPreKey(333, "baz", "boop"), System.currentTimeMillis(), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(true, false, true, true)));
|
||||
add(new Device(1, null, "foo", "bar", "baz", "isgcm", null, null, false, 111, new SignedPreKey(333, "baz", "boop"), System.currentTimeMillis(), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(true, false, false, true, true)));
|
||||
}};
|
||||
|
||||
Set<Device> multiDeviceList = new HashSet<Device>() {{
|
||||
add(new Device(1, null, "foo", "bar", "baz", "isgcm", null, null, false, 222, new SignedPreKey(111, "foo", "bar"), System.currentTimeMillis(), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(true, false, true, false)));
|
||||
add(new Device(2, null, "foo", "bar", "baz", "isgcm", null, null, false, 333, new SignedPreKey(222, "oof", "rab"), System.currentTimeMillis(), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(true, false, true, false)));
|
||||
add(new Device(3, null, "foo", "bar", "baz", "isgcm", null, null, false, 444, null, System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(false, false, false, false)));
|
||||
add(new Device(1, null, "foo", "bar", "baz", "isgcm", null, null, false, 222, new SignedPreKey(111, "foo", "bar"), System.currentTimeMillis(), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(true, false, false, true, false)));
|
||||
add(new Device(2, null, "foo", "bar", "baz", "isgcm", null, null, false, 333, new SignedPreKey(222, "oof", "rab"), System.currentTimeMillis(), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(true, false, false, true, false)));
|
||||
add(new Device(3, null, "foo", "bar", "baz", "isgcm", null, null, false, 444, null, System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31), System.currentTimeMillis(), "Test", 0, new Device.DeviceCapabilities(false, false, false, false, false)));
|
||||
}};
|
||||
|
||||
Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, SINGLE_DEVICE_UUID, singleDeviceList, "1234".getBytes());
|
||||
|
||||
@@ -286,7 +286,7 @@ public class AccountsTest {
|
||||
private Device generateDevice(long id) {
|
||||
Random random = new Random(System.currentTimeMillis());
|
||||
SignedPreKey signedPreKey = new SignedPreKey(random.nextInt(), "testPublicKey-" + random.nextInt(), "testSignature-" + random.nextInt());
|
||||
return new Device(id, "testName-" + random.nextInt(), "testAuthToken-" + random.nextInt(), "testSalt-" + random.nextInt(), null, "testGcmId-" + random.nextInt(), "testApnId-" + random.nextInt(), "testVoipApnId-" + random.nextInt(), random.nextBoolean(), random.nextInt(), signedPreKey, random.nextInt(), random.nextInt(), "testUserAgent-" + random.nextInt() , 0, new Device.DeviceCapabilities(random.nextBoolean(), random.nextBoolean(), random.nextBoolean(), random.nextBoolean()));
|
||||
return new Device(id, "testName-" + random.nextInt(), "testAuthToken-" + random.nextInt(), "testSalt-" + random.nextInt(), null, "testGcmId-" + random.nextInt(), "testApnId-" + random.nextInt(), "testVoipApnId-" + random.nextInt(), random.nextBoolean(), random.nextInt(), signedPreKey, random.nextInt(), random.nextInt(), "testUserAgent-" + random.nextInt() , 0, new Device.DeviceCapabilities(random.nextBoolean(), random.nextBoolean(), random.nextBoolean(), random.nextBoolean(), random.nextBoolean()));
|
||||
}
|
||||
|
||||
private Account generateAccount(String number, UUID uuid) {
|
||||
|
||||
Reference in New Issue
Block a user