mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-27 12:15:50 +01:00
Initial pre-alpha support for sender key.
This commit is contained in:
@@ -16,7 +16,7 @@ public final class AccountAttributesTest {
|
||||
"reglock1234",
|
||||
new byte[10],
|
||||
false,
|
||||
new AccountAttributes.Capabilities(true, true, true, true),
|
||||
new AccountAttributes.Capabilities(true, true, true, true, true),
|
||||
false));
|
||||
assertEquals("{\"signalingKey\":\"skey\"," +
|
||||
"\"registrationId\":123," +
|
||||
@@ -28,19 +28,19 @@ public final class AccountAttributesTest {
|
||||
"\"unidentifiedAccessKey\":\"AAAAAAAAAAAAAA==\"," +
|
||||
"\"unrestrictedUnidentifiedAccess\":false," +
|
||||
"\"discoverableByPhoneNumber\":false," +
|
||||
"\"capabilities\":{\"uuid\":true,\"storage\":true,\"gv2-3\":true,\"gv1-migration\":true}}", json);
|
||||
"\"capabilities\":{\"uuid\":true,\"storage\":true,\"senderKey\":true,\"gv2-3\":true,\"gv1-migration\":true}}", json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gv2_true() {
|
||||
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, true, false, false));
|
||||
assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":true,\"gv1-migration\":false}", json);
|
||||
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, true, false, false, false));
|
||||
assertEquals("{\"uuid\":false,\"storage\":false,\"senderKey\":false,\"gv2-3\":true,\"gv1-migration\":false}", json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gv2_false() {
|
||||
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, false, false, false));
|
||||
assertEquals("{\"uuid\":false,\"storage\":false,\"gv2-3\":false,\"gv1-migration\":false}", json);
|
||||
String json = JsonUtil.toJson(new AccountAttributes.Capabilities(false, false, false, false, false));
|
||||
assertEquals("{\"uuid\":false,\"storage\":false,\"senderKey\":false,\"gv2-3\":false,\"gv1-migration\":false}", json);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.whispersystems.signalservice.internal.push;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.signalservice.internal.util.JsonUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class GroupMismatchedDevicesTest {
|
||||
|
||||
@Test
|
||||
public void testSimpleParse() throws IOException {
|
||||
GroupMismatchedDevices[] parsed = JsonUtil.fromJson("[\n" +
|
||||
" {\n" +
|
||||
" \"uuid\": \"12345678-1234-1234-1234-123456789012\",\n" +
|
||||
" \"devices\": {\n" +
|
||||
" \"missingDevices\": [1, 2],\n" +
|
||||
" \"extraDevices\": [3]\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"uuid\": \"22345678-1234-1234-1234-123456789012\",\n" +
|
||||
" \"devices\": {\n" +
|
||||
" \"missingDevices\": [],\n" +
|
||||
" \"extraDevices\": [2]\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"]", GroupMismatchedDevices[].class);
|
||||
|
||||
assertEquals(2, parsed.length);
|
||||
assertEquals("12345678-1234-1234-1234-123456789012", parsed[0].getUuid());
|
||||
assertEquals(1, (int) parsed[0].getDevices().getMissingDevices().get(0));
|
||||
assertEquals(2, (int) parsed[0].getDevices().getMissingDevices().get(1));
|
||||
assertEquals(3, (int) parsed[0].getDevices().getExtraDevices().get(0));
|
||||
|
||||
assertEquals("22345678-1234-1234-1234-123456789012", parsed[1].getUuid());
|
||||
assertEquals(2, (int) parsed[1].getDevices().getExtraDevices().get(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.whispersystems.signalservice.internal.push;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.signalservice.internal.util.JsonUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class GroupStaleDevicesTest {
|
||||
|
||||
@Test
|
||||
public void testSimpleParse() throws IOException {
|
||||
GroupStaleDevices[] parsed = JsonUtil.fromJson("[\n" +
|
||||
" {\n" +
|
||||
" \"uuid\": \"12345678-1234-1234-1234-123456789012\",\n" +
|
||||
" \"devices\": {\n" +
|
||||
" \"staleDevices\": [3]\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"uuid\": \"22345678-1234-1234-1234-123456789012\",\n" +
|
||||
" \"devices\": {\n" +
|
||||
" \"staleDevices\": [2]\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"]", GroupStaleDevices[].class);
|
||||
|
||||
assertEquals(2, parsed.length);
|
||||
assertEquals("12345678-1234-1234-1234-123456789012", parsed[0].getUuid());
|
||||
assertEquals(3, (int) parsed[0].getDevices().getStaleDevices().get(0));
|
||||
|
||||
assertEquals("22345678-1234-1234-1234-123456789012", parsed[1].getUuid());
|
||||
assertEquals(2, (int) parsed[1].getDevices().getStaleDevices().get(0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user