mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
improvements after dev comments
This commit is contained in:
@@ -537,109 +537,6 @@ public class IntroductionIntegrationTest extends BriarIntegrationTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIntroductionToIdentitiesOfSameContact() throws Exception {
|
|
||||||
startLifecycles();
|
|
||||||
try {
|
|
||||||
// Get Identities
|
|
||||||
getDefaultIdentities();
|
|
||||||
author2 = authorFactory.createLocalAuthor(INTRODUCEE2,
|
|
||||||
TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
|
||||||
TestUtils.getRandomBytes(123));
|
|
||||||
identityManager1.registerLocalAuthor(author2);
|
|
||||||
|
|
||||||
// Add introducees' authors as contacts
|
|
||||||
contactId1 = contactManager0.addContact(author1,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true, true
|
|
||||||
);
|
|
||||||
contactId2 = contactManager0.addContact(author2,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true, true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = null;
|
|
||||||
ContactId contactId01 = contactManager1.addContact(author0,
|
|
||||||
author1.getId(), master, clock.currentTimeMillis(), false,
|
|
||||||
true, true
|
|
||||||
);
|
|
||||||
ContactId contactId02 = contactManager1.addContact(author0,
|
|
||||||
author2.getId(), master, clock.currentTimeMillis(), false,
|
|
||||||
true, true
|
|
||||||
);
|
|
||||||
// listen to events
|
|
||||||
addListeners(true, false);
|
|
||||||
|
|
||||||
// Add Transport Properties
|
|
||||||
TransportPropertyManager tpm0 = t0.getTransportPropertyManager();
|
|
||||||
TransportPropertyManager tpm1 = t1.getTransportPropertyManager();
|
|
||||||
TransportProperties tp = new TransportProperties(
|
|
||||||
Collections.singletonMap("key", "value"));
|
|
||||||
tpm0.mergeLocalProperties(TRANSPORT_ID, tp);
|
|
||||||
deliverMessage(sync0, contactId01, sync1, contactId1, "0 to 11");
|
|
||||||
deliverMessage(sync0, contactId02, sync1, contactId2, "0 to 12");
|
|
||||||
tpm1.mergeLocalProperties(TRANSPORT_ID, tp);
|
|
||||||
deliverMessage(sync1, contactId1, sync0, contactId01, "1 to 01");
|
|
||||||
deliverMessage(sync1, contactId2, sync0, contactId02, "1 to 02");
|
|
||||||
|
|
||||||
// make introduction
|
|
||||||
long time = clock.currentTimeMillis();
|
|
||||||
Contact introducee1 = contactManager0.getContact(contactId1);
|
|
||||||
Contact introducee2 = contactManager0.getContact(contactId2);
|
|
||||||
introductionManager0
|
|
||||||
.makeIntroduction(introducee1, introducee2, "Hi!", time);
|
|
||||||
|
|
||||||
// sync request messages
|
|
||||||
deliverMessage(sync0, contactId01, sync1, contactId1);
|
|
||||||
deliverMessage(sync0, contactId02, sync1, contactId2);
|
|
||||||
|
|
||||||
// wait for request to arrive
|
|
||||||
eventWaiter.await(TIMEOUT, 2);
|
|
||||||
assertTrue(listener1.requestReceived);
|
|
||||||
|
|
||||||
// sync responses
|
|
||||||
deliverMessage(sync1, contactId1, sync0, contactId01);
|
|
||||||
deliverMessage(sync1, contactId2, sync0, contactId02);
|
|
||||||
|
|
||||||
// wait for two responses to arrive
|
|
||||||
eventWaiter.await(TIMEOUT, 2);
|
|
||||||
assertTrue(listener0.response1Received);
|
|
||||||
assertTrue(listener0.response2Received);
|
|
||||||
|
|
||||||
// sync forwarded responses to introducees
|
|
||||||
deliverMessage(sync0, contactId01, sync1, contactId1);
|
|
||||||
deliverMessage(sync0, contactId02, sync1, contactId2);
|
|
||||||
|
|
||||||
// wait for "both" introducees to abort session
|
|
||||||
eventWaiter.await(TIMEOUT, 2);
|
|
||||||
assertTrue(listener1.aborted);
|
|
||||||
|
|
||||||
// sync abort message
|
|
||||||
deliverMessage(sync1, contactId1, sync0, contactId01);
|
|
||||||
deliverMessage(sync1, contactId2, sync0, contactId02);
|
|
||||||
|
|
||||||
// wait for introducer to abort session (gets event twice)
|
|
||||||
eventWaiter.await(TIMEOUT, 2);
|
|
||||||
assertTrue(listener0.aborted);
|
|
||||||
|
|
||||||
assertFalse(contactManager1
|
|
||||||
.contactExists(author1.getId(), author2.getId()));
|
|
||||||
assertFalse(contactManager1
|
|
||||||
.contactExists(author2.getId(), author1.getId()));
|
|
||||||
|
|
||||||
assertEquals(2, introductionManager0.getIntroductionMessages(
|
|
||||||
contactId1).size());
|
|
||||||
assertEquals(2, introductionManager0.getIntroductionMessages(
|
|
||||||
contactId2).size());
|
|
||||||
assertEquals(2, introductionManager1.getIntroductionMessages(
|
|
||||||
contactId01).size());
|
|
||||||
assertEquals(2, introductionManager1.getIntroductionMessages(
|
|
||||||
contactId02).size());
|
|
||||||
} finally {
|
|
||||||
stopLifecycles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSessionIdReuse() throws Exception {
|
public void testSessionIdReuse() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public interface SetupController {
|
|||||||
|
|
||||||
float estimatePasswordStrength(String password);
|
float estimatePasswordStrength(String password);
|
||||||
|
|
||||||
void storeAuthorInfo(String password, String nickName,
|
void storeAuthorInfo(String password, String nickname,
|
||||||
ResultHandler<Void> resultHandler);
|
ResultHandler<Void> resultHandler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class SetupControllerImpl extends PasswordControllerImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeAuthorInfo(final String password, final String nickName,
|
public void storeAuthorInfo(final String password, final String nickname,
|
||||||
final ResultHandler<Void> resultHandler) {
|
final ResultHandler<Void> resultHandler) {
|
||||||
cryptoExecutor.execute(new Runnable() {
|
cryptoExecutor.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -46,7 +46,7 @@ public class SetupControllerImpl extends PasswordControllerImpl
|
|||||||
databaseConfig.setEncryptionKey(key);
|
databaseConfig.setEncryptionKey(key);
|
||||||
String hex = encryptDatabaseKey(key, password);
|
String hex = encryptDatabaseKey(key, password);
|
||||||
storeEncryptedDatabaseKey(hex);
|
storeEncryptedDatabaseKey(hex);
|
||||||
databaseConfig.setAuthorNick(nickName);
|
databaseConfig.setAuthorNick(nickname);
|
||||||
resultHandler.onResult(null);
|
resultHandler.onResult(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user