mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 08:38:03 +01:00
Drop profile migration tools
This commit is contained in:
committed by
Jon Chambers
parent
d94e86781f
commit
6aceb24fd2
@@ -5,18 +5,12 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
@@ -150,44 +144,4 @@ class ProfilesDynamoDbTest extends ProfilesTest {
|
||||
Map.of(":commitment", AttributeValues.fromByteArray(commitment)))
|
||||
);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
void migrate(final VersionedProfile profile) {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
|
||||
assertTrue(assertDoesNotThrow(() -> profiles.migrate(uuid, profile).join()));
|
||||
assertFalse(assertDoesNotThrow(() -> profiles.migrate(uuid, profile).join()));
|
||||
|
||||
assertEquals(Optional.of(profile), profiles.get(uuid, profile.getVersion()));
|
||||
}
|
||||
|
||||
private static Stream<Arguments> migrate() {
|
||||
return Stream.of(
|
||||
Arguments.of(new VersionedProfile("version", "name", "avatar", "emoji", "about", "paymentAddress", "commitment".getBytes(StandardCharsets.UTF_8))),
|
||||
Arguments.of(new VersionedProfile("version", null, "avatar", "emoji", "about", "paymentAddress", "commitment".getBytes(StandardCharsets.UTF_8))),
|
||||
Arguments.of(new VersionedProfile("version", "name", null, "emoji", "about", "paymentAddress", "commitment".getBytes(StandardCharsets.UTF_8))),
|
||||
Arguments.of(new VersionedProfile("version", "name", "avatar", null, "about", "paymentAddress", "commitment".getBytes(StandardCharsets.UTF_8))),
|
||||
Arguments.of(new VersionedProfile("version", "name", "avatar", "emoji", null, "paymentAddress", "commitment".getBytes(StandardCharsets.UTF_8))),
|
||||
Arguments.of(new VersionedProfile("version", "name", "avatar", "emoji", "about", null, "commitment".getBytes(StandardCharsets.UTF_8)))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void delete() {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
final VersionedProfile firstProfile =
|
||||
new VersionedProfile("version1", "name", "avatar", "emoji", "about", "paymentAddress", "commitment".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
final VersionedProfile secondProfile =
|
||||
new VersionedProfile("version2", "name", "avatar", "emoji", "about", "paymentAddress", "commitment".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
profiles.set(uuid, firstProfile);
|
||||
profiles.set(uuid, secondProfile);
|
||||
|
||||
profiles.delete(uuid, firstProfile.getVersion()).join();
|
||||
|
||||
assertTrue(profiles.get(uuid, firstProfile.getVersion()).isEmpty());
|
||||
assertTrue(profiles.get(uuid, secondProfile.getVersion()).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,22 +5,13 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.opentable.db.postgres.embedded.LiquibasePreparer;
|
||||
import com.opentable.db.postgres.junit5.EmbeddedPostgresExtension;
|
||||
import com.opentable.db.postgres.junit5.PreparedDbExtension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.jdbi.v3.core.Jdbi;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.whispersystems.textsecuregcm.configuration.CircuitBreakerConfiguration;
|
||||
import org.whispersystems.textsecuregcm.util.Pair;
|
||||
|
||||
public class ProfilesPostgresTest extends ProfilesTest {
|
||||
|
||||
@@ -45,39 +36,4 @@ public class ProfilesPostgresTest extends ProfilesTest {
|
||||
protected ProfilesStore getProfilesStore() {
|
||||
return profiles;
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEach() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
VersionedProfile profileOne = new VersionedProfile("123", "foo", "avatarLocation", null, null,
|
||||
null, "aDigest".getBytes());
|
||||
VersionedProfile profileTwo = new VersionedProfile("345", "bar", "baz", null, null, null, "boof".getBytes());
|
||||
|
||||
profiles.set(uuid, profileOne);
|
||||
profiles.set(uuid, profileTwo);
|
||||
|
||||
final Set<Pair<UUID, VersionedProfile>> retrievedProfiles = new HashSet<>();
|
||||
|
||||
profiles.forEach((u, profile) -> retrievedProfiles.add(new Pair<>(u, profile)), 1);
|
||||
|
||||
assertEquals(Set.of(new Pair<>(uuid, profileOne), new Pair<>(uuid, profileTwo)), retrievedProfiles);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testForEachDeletedProfiles() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
VersionedProfile profileOne = new VersionedProfile("123", "foo", "avatarLocation", null, null,
|
||||
null, "aDigest".getBytes());
|
||||
VersionedProfile profileTwo = new VersionedProfile("345", "bar", "baz", null, null, null, "boof".getBytes());
|
||||
|
||||
profiles.set(uuid, profileOne);
|
||||
profiles.set(UUID.randomUUID(), profileTwo);
|
||||
profiles.deleteAll(uuid);
|
||||
|
||||
final List<Pair<UUID, String>> deletedProfiles = new ArrayList<>();
|
||||
|
||||
profiles.forEachDeletedProfile((u, version) -> deletedProfiles.add(new Pair<>(u, version)), 2);
|
||||
|
||||
assertEquals(List.of(new Pair<>(uuid, profileOne.getVersion())), deletedProfiles);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user