mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Use strings rather than hashes to identify transports. Dev task #64.
This commit is contained in:
@@ -109,7 +109,7 @@ public class ProtocolIntegrationTest extends BriarTestCase {
|
||||
messageBody.getBytes("UTF-8"));
|
||||
messageIds = Arrays.asList(message.getId(), message1.getId());
|
||||
// Create some transport properties
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
transportProperties = new TransportProperties(Collections.singletonMap(
|
||||
"bar", "baz"));
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
subject, timestamp, raw);
|
||||
message1 = new TestMessage(messageId1, messageId, group, null,
|
||||
contentType, subject, timestamp, raw);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
transportProperties = new TransportProperties(Collections.singletonMap(
|
||||
"foo", "bar"));
|
||||
"bar", "baz"));
|
||||
contactId = new ContactId(234);
|
||||
contact = new Contact(contactId, author, localAuthorId);
|
||||
endpoint = new Endpoint(contactId, transportId, 123, true);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
random.nextBytes(raw);
|
||||
message = new TestMessage(messageId, null, group, author, contentType,
|
||||
subject, timestamp, raw);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
contactId = new ContactId(1);
|
||||
}
|
||||
|
||||
@@ -1320,8 +1320,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
long epoch1 = 123, latency1 = 234;
|
||||
long epoch2 = 345, latency2 = 456;
|
||||
boolean alice1 = true, alice2 = false;
|
||||
TransportId transportId1 = new TransportId(TestUtils.getRandomId());
|
||||
TransportId transportId2 = new TransportId(TestUtils.getRandomId());
|
||||
TransportId transportId1 = new TransportId("bar");
|
||||
TransportId transportId2 = new TransportId("baz");
|
||||
Endpoint ep1 = new Endpoint(contactId, transportId1, epoch1, alice1);
|
||||
Endpoint ep2 = new Endpoint(contactId, transportId2, epoch2, alice2);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import static org.briarproject.api.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.api.AuthorConstants.MAX_SIGNATURE_LENGTH;
|
||||
import static org.briarproject.api.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT;
|
||||
import static org.briarproject.api.TransportPropertyConstants.MAX_PROPERTY_LENGTH;
|
||||
import static org.briarproject.api.TransportPropertyConstants.MAX_TRANSPORT_ID_LENGTH;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_BODY_LENGTH;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_CONTENT_TYPE_LENGTH;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_GROUP_NAME_LENGTH;
|
||||
@@ -174,7 +175,8 @@ public class ConstantsTest extends BriarTestCase {
|
||||
p.put(key, value);
|
||||
}
|
||||
// Create a maximum-length transport update
|
||||
TransportId id = new TransportId(TestUtils.getRandomId());
|
||||
String idString = TestUtils.createRandomString(MAX_TRANSPORT_ID_LENGTH);
|
||||
TransportId id = new TransportId(idString);
|
||||
TransportUpdate u = new TransportUpdate(id, p, Long.MAX_VALUE);
|
||||
// Serialise the update
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase {
|
||||
packetWriterFactory = i.getInstance(PacketWriterFactory.class);
|
||||
contactId = new ContactId(234);
|
||||
messageId = new MessageId(TestUtils.getRandomId());
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
secret = new byte[32];
|
||||
new Random().nextBytes(secret);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
public SimplexMessagingIntegrationTest() throws Exception {
|
||||
GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||
group = new Group(groupId, "Group", new byte[GROUP_SALT_LENGTH]);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
// Create matching secrets for Alice and Bob
|
||||
initialSecret = new byte[32];
|
||||
new Random().nextBytes(initialSecret);
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.plugins.duplex.DuplexPlugin;
|
||||
@@ -44,25 +43,23 @@ public class PluginManagerImplTest extends BriarTestCase {
|
||||
final SimplexPluginFactory simplexFactory =
|
||||
context.mock(SimplexPluginFactory.class);
|
||||
final SimplexPlugin simplexPlugin = context.mock(SimplexPlugin.class);
|
||||
final TransportId simplexId = new TransportId(TestUtils.getRandomId());
|
||||
final TransportId simplexId = new TransportId("simplex");
|
||||
final long simplexLatency = 12345;
|
||||
final SimplexPluginFactory simplexFailFactory =
|
||||
context.mock(SimplexPluginFactory.class, "simplexFailFactory");
|
||||
final SimplexPlugin simplexFailPlugin =
|
||||
context.mock(SimplexPlugin.class, "simplexFailPlugin");
|
||||
final TransportId simplexFailId =
|
||||
new TransportId(TestUtils.getRandomId());
|
||||
final TransportId simplexFailId = new TransportId("simplex1");
|
||||
final long simplexFailLatency = 23456;
|
||||
// Two duplex plugin factories: one creates a plugin, the other fails
|
||||
final DuplexPluginFactory duplexFactory =
|
||||
context.mock(DuplexPluginFactory.class);
|
||||
final DuplexPlugin duplexPlugin = context.mock(DuplexPlugin.class);
|
||||
final TransportId duplexId = new TransportId(TestUtils.getRandomId());
|
||||
final TransportId duplexId = new TransportId("duplex");
|
||||
final long duplexLatency = 34567;
|
||||
final DuplexPluginFactory duplexFailFactory =
|
||||
context.mock(DuplexPluginFactory.class, "duplexFailFactory");
|
||||
final TransportId duplexFailId =
|
||||
new TransportId(TestUtils.getRandomId());
|
||||
final TransportId duplexFailId = new TransportId("duplex1");
|
||||
context.checking(new Expectations() {{
|
||||
// First simplex plugin
|
||||
oneOf(simplexPluginConfig).getFactories();
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.transport.ConnectionRegistry;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ConnectionRegistryImplTest extends BriarTestCase {
|
||||
@@ -20,8 +18,8 @@ public class ConnectionRegistryImplTest extends BriarTestCase {
|
||||
public ConnectionRegistryImplTest() {
|
||||
contactId = new ContactId(1);
|
||||
contactId1 = new ContactId(2);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId1 = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
transportId1 = new TransportId("id1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -19,7 +18,6 @@ import org.briarproject.api.transport.ConnectionContext;
|
||||
import org.briarproject.api.transport.ConnectionRecogniser;
|
||||
import org.briarproject.api.transport.Endpoint;
|
||||
import org.briarproject.api.transport.TemporarySecret;
|
||||
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.Test;
|
||||
@@ -38,7 +36,7 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
|
||||
public KeyManagerImplTest() {
|
||||
contactId = new ContactId(234);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
secret0 = new byte[32];
|
||||
secret1 = new byte[32];
|
||||
secret2 = new byte[32];
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -22,7 +21,6 @@ import org.briarproject.api.transport.ConnectionRecogniser;
|
||||
import org.briarproject.api.transport.Endpoint;
|
||||
import org.briarproject.api.transport.TemporarySecret;
|
||||
import org.briarproject.util.ByteUtils;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
@@ -45,7 +43,7 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
|
||||
public KeyRotationIntegrationTest() {
|
||||
contactId = new ContactId(234);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
secret0 = new byte[32];
|
||||
secret1 = new byte[32];
|
||||
secret2 = new byte[32];
|
||||
|
||||
@@ -6,7 +6,6 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import java.util.Random;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -15,7 +14,6 @@ import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.transport.ConnectionContext;
|
||||
import org.briarproject.api.transport.TemporarySecret;
|
||||
import org.briarproject.util.ByteUtils;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
@@ -26,8 +24,7 @@ import org.junit.Test;
|
||||
public class TransportConnectionRecogniserTest extends BriarTestCase {
|
||||
|
||||
private final ContactId contactId = new ContactId(234);
|
||||
private final TransportId transportId =
|
||||
new TransportId(TestUtils.getRandomId());
|
||||
private final TransportId transportId = new TransportId("id");
|
||||
|
||||
@Test
|
||||
public void testAddAndRemoveSecret() {
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Random;
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestLifecycleModule;
|
||||
import org.briarproject.TestSystemModule;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.crypto.AuthenticatedCipher;
|
||||
@@ -56,7 +55,7 @@ public class TransportIntegrationTest extends BriarTestCase {
|
||||
crypto = i.getInstance(CryptoComponent.class);
|
||||
connectionWriterFactory = i.getInstance(ConnectionWriterFactory.class);
|
||||
contactId = new ContactId(234);
|
||||
transportId = new TransportId(TestUtils.getRandomId());
|
||||
transportId = new TransportId("id");
|
||||
frameCipher = crypto.getFrameCipher();
|
||||
random = new Random();
|
||||
// Since we're sending frames to ourselves, we only need outgoing keys
|
||||
|
||||
Reference in New Issue
Block a user