|
|
|
@ -4,37 +4,18 @@ import foundation.pEp.jniadapter.Blob;
|
|
|
|
|
import foundation.pEp.jniadapter.Engine;
|
|
|
|
|
import foundation.pEp.jniadapter.Identity;
|
|
|
|
|
import foundation.pEp.jniadapter.Message;
|
|
|
|
|
import foundation.pEp.jniadapter.test.utils.model.*;
|
|
|
|
|
import foundation.pEp.pitytest.AbstractTestContext;
|
|
|
|
|
import foundation.pEp.pitytest.TestLogger;
|
|
|
|
|
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public class ABAliceTestContext extends CTXBase {
|
|
|
|
|
// FsMQManager transport;
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void init() throws Throwable {
|
|
|
|
|
// super.init();
|
|
|
|
|
// transport = new FsMQManager(alice.address, "../resources/per-user-dir/alice/inbox");
|
|
|
|
|
// transport.clearOwnQueue();
|
|
|
|
|
// transport.addPeer(bob.address, "../resources/per-user-dir/bob/inbox");
|
|
|
|
|
//
|
|
|
|
|
// transport.broadcastSigOnline();
|
|
|
|
|
// transport.waitForPeerOnline(bob.address);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class CTXBase extends AbstractTestContext {
|
|
|
|
|
// Basic
|
|
|
|
|
public Engine engine;
|
|
|
|
|
public TestCallbacks callbacks;
|
|
|
|
|
|
|
|
|
|
public TestModel model = new TestModel();
|
|
|
|
|
|
|
|
|
|
// Identities
|
|
|
|
|
public Identity alice;
|
|
|
|
|
public Identity bob;
|
|
|
|
@ -42,22 +23,11 @@ public class CTXBase extends AbstractTestContext {
|
|
|
|
|
|
|
|
|
|
// Keys
|
|
|
|
|
public byte[] keyAlicePub;
|
|
|
|
|
private String filenameAlicePub = "../resources/test_keys/alice-pub-DE5DF92A358DCE5F.asc";
|
|
|
|
|
|
|
|
|
|
public byte[] keyAliceSec;
|
|
|
|
|
private String filenameAliceSec = "../resources/test_keys/alice-sec-DE5DF92A358DCE5F.asc";
|
|
|
|
|
|
|
|
|
|
public byte[] keyAlicePubPassphrase;
|
|
|
|
|
private String filenameAlicePubPassphrase = "../resources/test_keys/alice-passphrase-pub-BCBAC48800026D6F.asc";
|
|
|
|
|
|
|
|
|
|
public byte[] keyAliceSecPassphrase;
|
|
|
|
|
private String filenameAliceSecPassphrase = "../resources/test_keys/alice-passphrase-sec-BCBAC48800026D6F.asc";
|
|
|
|
|
|
|
|
|
|
public byte[] keyBobPub;
|
|
|
|
|
private String filenameBobPub = "../resources/test_keys/bob-pub.asc";
|
|
|
|
|
|
|
|
|
|
public byte[] keyBobSec;
|
|
|
|
|
private String filenameBobSec = "../resources/test_keys/bob-sec.asc";
|
|
|
|
|
|
|
|
|
|
// Messages
|
|
|
|
|
public Message msgAliceToAlice;
|
|
|
|
@ -67,7 +37,7 @@ public class CTXBase extends AbstractTestContext {
|
|
|
|
|
public Message.Direction msgDirOutgoing = Message.Direction.Outgoing;
|
|
|
|
|
public Blob attachmentTiny;
|
|
|
|
|
public Blob attachment1KB;
|
|
|
|
|
public AttachmentList attachmentList = new AttachmentList(3,10000);
|
|
|
|
|
public AttachmentList attachmentList = new AttachmentList(3, 10000);
|
|
|
|
|
|
|
|
|
|
public CTXBase init() throws Throwable {
|
|
|
|
|
callbacks = new TestCallbacks();
|
|
|
|
@ -75,6 +45,18 @@ public class CTXBase extends AbstractTestContext {
|
|
|
|
|
engine.setMessageToSendCallback(callbacks);
|
|
|
|
|
engine.setNotifyHandshakeCallback(callbacks);
|
|
|
|
|
|
|
|
|
|
setupModel();
|
|
|
|
|
alice = model.get(Role.ALICE).pEpIdent;
|
|
|
|
|
bob = model.get(Role.BOB).pEpIdent;
|
|
|
|
|
carol = model.get(Role.CAROL).pEpIdent;
|
|
|
|
|
|
|
|
|
|
keyAlicePub = model.get(Role.ALICE).getDefaultKey(false).getKeyPub();
|
|
|
|
|
keyAliceSec = model.get(Role.ALICE).getDefaultKey(false).getKeySec();
|
|
|
|
|
keyAlicePubPassphrase = model.get(Role.ALICE).getDefaultKey(true).getKeyPub();
|
|
|
|
|
keyAliceSecPassphrase = model.get(Role.ALICE).getDefaultKey(true).getKeySec();
|
|
|
|
|
keyBobPub = model.get(Role.BOB).getDefaultKey(false).getKeyPub();
|
|
|
|
|
keyBobSec = model.get(Role.BOB).getDefaultKey(false).getKeySec();
|
|
|
|
|
|
|
|
|
|
TestLogger.logH2("Machine directory: ");
|
|
|
|
|
TestLogger.log(engine.getMachineDirectory());
|
|
|
|
|
TestLogger.logH2("User directory:");
|
|
|
|
@ -82,49 +64,65 @@ public class CTXBase extends AbstractTestContext {
|
|
|
|
|
|
|
|
|
|
attachmentTiny = AdapterTestUtils.makeNewTestBlob("attachment1", "attachment1.txt", "text/plain");
|
|
|
|
|
attachment1KB = AdapterTestUtils.makeNewTestBlob(1000, "att with size 1KB", null);
|
|
|
|
|
|
|
|
|
|
alice = new Identity();
|
|
|
|
|
alice.username = "Alice pEp Test";
|
|
|
|
|
alice.user_id = "23";
|
|
|
|
|
alice.address = "alice@peptest.org";
|
|
|
|
|
alice.me = true;
|
|
|
|
|
|
|
|
|
|
bob = new Identity();
|
|
|
|
|
bob.username = "Bob pEp Test";
|
|
|
|
|
bob.user_id = "42";
|
|
|
|
|
bob.address = "bob@peptest.org";
|
|
|
|
|
|
|
|
|
|
carol = new Identity();
|
|
|
|
|
carol.username = "Carol pEp Test";
|
|
|
|
|
carol.user_id = "65";
|
|
|
|
|
carol.address = "carol@peptest.org";
|
|
|
|
|
|
|
|
|
|
msgAliceToAlice = AdapterTestUtils.makeNewTestMessage(alice, alice, Message.Direction.Outgoing);
|
|
|
|
|
msgAliceToBob = AdapterTestUtils.makeNewTestMessage(alice, bob, Message.Direction.Outgoing);
|
|
|
|
|
|
|
|
|
|
Path path;
|
|
|
|
|
path = Paths.get(filenameBobPub);
|
|
|
|
|
try {
|
|
|
|
|
keyBobPub = Files.readAllBytes(path);
|
|
|
|
|
|
|
|
|
|
path = Paths.get(filenameBobSec);
|
|
|
|
|
keyBobSec = Files.readAllBytes(path);
|
|
|
|
|
|
|
|
|
|
path = Paths.get(filenameAlicePub);
|
|
|
|
|
keyAlicePub = Files.readAllBytes(path);
|
|
|
|
|
|
|
|
|
|
path = Paths.get(filenameAliceSec);
|
|
|
|
|
keyAliceSec = Files.readAllBytes(path);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path = Paths.get(filenameAlicePubPassphrase);
|
|
|
|
|
keyAlicePubPassphrase = Files.readAllBytes(path);
|
|
|
|
|
private void setupModel() {
|
|
|
|
|
// Idents
|
|
|
|
|
{
|
|
|
|
|
model.add(new TestIdentity(Role.ALICE));
|
|
|
|
|
model.add(new TestIdentity(Role.BOB));
|
|
|
|
|
model.add(new TestIdentity(Role.CAROL));
|
|
|
|
|
}
|
|
|
|
|
// Nodes
|
|
|
|
|
{
|
|
|
|
|
TestNode tn = new TestNode(Node.NODE_A1);
|
|
|
|
|
tn.addOwnIdent(model.get(Role.ALICE));
|
|
|
|
|
model.add(tn);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
TestNode tn = new TestNode(Node.NODE_B1);
|
|
|
|
|
tn.addOwnIdent(model.get(Role.BOB));
|
|
|
|
|
model.add(tn);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
TestNode tn = new TestNode(Node.NODE_C1);
|
|
|
|
|
tn.addOwnIdent(model.get(Role.CAROL));
|
|
|
|
|
model.add(tn);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
TestNode tn = new TestNode(Node.NODE_A2);
|
|
|
|
|
tn.addOwnIdent(model.get(Role.ALICE));
|
|
|
|
|
model.add(tn);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
TestNode tn = new TestNode(Node.NODE_B2);
|
|
|
|
|
tn.addOwnIdent(model.get(Role.BOB));
|
|
|
|
|
model.add(tn);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
TestNode tn = new TestNode(Node.NODE_C2);
|
|
|
|
|
tn.addOwnIdent(model.get(Role.CAROL));
|
|
|
|
|
model.add(tn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path = Paths.get(filenameAliceSecPassphrase);
|
|
|
|
|
keyAliceSecPassphrase = Files.readAllBytes(path);
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
// Keys
|
|
|
|
|
{
|
|
|
|
|
String pathPub = "../resources/test_keys/alice-pub-DE5DF92A358DCE5F.asc";
|
|
|
|
|
String pathSec = "../resources/test_keys/alice-sec-DE5DF92A358DCE5F.asc";
|
|
|
|
|
String pathPubPP = "../resources/test_keys/alice-passphrase-pub-BCBAC48800026D6F.asc";
|
|
|
|
|
String pathSecPP = "../resources/test_keys/alice-passphrase-sec-BCBAC48800026D6F.asc";
|
|
|
|
|
new TestKeyPair(model.get(Role.ALICE), pathPub, pathSec, true);
|
|
|
|
|
new TestKeyPair(model.get(Role.ALICE), pathPubPP, pathSecPP, "passphrase_alice", true);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
String pathPub = "../resources/test_keys/bob-pub.asc";
|
|
|
|
|
String pathSec = "../resources/test_keys/bob-sec.asc";
|
|
|
|
|
new TestKeyPair(model.get(Role.BOB), pathPub, pathSec, true);
|
|
|
|
|
}
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|