Browse Source

Fix encrypt feature tests

1.1.101
Chris Fuertes 3 years ago
parent
commit
d628abdd20
3 changed files with 65 additions and 14 deletions
  1. +2
    -1
      chrome/content/modules/pEpAdapter.js
  2. +1
    -1
      chrome/content/modules/pEpServer.js
  3. +62
    -12
      tests/features/encrypt_feature_spec.js

+ 2
- 1
chrome/content/modules/pEpAdapter.js View File

@ -112,8 +112,9 @@ class pEpAdapter {
}
async encrypt(subject, body, from, to = [], stringlist = [], encodingFormat = ENC_FORMAT_PEP) {
let msgId = PEP_PREFIX + String(this.requestId);
let message = new pEpAdapter.pEpMessage(msgId, subject, body, from, to, DIR_OUTGOING);
let message = new pEpAdapter.pEpMessage(msgId, subject, body, from, to, DIR_OUTGOING, encodingFormat);
let params = [
message,


+ 1
- 1
chrome/content/modules/pEpServer.js View File

@ -247,7 +247,7 @@ class pEpServer {
if (that.retryCount < MAX_RETRY_ATTEMPTS) {
that.registerListener()
.then(() => {
that.callPepAdapter(SERVER_TYPE_CALL_FUNC, functionName, paramsArr, loadListener, errorListener, deferred);
that.callPepAdapter(SERVER_TYPE_CALL_FUNC, functionName, paramsArr);
});
}
else {


+ 62
- 12
tests/features/encrypt_feature_spec.js View File

@ -3,6 +3,7 @@ let {describe, it, before, beforeEach}= require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let expect = chai.expect;
let assert = chai.assert;
let pEpAdapter = require ( '../../chrome/content/modules/pEpAdapter');
let pEpServer = require ( '../../chrome/content/modules/pEpServer');
@ -106,38 +107,87 @@ describe('Encrypte Feature', () => {
let from, to, subject, body, pEpMode;
//from = {user_id: 1, username: "Fromer", address: "from@test.com", fingerprint: "fp_from"};
//to = [{user_id: 99, username: "Toer", address: "to@test.com", fingerprint: "fp_to"}];
from = "from@test.com";
to = "to@test.com";
from = "cfg@pep.security";
to = "cfg@pep.security";
subject = "subject";
body = "Not Encrypted Message";
let server = new pEpServer(log, core, os, env, path, connectionInfo, XhrQueue, files, utils);
let adapter = new pEpAdapter(console.log, server);
result = adapter.encrypt(subject, body, from, to);
result = adapter.encrypt(subject, body, from, [to]);
});
it('should resolve into an encrypted mail', () => {
return result.should.become({});
return result.should.be.fulfilled;
return result.should.become({
"attachments": [
{
"mime_type": "application/pgp-encrypted",
"size": 10,
"value": "VmVyc2lvbjogMQ==",
},
{
"filename": "file://msg.asc",
"mime_type": "application/octet-stream",
"size": 3413,
"value": "LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpoUUVNQXgwcGFGQ3JmWVFVQVFmOUhMeEM5TkphTDJjMTViYis1RDk1TWlHYnZKZE9ZQUpQWlJMTzJlVWFrZUZtCm9VNndtWW5zS1k0cGhOOU9tbG11VXNjVEdOQlI4dHlrem91bE9ObEVZYlFrZjgzL0IxaFF4dVM5Y0s1b0dXRjYKMCsrMVBsR29HY2g0RUFoRFU5Wlh4NHlMNmY4cW5WTHJtOXRlU2tNVmNNREpsOThzTUplNkIvTGxqNUY3d3FpdQpVUzFxZ01sb25pNzdaSEtSVWpCVEM2M2JhOFF3VkdlV1JpRVVVSTZtS05ySFI2Ri9TRnlGemUraHkwZTV0bXd5CnROWmtGVURDbGgwTmZ1NmVZUnZCTy9LdWpTTmgxRGI0Ny84SGNqUlh6UzJUMlhsbXA0dGJoZXFORjdabnBXcUsKNVQxdFNlL3krdGFHbHhnWnBtVjRQZ0Y0UUkvYnJOOUhsRnkxeW1ZcXRkTHJBUURrWUFWWTBUODBQTHROdXZvMgo0enNEcENYTVl5dUtMQXdGNS9VTUdkVFpFdXJaV3FJZy8yVDhvVDVpOFBoM0RUbnd3blJ3RkQ1bkhRNHVmdlZGCjFBYThRN2Zrc1pBbzViVWZjV0IvZUpWanU5ejBhek92YTlnNXJXS2o0UGZ2REV3ZWJaWnFWL09IZEhINWJXcDIKOHk0Q1kyalhsVDhCdDlnek4zdVIxRXZ1T2lEOEFDZVpYU3JsWjYrcTJ0L0VmQWgrZExuSnAwVjltNGNaTzJkagpqbEdhc3lOcVFJN2wzMlBFQ1BN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0laVkhFZTBrTWVkTy9oZWo4CjJGSGRvaVNYOCthMjNZUHRrbDdOaThGOEZybEFldEFHN1YrOWpnY3Q1ckpvYzBQeW1NQVlRSHVuU04wQWpWOTEKbjAySGZYZGFsT0owcktGUlUrTTZEdU0wc2g2bDJqeEE2WG9YbnJCY2lZQjRydkZhT014REMxdGZOV3FvaWVjVApKY2V4dC9Od3NYRlMwQ0FSYitSZ1ZFU1lNZEUrZk9ub2NtQWRJTzBaYVpxNHRsdk11NGdTd0poRkMraXpkRXVoCm1oa2JQdFZ3bk93SU9mNjI4OEZZczgveVQ2MmxIMVN2RzdpTkRUMG4yTXc5d1I0YXpnMDRrVGgvVkFra2MwWDkKK3J1TlB1OXdvZnFPeVkwb2puWjlkWXM3aER3VGM4OWU1L0NmcHJPdjdXS1V2SGQ1NGlJZElnUVpmZys3SCsrdApSNExFVVZFS0hFYzVVYXozMkFKa011UEN1QlZBdkgxQXZKbz0KPStZVjIKLS0tLS1FTkQgUEdQIE1FU1NBR0UtLS0tLQo=",
},
],
"dir": 1,
"enc_format": 3,
"from": {
"address": "cfg@pep.security",
"comm_type": 255,
"fpr": "EDA8D5406CFFAC5FE56A53BBCFFDF76F6C2F959D",
"user_id": "pEp_own_userId",
"username": "anonymous"
},
"id": "pEp.PMV03L.0TXZAWEXL7KP0.B4FEA6B8-FFD4-4578-A2B7-CDE7C40456F8@pep.security",
"longmsg": "this message was encrypted with p≡p https://pEp-project.org",
"opt_fields": [
{
"key": "X-pEp-Version",
"value": "2.0",
}
],
"shortmsg": "p≡p",
"to": [
{
"address": "cfg@pep.security",
"comm_type": 255,
"fpr": "EDA8D5406CFFAC5FE56A53BBCFFDF76F6C2F959D",
"user_id": "pEp_own_userId",
"username": "anonymous"
}
]
});
});
it("should have at least 2 attachments", () => {
return result.should.hasOwnProperty("attachments");
return result.attachments.length.should.be.gt(2);
return result.should.eventually.have.property("attachments").then((attachments) => {
attachments.length.should.be.gte(2);
attachments[0].mime_type.should.be.equal("application/pgp-encrypted");
attachments[1].mime_type.should.be.equal("application/octet-stream");
attachments[1].filename.should.be.equal("file://msg.asc");
});
});
it("should have mime type pgp-encrypted", () => {
return result.attachments[1].filename.should.be.equal("file://msg.asc");
});
it("should have x-pEp-version", () => {
return result.opt_fields[0].key.equal("X-pEp-Version");
return result.should.eventually.have.property("opt_fields").then((opt_fields) => {
opt_fields[0].key.should.be.equal("X-pEp-Version");
});
});
it("should have pEp subject", () => {
return result.shortmsg.equal("p≡p");
return result.should.eventually.have.property("shortmsg").then((shortmsg) => {
shortmsg.should.be.equal("p≡p");
});
});
it('should have enctypted body', () => {
result.longmsg.equal("this message was encrypted with p≡p https://pEp-project.org");
return result.should.eventually.have.property("longmsg").then((longmsg) => {
longmsg.should.be.equal("this message was encrypted with p≡p https://pEp-project.org");
});
});
});
});

Loading…
Cancel
Save