diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java index 8a3093165..27b5a5c6d 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java @@ -197,7 +197,7 @@ public class ProfileController { accountProfile.get().getIdentityKey(), UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), accountProfile.get().isUnrestrictedUnidentifiedAccess(), - new UserCapabilities(accountProfile.get().isUuidAddressingSupported(), accountProfile.get().isGroupsV2Supported()), + new UserCapabilities(accountProfile.get().isGroupsV2Supported()), username.orElse(null), null, credential.orElse(null), @@ -235,7 +235,7 @@ public class ProfileController { accountProfile.get().getIdentityKey(), UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), accountProfile.get().isUnrestrictedUnidentifiedAccess(), - new UserCapabilities(accountProfile.get().isUuidAddressingSupported(), accountProfile.get().isGroupsV2Supported()), + new UserCapabilities(accountProfile.get().isGroupsV2Supported()), username, accountProfile.get().getUuid(), null, @@ -308,7 +308,7 @@ public class ProfileController { accountProfile.get().getIdentityKey(), UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), accountProfile.get().isUnrestrictedUnidentifiedAccess(), - new UserCapabilities(accountProfile.get().isUuidAddressingSupported(), accountProfile.get().isGroupsV2Supported()), + new UserCapabilities(accountProfile.get().isGroupsV2Supported()), username.orElse(null), null, null, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java index 217b8f3e8..60bce877b 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java @@ -3,23 +3,15 @@ package org.whispersystems.textsecuregcm.entities; import com.fasterxml.jackson.annotation.JsonProperty; public class UserCapabilities { - @JsonProperty - private boolean uuid; - @JsonProperty private boolean gv2; public UserCapabilities() {} - public UserCapabilities(boolean uuid, boolean gv2) { - this.uuid = uuid; + public UserCapabilities(boolean gv2) { this.gv2 = gv2; } - public boolean isUuid() { - return uuid; - } - public boolean isGv2() { return gv2; } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java index 5a608af70..511d73650 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java @@ -137,12 +137,6 @@ public class Account implements Principal { return Optional.empty(); } - public boolean isUuidAddressingSupported() { - return devices.stream() - .filter(Device::isEnabled) - .allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isUuid()); - } - public boolean isGroupsV2Supported() { return devices.stream() .filter(Device::isEnabled) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Device.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Device.java index 190967126..5235e3a22 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Device.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Device.java @@ -267,9 +267,6 @@ public class Device { } public static class DeviceCapabilities { - @JsonProperty - private boolean uuid; - @JsonProperty private boolean gv2; @@ -281,17 +278,12 @@ public class Device { public DeviceCapabilities() {} - public DeviceCapabilities(boolean uuid, boolean gv2, boolean storage, boolean transfer) { - this.uuid = uuid; + public DeviceCapabilities(boolean gv2, boolean storage, boolean transfer) { this.gv2 = gv2; this.storage = storage; this.transfer = transfer; } - public boolean isUuid() { - return uuid; - } - public boolean isGv2() { return gv2; } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java index 026034516..0f1c6c875 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java @@ -117,7 +117,6 @@ public class DeviceControllerTest { // when(maxedAccount.getActiveDeviceCount()).thenReturn(6); when(account.getAuthenticatedDevice()).thenReturn(Optional.of(masterDevice)); when(account.isEnabled()).thenReturn(false); - when(account.isUuidAddressingSupported()).thenReturn(true); when(account.isGroupsV2Supported()).thenReturn(true); when(pendingDevicesManager.getCodeForNumber(AuthHelper.VALID_NUMBER)).thenReturn(Optional.of(new StoredVerificationCode("5678901", System.currentTimeMillis(), null))); @@ -224,7 +223,7 @@ public class DeviceControllerTest { @Test public void deviceDowngradeCapabilitiesTest() throws Exception { - Device.DeviceCapabilities deviceCapabilities = new Device.DeviceCapabilities(true, false, true, false); + Device.DeviceCapabilities deviceCapabilities = new Device.DeviceCapabilities(false, true, false); AccountAttributes accountAttributes = new AccountAttributes("keykeykeykey", false, 1234, null, null, null, null, true, deviceCapabilities); Response response = resources.getJerseyTest() .target("/v1/devices/5678901") diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java index 757c6a104..006e4ad23 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java @@ -85,13 +85,13 @@ public class MessageControllerTest { @Before public void setup() throws Exception { Set singleDeviceList = new HashSet() {{ - 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, true, 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, true, true))); }}; Set multiDeviceList = new HashSet() {{ - 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, true, 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, true, 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, 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, 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))); }}; Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, SINGLE_DEVICE_UUID, singleDeviceList, "1234".getBytes()); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java index 15bddf1b2..977d6d02f 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java @@ -96,7 +96,7 @@ public class ProfileControllerTest { when(profileAccount.getAvatar()).thenReturn("profiles/bang"); when(profileAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID_TWO); when(profileAccount.isEnabled()).thenReturn(true); - when(profileAccount.isUuidAddressingSupported()).thenReturn(false); + when(profileAccount.isGroupsV2Supported()).thenReturn(false); when(profileAccount.getPayments()).thenReturn(List.of(new PaymentAddress("mc", "12345678901234567890123456789012"))); Account capabilitiesAccount = mock(Account.class); @@ -105,7 +105,7 @@ public class ProfileControllerTest { when(capabilitiesAccount.getProfileName()).thenReturn("bazz"); when(capabilitiesAccount.getAvatar()).thenReturn("profiles/bangz"); when(capabilitiesAccount.isEnabled()).thenReturn(true); - when(capabilitiesAccount.isUuidAddressingSupported()).thenReturn(true); + when(capabilitiesAccount.isGroupsV2Supported()).thenReturn(true); when(accountsManager.get(AuthHelper.VALID_NUMBER_TWO)).thenReturn(Optional.of(profileAccount)); when(accountsManager.get(AuthHelper.VALID_UUID_TWO)).thenReturn(Optional.of(profileAccount)); @@ -158,7 +158,7 @@ public class ProfileControllerTest { assertThat(profile.getName()).isEqualTo("baz"); assertThat(profile.getAvatar()).isEqualTo("profiles/bang"); assertThat(profile.getPayments()).isEqualTo(List.of(new PaymentAddress("mc", "12345678901234567890123456789012"))); - assertThat(profile.getCapabilities().isUuid()).isFalse(); + assertThat(profile.getCapabilities().isGv2()).isFalse(); assertThat(profile.getUsername()).isNull(); assertThat(profile.getUuid()).isNull();; @@ -242,7 +242,7 @@ public class ProfileControllerTest { .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD)) .get(Profile.class); - assertThat(profile.getCapabilities().isUuid()).isTrue(); + assertThat(profile.getCapabilities().isGv2()).isTrue(); } @Test @@ -385,7 +385,7 @@ public class ProfileControllerTest { assertThat(profile.getIdentityKey()).isEqualTo("bar"); assertThat(profile.getName()).isEqualTo("validname"); assertThat(profile.getAvatar()).isEqualTo("profiles/validavatar"); - assertThat(profile.getCapabilities().isUuid()).isFalse(); + assertThat(profile.getCapabilities().isGv2()).isFalse(); assertThat(profile.getUsername()).isEqualTo("n00bkiller"); assertThat(profile.getUuid()).isNull();; diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java index 4c25ae08e..13ae221e3 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java @@ -25,9 +25,9 @@ public class AccountTest { private final Device recentSecondaryDevice = mock(Device.class); private final Device oldSecondaryDevice = mock(Device.class); - private final Device uuidCapableDevice = mock(Device.class); - private final Device uuidIncapableDevice = mock(Device.class); - private final Device uuidIncapableExpiredDevice = mock(Device.class); + private final Device gv2CapableDevice = mock(Device.class); + private final Device gv2IncapableDevice = mock(Device.class); + private final Device gv2IncapableExpiredDevice = mock(Device.class); @Before public void setup() { @@ -51,17 +51,17 @@ public class AccountTest { when(oldSecondaryDevice.isEnabled()).thenReturn(false); when(oldSecondaryDevice.getId()).thenReturn(2L); - when(uuidCapableDevice.getCapabilities()).thenReturn(new Device.DeviceCapabilities(true, true, true, true)); - when(uuidCapableDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)); - when(uuidCapableDevice.isEnabled()).thenReturn(true); + when(gv2CapableDevice.getCapabilities()).thenReturn(new Device.DeviceCapabilities(true, true, true)); + when(gv2CapableDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)); + when(gv2CapableDevice.isEnabled()).thenReturn(true); - when(uuidIncapableDevice.getCapabilities()).thenReturn(new Device.DeviceCapabilities(false, false, false, false)); - when(uuidIncapableDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)); - when(uuidIncapableDevice.isEnabled()).thenReturn(true); + when(gv2IncapableDevice.getCapabilities()).thenReturn(new Device.DeviceCapabilities(false, false, false)); + when(gv2IncapableDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)); + when(gv2IncapableDevice.isEnabled()).thenReturn(true); - when(uuidIncapableExpiredDevice.getCapabilities()).thenReturn(new Device.DeviceCapabilities(false, false, false, false)); - when(uuidIncapableExpiredDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31)); - when(uuidIncapableExpiredDevice.isEnabled()).thenReturn(false); + when(gv2IncapableExpiredDevice.getCapabilities()).thenReturn(new Device.DeviceCapabilities(false, false, false)); + when(gv2IncapableExpiredDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31)); + when(gv2IncapableExpiredDevice.isEnabled()).thenReturn(false); } @Test @@ -101,22 +101,22 @@ public class AccountTest { @Test public void testCapabilities() { Account uuidCapable = new Account("+14152222222", UUID.randomUUID(), new HashSet() {{ - add(uuidCapableDevice); + add(gv2CapableDevice); }}, "1234".getBytes()); Account uuidIncapable = new Account("+14152222222", UUID.randomUUID(), new HashSet() {{ - add(uuidCapableDevice); - add(uuidIncapableDevice); + add(gv2CapableDevice); + add(gv2IncapableDevice); }}, "1234".getBytes()); Account uuidCapableWithExpiredIncapable = new Account("+14152222222", UUID.randomUUID(), new HashSet() {{ - add(uuidCapableDevice); - add(uuidIncapableExpiredDevice); + add(gv2CapableDevice); + add(gv2IncapableExpiredDevice); }}, "1234".getBytes()); - assertTrue(uuidCapable.isUuidAddressingSupported()); - assertFalse(uuidIncapable.isUuidAddressingSupported()); - assertTrue(uuidCapableWithExpiredIncapable.isUuidAddressingSupported()); + assertTrue(uuidCapable.isGroupsV2Supported()); + assertFalse(uuidIncapable.isGroupsV2Supported()); + assertTrue(uuidCapableWithExpiredIncapable.isGroupsV2Supported()); } @Test diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java index 37dcc512b..022ce7b51 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsTest.java @@ -266,7 +266,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())); } private Account generateAccount(String number, UUID uuid) {