mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Move local author creation into IdentityManager.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.briarproject.briar.feed;
|
||||
|
||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.contact.ContactModule;
|
||||
import org.briarproject.bramble.crypto.CryptoExecutorModule;
|
||||
@@ -47,8 +49,12 @@ public class FeedManagerIntegrationTest extends BriarTestCase {
|
||||
component.inject(this);
|
||||
injectEagerSingletons(component);
|
||||
|
||||
IdentityManager identityManager = component.getIdentityManager();
|
||||
LocalAuthor localAuthor = identityManager.createLocalAuthor("feedTest");
|
||||
identityManager.registerLocalAuthor(localAuthor);
|
||||
|
||||
lifecycleManager = component.getLifecycleManager();
|
||||
lifecycleManager.startServices("feedTest");
|
||||
lifecycleManager.startServices();
|
||||
lifecycleManager.waitForStartup();
|
||||
|
||||
feedManager = component.getFeedManager();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.briar.feed;
|
||||
|
||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.client.ClientModule;
|
||||
import org.briarproject.bramble.contact.ContactModule;
|
||||
@@ -76,6 +77,8 @@ interface FeedManagerIntegrationTestComponent {
|
||||
|
||||
void inject(VersioningModule.EagerSingletons init);
|
||||
|
||||
IdentityManager getIdentityManager();
|
||||
|
||||
LifecycleManager getLifecycleManager();
|
||||
|
||||
FeedManager getFeedManager();
|
||||
|
||||
@@ -44,7 +44,6 @@ import java.io.InputStream;
|
||||
import static org.briarproject.bramble.api.transport.TransportConstants.TAG_LENGTH;
|
||||
import static org.briarproject.bramble.test.TestPluginConfigModule.MAX_LATENCY;
|
||||
import static org.briarproject.bramble.test.TestPluginConfigModule.TRANSPORT_ID;
|
||||
import static org.briarproject.bramble.test.TestUtils.getLocalAuthor;
|
||||
import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getTestDirectory;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -58,8 +57,6 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
private final File bobDir = new File(testDir, "bob");
|
||||
private final SecretKey master = getSecretKey();
|
||||
private final long timestamp = System.currentTimeMillis();
|
||||
private final LocalAuthor aliceAuthor = getLocalAuthor();
|
||||
private final LocalAuthor bobAuthor = getLocalAuthor();
|
||||
|
||||
private SimplexMessagingIntegrationTestComponent alice, bob;
|
||||
|
||||
@@ -76,6 +73,11 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testWriteAndRead() throws Exception {
|
||||
// Create the identities
|
||||
LocalAuthor aliceAuthor =
|
||||
alice.getIdentityManager().createLocalAuthor("Alice");
|
||||
LocalAuthor bobAuthor =
|
||||
bob.getIdentityManager().createLocalAuthor("Bob");
|
||||
// Set up the devices and get the contact IDs
|
||||
ContactId bobId = setUp(alice, aliceAuthor, bobAuthor, true);
|
||||
ContactId aliceId = setUp(bob, bobAuthor, aliceAuthor, false);
|
||||
@@ -98,13 +100,13 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
|
||||
private ContactId setUp(SimplexMessagingIntegrationTestComponent device,
|
||||
LocalAuthor local, Author remote, boolean alice) throws Exception {
|
||||
// Start the lifecycle manager
|
||||
LifecycleManager lifecycleManager = device.getLifecycleManager();
|
||||
lifecycleManager.startServices(null);
|
||||
lifecycleManager.waitForStartup();
|
||||
// Add an identity for the user
|
||||
IdentityManager identityManager = device.getIdentityManager();
|
||||
identityManager.registerLocalAuthor(local);
|
||||
// Start the lifecycle manager
|
||||
LifecycleManager lifecycleManager = device.getLifecycleManager();
|
||||
lifecycleManager.startServices();
|
||||
lifecycleManager.waitForStartup();
|
||||
// Add the other user as a contact
|
||||
ContactManager contactManager = device.getContactManager();
|
||||
return contactManager.addContact(remote, local.getId(), master,
|
||||
|
||||
@@ -160,8 +160,8 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
||||
validationWaiter = new Waiter();
|
||||
deliveryWaiter = new Waiter();
|
||||
|
||||
createAndRegisterIdentities();
|
||||
startLifecycles();
|
||||
getDefaultIdentities();
|
||||
listenToEvents();
|
||||
addDefaultContacts();
|
||||
}
|
||||
@@ -193,9 +193,9 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
||||
lifecycleManager0 = c0.getLifecycleManager();
|
||||
lifecycleManager1 = c1.getLifecycleManager();
|
||||
lifecycleManager2 = c2.getLifecycleManager();
|
||||
lifecycleManager0.startServices(AUTHOR0);
|
||||
lifecycleManager1.startServices(AUTHOR1);
|
||||
lifecycleManager2.startServices(AUTHOR2);
|
||||
lifecycleManager0.startServices();
|
||||
lifecycleManager1.startServices();
|
||||
lifecycleManager2.startServices();
|
||||
lifecycleManager0.waitForStartup();
|
||||
lifecycleManager1.waitForStartup();
|
||||
lifecycleManager2.waitForStartup();
|
||||
@@ -230,10 +230,13 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
||||
}
|
||||
}
|
||||
|
||||
private void getDefaultIdentities() throws DbException {
|
||||
author0 = identityManager0.getLocalAuthor();
|
||||
author1 = identityManager1.getLocalAuthor();
|
||||
author2 = identityManager2.getLocalAuthor();
|
||||
private void createAndRegisterIdentities() {
|
||||
author0 = identityManager0.createLocalAuthor(AUTHOR0);
|
||||
identityManager0.registerLocalAuthor(author0);
|
||||
author1 = identityManager1.createLocalAuthor(AUTHOR1);
|
||||
identityManager1.registerLocalAuthor(author1);
|
||||
author2 = identityManager2.createLocalAuthor(AUTHOR2);
|
||||
identityManager2.registerLocalAuthor(author2);
|
||||
}
|
||||
|
||||
protected void addDefaultContacts() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user