mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-08 20:18:34 +00:00
Revert "Ensure GV1 length is exactly the length expected."
This reverts commit 8e962bf992de3a68e2b8e12240a39ea707ce1749.
This commit is contained in:
parent
dadb2f9d37
commit
fc4e690996
@ -40,7 +40,7 @@ public abstract class GroupId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NonNull GroupId.V1 v1(byte[] gv1GroupIdBytes) throws BadGroupIdException {
|
public static @NonNull GroupId.V1 v1(byte[] gv1GroupIdBytes) throws BadGroupIdException {
|
||||||
if (gv1GroupIdBytes.length != MMS_BYTE_LENGTH) {
|
if (gv1GroupIdBytes.length == V2_BYTE_LENGTH) {
|
||||||
throw new BadGroupIdException();
|
throw new BadGroupIdException();
|
||||||
}
|
}
|
||||||
return new GroupId.V1(gv1GroupIdBytes);
|
return new GroupId.V1(gv1GroupIdBytes);
|
||||||
|
@ -276,16 +276,6 @@ public final class GroupIdTest {
|
|||||||
GroupId.v2orThrow(Hex.fromStringCondensed("000102030405060708090a0b0c0d0e0f"));
|
GroupId.v2orThrow(Hex.fromStringCondensed("000102030405060708090a0b0c0d0e0f"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = BadGroupIdException.class)
|
|
||||||
public void cannot_create_v1_with_a_bad_length() throws IOException, BadGroupIdException {
|
|
||||||
GroupId.v1(Hex.fromStringCondensed("000102030405060708090a0b0c0d0e0fff"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = AssertionError.class)
|
|
||||||
public void cannot_create_v1_with_a_bad_length_assert() throws IOException {
|
|
||||||
GroupId.v1orThrow(Hex.fromStringCondensed("000102030405060708090a0b0c0d0e0fff"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void create_mms() {
|
public void create_mms() {
|
||||||
GroupId.Mms mms = GroupId.createMms(mockRandom(new byte[]{ 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8 }));
|
GroupId.Mms mms = GroupId.createMms(mockRandom(new byte[]{ 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8 }));
|
||||||
|
@ -31,7 +31,7 @@ public class RecipientIdFollowUpJobMigrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void migrate_requestGroupInfoJob_good() throws Exception {
|
public void migrate_requestGroupInfoJob_good() throws Exception {
|
||||||
JobData testData = new JobData("RequestGroupInfoJob", null, new Data.Builder().putString("source", "1")
|
JobData testData = new JobData("RequestGroupInfoJob", null, new Data.Builder().putString("source", "1")
|
||||||
.putString("group_id", "__textsecure_group__!abcdef01234567899876543210fedcba")
|
.putString("group_id", "__textsecure_group__!abcd")
|
||||||
.build());
|
.build());
|
||||||
RecipientIdFollowUpJobMigration subject = new RecipientIdFollowUpJobMigration();
|
RecipientIdFollowUpJobMigration subject = new RecipientIdFollowUpJobMigration();
|
||||||
JobData converted = subject.migrate(testData);
|
JobData converted = subject.migrate(testData);
|
||||||
@ -39,7 +39,7 @@ public class RecipientIdFollowUpJobMigrationTest {
|
|||||||
assertEquals("RequestGroupInfoJob", converted.getFactoryKey());
|
assertEquals("RequestGroupInfoJob", converted.getFactoryKey());
|
||||||
assertNull(converted.getQueueKey());
|
assertNull(converted.getQueueKey());
|
||||||
assertEquals("1", converted.getData().getString("source"));
|
assertEquals("1", converted.getData().getString("source"));
|
||||||
assertEquals("__textsecure_group__!abcdef01234567899876543210fedcba", converted.getData().getString("group_id"));
|
assertEquals("__textsecure_group__!abcd", converted.getData().getString("group_id"));
|
||||||
|
|
||||||
new RequestGroupInfoJob.Factory().create(mock(Job.Parameters.class), converted.getData());
|
new RequestGroupInfoJob.Factory().create(mock(Job.Parameters.class), converted.getData());
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class RecipientIdJobMigrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void migrate_requestGroupInfoJob() throws Exception {
|
public void migrate_requestGroupInfoJob() throws Exception {
|
||||||
JobData testData = new JobData("RequestGroupInfoJob", null, new Data.Builder().putString("source", "+16101234567")
|
JobData testData = new JobData("RequestGroupInfoJob", null, new Data.Builder().putString("source", "+16101234567")
|
||||||
.putString("group_id", "__textsecure_group__!abcdef01234567899876543210fedcba")
|
.putString("group_id", "__textsecure_group__!abcd")
|
||||||
.build());
|
.build());
|
||||||
mockRecipientResolve("+16101234567", 1);
|
mockRecipientResolve("+16101234567", 1);
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ public class RecipientIdJobMigrationTest {
|
|||||||
assertEquals("RequestGroupInfoJob", converted.getFactoryKey());
|
assertEquals("RequestGroupInfoJob", converted.getFactoryKey());
|
||||||
assertNull(converted.getQueueKey());
|
assertNull(converted.getQueueKey());
|
||||||
assertEquals("1", converted.getData().getString("source"));
|
assertEquals("1", converted.getData().getString("source"));
|
||||||
assertEquals("__textsecure_group__!abcdef01234567899876543210fedcba", converted.getData().getString("group_id"));
|
assertEquals("__textsecure_group__!abcd", converted.getData().getString("group_id"));
|
||||||
|
|
||||||
new RequestGroupInfoJob.Factory().create(mock(Job.Parameters.class), converted.getData());
|
new RequestGroupInfoJob.Factory().create(mock(Job.Parameters.class), converted.getData());
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ public class RecipientIdJobMigrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void migrate_pushGroupUpdateJob() throws Exception {
|
public void migrate_pushGroupUpdateJob() throws Exception {
|
||||||
JobData testData = new JobData("PushGroupUpdateJob", null, new Data.Builder().putString("source", "+16101234567")
|
JobData testData = new JobData("PushGroupUpdateJob", null, new Data.Builder().putString("source", "+16101234567")
|
||||||
.putString("group_id", "__textsecure_group__!abcdef01234567899876543210fedcba")
|
.putString("group_id", "__textsecure_group__!abcd")
|
||||||
.build());
|
.build());
|
||||||
mockRecipientResolve("+16101234567", 1);
|
mockRecipientResolve("+16101234567", 1);
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ public class RecipientIdJobMigrationTest {
|
|||||||
assertEquals("PushGroupUpdateJob", converted.getFactoryKey());
|
assertEquals("PushGroupUpdateJob", converted.getFactoryKey());
|
||||||
assertNull(converted.getQueueKey());
|
assertNull(converted.getQueueKey());
|
||||||
assertEquals("1", converted.getData().getString("source"));
|
assertEquals("1", converted.getData().getString("source"));
|
||||||
assertEquals("__textsecure_group__!abcdef01234567899876543210fedcba", converted.getData().getString("group_id"));
|
assertEquals("__textsecure_group__!abcd", converted.getData().getString("group_id"));
|
||||||
|
|
||||||
new PushGroupUpdateJob.Factory().create(mock(Job.Parameters.class), converted.getData());
|
new PushGroupUpdateJob.Factory().create(mock(Job.Parameters.class), converted.getData());
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.storage;
|
package org.thoughtcrime.securesms.storage;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.thoughtcrime.securesms.storage.GroupV1ConflictMerger;
|
||||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper.KeyGenerator;
|
import org.thoughtcrime.securesms.storage.StorageSyncHelper.KeyGenerator;
|
||||||
import org.whispersystems.signalservice.api.storage.SignalGroupV1Record;
|
import org.whispersystems.signalservice.api.storage.SignalGroupV1Record;
|
||||||
|
|
||||||
@ -15,22 +16,20 @@ import static org.thoughtcrime.securesms.testutil.TestHelpers.byteArray;
|
|||||||
|
|
||||||
public class GroupV1ConflictMergerTest {
|
public class GroupV1ConflictMergerTest {
|
||||||
|
|
||||||
private static final byte[] GENERATED_KEY = byteArray(8675309);
|
private static byte[] GENERATED_KEY = byteArray(8675309);
|
||||||
private static final KeyGenerator KEY_GENERATOR = mock(KeyGenerator.class);
|
private static KeyGenerator KEY_GENERATOR = mock(KeyGenerator.class);
|
||||||
private static final byte[] V1_GROUP_ID = byteArray(100, 16);
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
when(KEY_GENERATOR.generate()).thenReturn(GENERATED_KEY);
|
when(KEY_GENERATOR.generate()).thenReturn(GENERATED_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void merge_alwaysPreferRemote_exceptProfileSharingIsEitherOr() {
|
public void merge_alwaysPreferRemote_exceptProfileSharingIsEitherOr() {
|
||||||
SignalGroupV1Record remote = new SignalGroupV1Record.Builder(byteArray(1), V1_GROUP_ID)
|
SignalGroupV1Record remote = new SignalGroupV1Record.Builder(byteArray(1), byteArray(100))
|
||||||
.setBlocked(false)
|
.setBlocked(false)
|
||||||
.setProfileSharingEnabled(false)
|
.setProfileSharingEnabled(false)
|
||||||
.setArchived(false)
|
.setArchived(false)
|
||||||
.build();
|
.build();
|
||||||
SignalGroupV1Record local = new SignalGroupV1Record.Builder(byteArray(2), V1_GROUP_ID)
|
SignalGroupV1Record local = new SignalGroupV1Record.Builder(byteArray(2), byteArray(100))
|
||||||
.setBlocked(true)
|
.setBlocked(true)
|
||||||
.setProfileSharingEnabled(true)
|
.setProfileSharingEnabled(true)
|
||||||
.setArchived(true)
|
.setArchived(true)
|
||||||
@ -39,19 +38,19 @@ public class GroupV1ConflictMergerTest {
|
|||||||
SignalGroupV1Record merged = new GroupV1ConflictMerger(Collections.singletonList(local)).merge(remote, local, KEY_GENERATOR);
|
SignalGroupV1Record merged = new GroupV1ConflictMerger(Collections.singletonList(local)).merge(remote, local, KEY_GENERATOR);
|
||||||
|
|
||||||
assertArrayEquals(GENERATED_KEY, merged.getId().getRaw());
|
assertArrayEquals(GENERATED_KEY, merged.getId().getRaw());
|
||||||
assertArrayEquals(V1_GROUP_ID, merged.getGroupId());
|
assertArrayEquals(byteArray(100), merged.getGroupId());
|
||||||
assertFalse(merged.isBlocked());
|
assertFalse(merged.isBlocked());
|
||||||
assertFalse(merged.isArchived());
|
assertFalse(merged.isArchived());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void merge_returnRemoteIfEndResultMatchesRemote() {
|
public void merge_returnRemoteIfEndResultMatchesRemote() {
|
||||||
SignalGroupV1Record remote = new SignalGroupV1Record.Builder(byteArray(1), V1_GROUP_ID)
|
SignalGroupV1Record remote = new SignalGroupV1Record.Builder(byteArray(1), byteArray(100))
|
||||||
.setBlocked(false)
|
.setBlocked(false)
|
||||||
.setProfileSharingEnabled(true)
|
.setProfileSharingEnabled(true)
|
||||||
.setArchived(true)
|
.setArchived(true)
|
||||||
.build();
|
.build();
|
||||||
SignalGroupV1Record local = new SignalGroupV1Record.Builder(byteArray(2), V1_GROUP_ID)
|
SignalGroupV1Record local = new SignalGroupV1Record.Builder(byteArray(2), byteArray(100))
|
||||||
.setBlocked(true)
|
.setBlocked(true)
|
||||||
.setProfileSharingEnabled(false)
|
.setProfileSharingEnabled(false)
|
||||||
.setArchived(false)
|
.setArchived(false)
|
||||||
@ -64,12 +63,12 @@ public class GroupV1ConflictMergerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void merge_returnLocalIfEndResultMatchesLocal() {
|
public void merge_returnLocalIfEndResultMatchesLocal() {
|
||||||
SignalGroupV1Record remote = new SignalGroupV1Record.Builder(byteArray(1), V1_GROUP_ID)
|
SignalGroupV1Record remote = new SignalGroupV1Record.Builder(byteArray(1), byteArray(100))
|
||||||
.setBlocked(false)
|
.setBlocked(false)
|
||||||
.setProfileSharingEnabled(false)
|
.setProfileSharingEnabled(false)
|
||||||
.setArchived(false)
|
.setArchived(false)
|
||||||
.build();
|
.build();
|
||||||
SignalGroupV1Record local = new SignalGroupV1Record.Builder(byteArray(2), V1_GROUP_ID)
|
SignalGroupV1Record local = new SignalGroupV1Record.Builder(byteArray(2), byteArray(100))
|
||||||
.setBlocked(false)
|
.setBlocked(false)
|
||||||
.setProfileSharingEnabled(true)
|
.setProfileSharingEnabled(true)
|
||||||
.setArchived(false)
|
.setArchived(false)
|
||||||
|
@ -417,7 +417,7 @@ public final class StorageSyncHelperTest {
|
|||||||
boolean blocked,
|
boolean blocked,
|
||||||
boolean profileSharing)
|
boolean profileSharing)
|
||||||
{
|
{
|
||||||
return new SignalGroupV1Record.Builder(byteArray(key), byteArray(groupId, 16)).setBlocked(blocked).setProfileSharingEnabled(profileSharing).build();
|
return new SignalGroupV1Record.Builder(byteArray(key), byteArray(groupId)).setBlocked(blocked).setProfileSharingEnabled(profileSharing).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SignalGroupV2Record groupV2(int key,
|
private static SignalGroupV2Record groupV2(int key,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user