Browse Source

Move forward Decrypt/Encrypt

1.1.101
Chris Fuertes 3 years ago
parent
commit
4fe0cb910e
24 changed files with 842 additions and 122 deletions
  1. +10
    -0
      .mocharc.json
  2. +1
    -0
      chrome/chrome.manifest
  3. +39
    -3
      chrome/content/modules/pEp.js
  4. +188
    -0
      chrome/content/modules/pEpAdapter.js
  5. +30
    -12
      chrome/content/modules/pEpServer.js
  6. +2
    -2
      chrome/content/modules/pepencrypter.js
  7. +3
    -2
      chrome/content/modules/pepidentity.js
  8. +22
    -2
      chrome/content/modules/pepmessage.js
  9. +0
    -1
      chrome/content/modules/utils.js
  10. +1
    -1
      chrome/content/modules/xhrQueue.js
  11. +2
    -2
      chrome/content/pepmessenger.js
  12. +2
    -2
      chrome/content/pepmessenger.xul
  13. +52
    -0
      chrome/content/pepmessengercompose.js
  14. +7
    -1
      chrome/content/pepmessengercompose.xul
  15. +215
    -0
      chrome/content/pepmsghdrview.js
  16. +22
    -0
      chrome/content/pepmsghdrview.xul
  17. +6
    -0
      package-lock.json
  18. +4
    -3
      package.json
  19. +6
    -0
      tests/config/testSetup.js
  20. +99
    -0
      tests/features/decrypt_feature_spec.js
  21. +123
    -82
      tests/features/encrypt_feature_spec.js
  22. +2
    -6
      tests/features/get_version_feature_spec.js
  23. +1
    -2
      tests/mocha.opts
  24. +5
    -1
      tests/unit/pepserver_spec.js

+ 10
- 0
.mocharc.json View File

@ -0,0 +1,10 @@
{
"diff": true,
"extension": ["js"],
"opts": "./test/mocha.opts",
"package": "./package.json",
"reporter": "spec",
"slow": 75,
"timeout": 2000,
"ui": "bdd"
}

+ 1
- 0
chrome/chrome.manifest View File

@ -1,4 +1,5 @@
content p4t content/
overlay chrome://messenger/content/messenger.xul chrome://p4t/content/pepmessenger.xul
overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://p4t/content/pepmsghdrview.xul
overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://p4t/content/pepmessengercompose.xul

+ 39
- 3
chrome/content/modules/pEp.js View File

@ -130,15 +130,51 @@ class pEp {
return result.api_version;
}
encryptMail() {
/**
* Function called on send mail
*/
async encryptMail(subject = "", body, from, to) {
this.log("pEp: encryptMail()", "subject:", subject, "body:", body, "from:", from, "to:",to);
let result = await this.adapter.encrypt(subject, body, from, to);
return result;
}
decryptMail() {
/**
* Function called on open mail
*/
async decryptMail(mail, currentHeaderData) {
this.log("pEp: decryptMail()", currentHeaderData);
let from = {
user_id: "95E4A594",
username: "Chris",
address: "cfg@pep.security",
fingerprint: "B277 5D7B 919C 9E28 EC1B 9B49 2C0E 8DE5 95E4 A594"
};
let to = [{
user_id: "95E4A594",
username: "Chris",
address: "cfg@pep.security",
fingerprint: "B277 5D7B 919C 9E28 EC1B 9B49 2C0E 8DE5 95E4 A594"
}];
let cc = null;
let replyTo = null;
// send to pEpAdapter
let result = await this.adapter.decrypt("pEp", mail, from, to, cc, replyTo);
return result;
}
checkPrivacy() {
}
async getPrivacyColorFromRating( rating ) {
return await this.adapter.color_from_rating(rating);
}
showTrustwords() {
// TODO Trustwords pending to implement
}


+ 188
- 0
chrome/content/modules/pEpAdapter.js View File

@ -2,12 +2,29 @@ const EXPORTED_SYMBOLS =[ "pEpAdapter" ];
const SERVER_TYPE_CALL_FUNC = "callFunction";
const API_METHOD_SERVER_VERSION = "serverVersion";
const API_METHOD_DECRYPT = "decrypt_message";
const API_METHOD_ENCRYPT = "encrypt_message";
const DIR_INCOMING = 0;
const DIR_OUTGOING = 1;
const ENC_FORMAT_PEP = 4;
const PEP_PREFIX = "pEp-";
const RATING_COLOR_GREY = "grey";
const RATING_COLOR_RED = "red";
const RATING_COLOR_GREEN = "green";
const RATING_COLOR_YELLOW = "yellow";
if(typeof btoa === "undefined") {
var btoa = require('btoa');
}
class pEpAdapter {
constructor(log, server){
this.log = log;
this.server = server;
this.requestId = 0;
}
async serverVersion() {
@ -29,8 +46,179 @@ class pEpAdapter {
return null;
}
}
async decrypt(subject, body, sender = "*", to, cc, replyTo) {
this.log("pEpAdapter.js: decrypt()");
this.requestId++;
let msgId = PEP_PREFIX + this.requestId;
subject = "pEp"; // CHECK
let message = new pEpAdapter.pEpMessage(msgId, subject, body, sender, to, DIR_INCOMING);
if (cc) {
message.cc = cc;
}
if (replyTo) {
message.reply_to = replyTo;
}
//message.longmsg = "";
// message.addAttachment(btoa(body), body.length);
let params = [
message,
["OP"], // message output
["OP"], // stringlist output
["OP"], // rating output
["OP"] // flags output
];
console.debug(params);
console.debug(params[0].attachments);
try {
return await this.server.callPepAdapter(
SERVER_TYPE_CALL_FUNC,
API_METHOD_DECRYPT,
params,
response => {
let result = response.result.outParams;
this.log("pEpAdapter.js: decrypt() success: ", result);
return {
longmsg: result[3].longmsg,
shortmsg: result[3].shortmsg,
persons: {
from: result[3].from,
to: result[3].to,
cc: result[3].cc,
reply_to: result[3].reply_to
},
rating: result[1].rating,
fpr: result[2]
}
},
err => {
this.log("this is an error", err);
return null;
}
);
} catch (e) {
this.log("pEpAdapter.js: decrypt() error: ", e);
return null;
}
}
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 params = [
message,
[],
["OP"],
encodingFormat,
0
];
let response;
try {
response = await this.server.callPepAdapter(
SERVER_TYPE_CALL_FUNC,
API_METHOD_ENCRYPT,
params,
response => response.result.outParams[0],
err => this.log(err)
);
this.log("pEpAdapter.js: encrypt() success: ", response);
return response;
} catch (e) {
this.log("pEpAdapter: encrypt(): error ", e);
return null;
}
}
async color_from_rating(rating) {
let color = RATING_COLOR_GREY;
if (rating === -2 || rating === 2) {
color = RATING_COLOR_GREY;
}
else if (rating < 0) {
color = RATING_COLOR_RED;
}
else if (rating < 6) {
color = RATING_COLOR_GREY;
}
else if (rating >= 7) {
color = RATING_COLOR_GREEN;
}
else {
color = RATING_COLOR_YELLOW;
}
return color;
}
}
pEpAdapter.pEpIdentity = class {
constructor(address, id = "", name = "anonymous", fingerprint) {
if(typeof address === "string") {
this.user_id = id;
this.username = name;
this.address = address;
this.fingerprint = fingerprint;
}
else {
this.user_id = address.user_id;
this.username = address.username;
this.address = address.address;
this.fingerprint = address.fingerprint;
}
}
};
pEpAdapter.pEpMessage = class {
constructor(id, short, long, from, to = [], dir = DIR_OUTGOING) {
if(typeof to === "string") to = [to];
this.id = id;
this.shortmsg = short;
this.longmsg = long;
this.from = new pEpAdapter.pEpIdentity(from);
this.to = to.reduce((addresses, addr) => {
addresses.push(new pEpAdapter.pEpIdentity(addr));
return addresses;
}, []);
this.dir = dir;
this.attachments = [];
}
addAttachment(base64_value, size, filename = "", mimetype = "") {
let attachment;
if (typeof base64_value === "object") {
attachment = base64_value;
}
else {
attachment = {
value: base64_value,
size: size
}
}
this.attachments.push(attachment);
}
};
// export common.js module to allow one js file for browser and node.js
if (typeof module !== 'undefined' && module.exports) {
module.exports = pEpAdapter;

+ 30
- 12
chrome/content/modules/pEpServer.js View File

@ -9,6 +9,10 @@ const MAX_RETRY_ATTEMPTS = 2;
const SERVER_TYPE_CALL_FUNC = "callFunction";
const PEP_WRONG_SEC_TOKEN_CODE = -32600;
const PEP_RESPONSE_OK = 0;
const PEP_RESPONSE_UNENCRYPTED = 1024;
const PEP_RESPONSE_DECRYPTED = 1026;
class pEpServer {
constructor( log, core, os, env, path, connectionInfo, XhrQueue, files, utils, XMLHttpRequest ) {
if (pepServerInstance) return pepServerInstance;
@ -149,7 +153,7 @@ class pEpServer {
environment: env,
mergeStderr: false,
stdin: stdin => { /* do nothing*/ },
stdout: data => { that.log("stdout from pep-json-server: " + data); },
stdout: data => { that.log("stdout from pEp-json-server: " + data); },
stderr: data => {
if (stderrData.length < 2048) {
stderrData += data;
@ -211,10 +215,10 @@ class pEpServer {
* @return Object - a Promise
*/
async callPepAdapter(funcType, functionName, paramsArr, onLoadListener, onErrorListener, deferred) {
this.log("++++callPepAdapter(" + funcType + ", " + functionName + ")");
this.log("callPepAdapter(" + funcType + ", " + functionName + ")\n");
if (!deferred) deferred = this.utils.deferred();
if (!deferred) deferred = new this.utils.deferred;
let that = this;
let securityToken = this.connectionInfo.security_token || "";
let connectionAddress = this.getConnectionAddress();
@ -286,7 +290,7 @@ class pEpServer {
try {
parsedObj = that.utils.parseJSON(responseText);
if ((typeof(parsedObj) === "object") && ("error" in parsedObj)) {
if ((typeof(parsedObj) === "object") && parsedObj.hasOwnProperty("error")) {
if (parsedObj.error.code === PEP_WRONG_SEC_TOKEN_CODE) {
// wrong security token
that.reloadConnectionInfo();
@ -297,17 +301,31 @@ class pEpServer {
that.retryCount = 0;
}
response = loadListener(parsedObj);
if (typeof(response) === "object" && "result" in response && "return" in response.result && "status" in response.result.return) {
if (response.result.return.status !== 0) {
that.log("callPepAdapter: '" + functionName + "' returned with error: " + JSON.stringify(response));
if (typeof parsedObj === "object" &&
parsedObj.hasOwnProperty("result") &&
parsedObj.result.hasOwnProperty("return")) {
if (parsedObj.result.return.hasOwnProperty("status")) {
switch (parsedObj.result.return.status) {
case(PEP_RESPONSE_OK):
case(PEP_RESPONSE_DECRYPTED):
response = loadListener(parsedObj);
that.log("callPepAdapter: '" + functionName + "' returned with success: ", response, parsedObj);
deferred.resolve(response);
break;
default:
that.log("callPepAdapter: '" + functionName + "' returned with error: ", parsedObj);
deferred.reject({code: "PEP-ERROR", message: parsedObj.error.message, parsedObj});
}
} else {
deferred.resolve(loadListener(parsedObj));
}
} else {
deferred.reject({code: "PEP-ERROR", message: parsedObj.error.message, parsedObj});
}
deferred.resolve(response);
}
catch (ex) {
deferred.reject(that.utils.getErrorObject("PEP-ERROR", ex, response));
deferred.reject(that.utils.getErrorObject("PEP-ERROR", ex, parsedObj));
}
};
}
@ -320,7 +338,7 @@ class pEpServer {
let that = this;
return (error) => {
that.log("XMLHttpRequest: got error: " + error);
that.log("XMLHttpRequest: got error: ", error);
that.xhrQueue.dropCurrentXhr();
if (!shuttingDown) {


+ 2
- 2
chrome/content/modules/pepencrypter.js View File

@ -35,14 +35,14 @@ class pEpEncrypter {
return addresses;
}, []);
let msgId = "pep-" + String(requestId);
let msgId = "pEp-" + String(requestId);
messageObj.shortmsg = subject;
messageObj.id = msgId;
messageObj.dir = 1;
return [
messageObj, // pep messge object
messageObj, // pEp messge object
[], // extra
["OP"], // dest
pEpMode, // encryption_format


+ 3
- 2
chrome/content/modules/pepidentity.js View File

@ -1,7 +1,8 @@
class PEpIdentity {
constructor(id, name, address) {
class pEpIdentity {
constructor(id, name, address, fingerprint) {
this.user_id = id;
this.username = name;
this.address = address;
this.fingerprint = fingerprint;
}
}

+ 22
- 2
chrome/content/modules/pepmessage.js View File

@ -13,8 +13,10 @@ class PEPMessage {
this.dir = 1;
this.attachments = [];
this.opt_fields = [];
}
setFrom(user_id, username, address) {
this.from = this._buildAddress(user_id, username, address);
}
@ -30,8 +32,26 @@ class PEPMessage {
this.dir = dir;
}
addAttachment(value, size, filename = "", mimetype = "") {
let attachment;
if (typeof value === "object") {
attachment = value;
}
else {
attachment = {
value: value,
size: size,
filename:filename,
mimetype:mimetype
}
}
this.attachments.push(attachment);
}
_buildAddress(user_id, username, address) {
// TODO: use pep identity
// TODO: use pEp identity
return {
user_id: user_id,
username: username,


+ 0
- 1
chrome/content/modules/utils.js View File

@ -135,7 +135,6 @@ let pEpUtils = {
this.reject = reject;
}.bind(this));
Object.freeze(this);
return this;
}
};


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

@ -57,7 +57,7 @@ class XhrQueue {
if (request !== null) {
this.currentXhr = this.process(request);
}
}
}
dropCurrentXhr() {
this.dropXhr(this.currentXhr);


+ 2
- 2
chrome/content/pepmessenger.js View File

@ -4,13 +4,13 @@ Cu.import("chrome://p4t/content/modules/pEp.js");
let pep = new pEp();
window.addEventListener("load", function(e) {
let privacyPanel = document.getElementById("pep-statusbar-privacy-status");
let privacyPanel = document.getElementById("pEp-statusbar-privacy-status");
pep.getVersion().then(value => {
privacyPanel.value = `p≡p running (v${value})`;
}).
catch(e => {
privacyPanel.value = `p≡p stopped`;
privacyPanel.value = `p≡p not running`;
});
}, false);

+ 2
- 2
chrome/content/pepmessenger.xul View File

@ -9,12 +9,12 @@
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://p4t/content/pepmessenger.js"/>
<script type="appplication/javascript" src="chrome://p4t/content/pepmessenger.js"/>
<statusbar id="status-bar">
<statusbarpanel id="pep-statusbar">
<hbox align="center">
<label id="pep-statusbar-privacy-status" value="CHRIS WAS NOT HERE" />
<label id="pep-statusbar-privacy-status" value="" />
</hbox>
</statusbarpanel>


+ 52
- 0
chrome/content/pepmessengercompose.js View File

@ -1,3 +1,55 @@
console.log("pepmessengercompose.js");
Cu.import("chrome://p4t/content/modules/pEp.js");
let pep = new pEp();
window.addEventListener("load", function (event) {
console.log("pepmessengercompose.js: onload()");
let privacyPanel = document.getElementById("pEp-statusbar-privacy-status");
pep.getVersion().then(value => {
privacyPanel.value = `p≡p running (v${value})`;
}).catch(e => {
privacyPanel.value = `p≡p not running`;
});
// // JUST FOR TESTING
// gMsgCompose.compFields.body = "Test Body";
// gMsgCompose.compFields.to = "cfg@pEp.security";
// gMsgCompose.compFields.subject = "Test Subject";
}, false);
let sendListener = (event) => {
console.log("pepmessengercompose.js: compose-send-message()");
window.removeEventListener(event.type, sendListener, true);
let ownMail = gCurrentIdentity.email;
//FIXME body not sent
pep.encryptMail(gMsgCompose.compFields.subject, "msgFields.body", ownMail, gMsgCompose.compFields.to)
.then(value => {
console.log("pepmessengercompose.js: compose-send-message() mail encrypted", value.shortmsg, value.longmsg);
gMsgCompose.compFields.subject = value.shortmsg;
gMsgCompose.compFields.body = value.longmsg;
window.dispatchEvent(event);
})
.catch(error => {
console.log("pepmessengercompose.js: compose-send-message() ERROR mail NOT encrypted");
console.log(error);
});
};
// let sendListener = (event) => {
// console.log("pepmessengercompose.js: compose-send-message()");
//
// gMsgCompose.compFields.subject = "RANDOM SUBJECT";
// gMsgCompose.compFields.body = "RANDOM BODY";
// };
window.addEventListener("compose-send-message", sendListener, true);

+ 7
- 1
chrome/content/pepmessengercompose.xul View File

@ -10,7 +10,13 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://p4t/content/pepmessengercompose.js"/>
<statusbar id="status-bar">
<statusbarpanel id="my-panel" label="Date"/>
<statusbarpanel id="pep-statusbar">
<hbox align="center">
<label id="pep-statusbar-privacy-status" value="" />
</hbox>
</statusbarpanel>
</statusbar>
</overlay>

+ 215
- 0
chrome/content/pepmsghdrview.js View File

@ -0,0 +1,215 @@
const Cu = Components.utils;
Cu.import("chrome://p4t/content/modules/pEp.js");
let pep = new pEp();
let count = 0;
let getPanel = (name, targetWindow) => {
for (let i = 0; i < targetWindow.frames.length; i++) {
if (targetWindow.frames[i].name === name) {
return targetWindow.frames[i];
}
}
return null;
};
let onLoadListener = (event) => {
console.log("pepmsghdrview.js: onLoadListener()");
let onStartHeadersMessageListener = () => {
let messagePanelFrame = getPanel("messagepane", window);
console.log("pepmsghdrview.js: onLoadMsgPanelFrameListener(), frame: ", messagePanelFrame);
if (messagePanelFrame != null) {
console.log("pepmsghdrview.js: onLoadListener() added listener");
messagePanelFrame.addEventListener("load", onLoadMsgPanelFrameListener, false);
}
};
let onEndHeadersMessageListener = () => {
};
gMessageListeners.push({
onStartHeaders: onStartHeadersMessageListener,
onEndHeaders: onEndHeadersMessageListener
});
onStartHeadersMessageListener();
onEndHeadersMessageListener();
};
let onLoadMsgPanelFrameListener = (event) => {
/* global currentHeaderData: false, gViewAllHeaders: false, gExpandedHeaderList: false, goDoCommand: false, HandleSelectedAttachments: false */
function updateSubject(newSubject) {
let subjectBox = document.getElementById("expandedsubjectBox");
subjectBox.headerValue = newSubject;
}
function updateBody(newBody) {
//TODO Not implemented yet
let bodyElement = getPanel("messagepane", window).document.getElementsByTagName("body")[0];
let node = bodyElement.firstChild;
while (node) {
if(node.nodeName === "DIV" || node.nodeName === "PRE") {
if (node.textContent.indexOf("-----BEGIN PGP")) {
node.innerHTML = newBody;
return;
}
}
node = node.nextSibling;
}
}
function updatePrivacy(privacyStatus) {
let privacyPanel = document.getElementById("pep-msghdr-statusbar-privacy-status");
privacyPanel.value = `Privacy color: ${privacyStatus}`;
}
console.log("pepmsghdrview.js: onLoadMsgPanelFrameListener()");
// read email from tb
// TODO decrypt mail
let messageString = "-----BEGIN PGP MESSAGE-----\n" +
"\n" +
"hQEMA3nTjPcdpPimAQgA2yAWJ7f3UdRvL/D8PI6KgAExPnQ4g8bEOUpwOgmo435x\n" +
"rEKlkP/QMGUWZfliDlhTAugaxqAxzVE4+rfyp9OqQUSj9S5xToIj0/qMa3ae4wLF\n" +
"WUxPksBVbb0r8nPQgGP9cpWa0+MWi3vUWeEvdcpcPCGsgmTKkxOKbqDAOD5GEKxX\n" +
"xj7iodBCevzf+nFtrHoMU56qkdreY/Pw1BTCFUPAUB8cEfqIp58CAfwP+WJUM2LM\n" +
"uMkZ4tq+F+bT5Q6oZUVqwdWeARlD6lu6LYFM/MQTBwHL9vVtpz35e7/yYa0O7lMB\n" +
"ev9ccn2a2qPaCdQt3tGfKREluT4GBhljxR5Oe55SUdJHASOnYNeFd48wfToxkXkv\n" +
"j1urYFxRZmq9atq0upqd2EnWlxq2OitrcG0PM4uuLKsw+vGjkElAqotLxdQqwXMJ\n" +
"jkogthSisZ8=\n" +
"=dTBg\n" +
"-----END PGP MESSAGE-----";
/*
let messageString = "-----BEGIN PGP MESSAGE-----\n" +
"\n" +
"hQIMAwofEBEEk5qCAQ//S/hegAyrCMSsxzgDwYWdZBILgxRvLM3g3ABAoTM8MRRW\n" +
"4hhHalak6Jds4VTtEcMAphcXdZIyI4AOXRLgJxktaiy4JglgPXkUGi0FicXz/UaV\n" +
"niZSOInlgyrPd9S1HUx9SxwI2qbT7inM0jmudwV7T63QOeo/vFahHlQS4N95Zw97\n" +
"cRV64lm/G9qSF6qPdJMDck7kdXIB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LIvCkNvPeU1bzMQPxaQem8QsUg6CGisXBYitlOFGhWIuqNJRXNMlIgRVc9\n" +
"jMyPhny7+XO3Uw/VCk0eg4ujWvKTqvg6niM0r6Z13hT7b1Hkpqot8Z2CcjwZD/Rm\n" +
"bK9IXV7RUWMFKthlA81joiaIeHk0NJN9NoBxFdFc6z25hWAqeBFzXpc0SeUgShOE\n" +
"IZHMf5KIWIvGbKG99XmmwVyaCysRZT29P5m47t9ZcyPxb0O3NJdkQAft3l9euxWl\n" +
"0JAEgpUAMaTam+c4+8FPj84JoXBRsdDimIVJx1eeSFdGDUV2VACu0zLD+1LuvgOJ\n" +
"vCaRplHDKkie6SNYiwhxWx1QSlUF8xqx7M19jMrK0y+fWI6CjNNrX2i2ESOgnLJa\n" +
"MD7DYt+gq9sDr/oGomTDkiiB1houfvpOQlAj+HD6I5BnHBvwW39clUTlL5b16GLz\n" +
"rMnYPhyOtLz6w3SUDKMdzwE5ankgp+8ToGc+He3PkJTUWx27CjTQ+h0+s+viOXBB\n" +
"LTWVi7Mm7bhqYnJz6Zme/gY3Kc6815FxnLR2dILzeZY0vFxFHOOTwrlOxV1jHPOS\n" +
"n2zsAJgoBieSdLqq5zygu8iTVeC1SFT3QNCHrl+UaTylX7T8kWW8eumuU6gRFPaV\n" +
"Sr2kl6sMaEtqKsmobd9KXjgjMZ5iV4v7EDloeBo=\n" +
"=xc3m\n" +
"-----END PGP MESSAGE-----";
*/
pep.decryptMail(messageString, currentHeaderData).then((message) => {
// replace encrypted mail with decrypted from pEpAdapter
updateSubject(message.shortmsg);
updateBody(message.longmsg);
pep.getPrivacyColorFromRating(message.rating).then(
(rating) => updatePrivacy(rating)
);
});
};
window.addEventListener("load", onLoadListener, false);

+ 22
- 0
chrome/content/pepmsghdrview.xul View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!--
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<overlay id="p4tMsgComposeOverlay"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://p4t/content/pepmsghdrview.js"/>
<statusbar id="status-bar">
<statusbarpanel id="pep-msghdr-statusbar">
<hbox align="center">
<label id="pep-msghdr-statusbar-privacy-status" value="" />
</hbox>
</statusbarpanel>
</statusbar>
</overlay>

+ 6
- 0
package-lock.json View File

@ -165,6 +165,12 @@
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"btoa": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz",
"integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==",
"dev": true
},
"chai": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz",


+ 4
- 3
package.json View File

@ -3,9 +3,10 @@
"version": "1.0.0",
"dependencies": {},
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"mocha": "^5.2.0",
"btoa": "^1.2.1",
"chai": "*",
"chai-as-promised": "*",
"mocha": "*",
"nyc": "^13.1.0",
"xhr2": "^0.1.4"
}


+ 6
- 0
tests/config/testSetup.js View File

@ -5,3 +5,9 @@ let should = chai.should();
global.should = should;
global.describe = describe;
let connectionInfo = {
address: "127.0.0.1",
port: 4223,
path: "/ja/0.1/",
security_token: "87alnE340q0GeE7kXGR_Vpp2lJs9N1B55buZIEj"
};

+ 99
- 0
tests/features/decrypt_feature_spec.js View File

@ -0,0 +1,99 @@
/* eslint-disable no-console */
let {describe, it, before, beforeEach}= require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let pEpAdapter = require ( '../../chrome/content/modules/pEpAdapter');
let pEpServer = require ( '../../chrome/content/modules/pEpServer');
let pEpUtils = require ( '../../chrome/content/modules/utils');
let pEpOs = require ( '../../chrome/content/modules/pEpOs');
let pEpCore = require ( '../../chrome/content/modules/pEpCore');
let XhrQueue = require ( '../../chrome/content/modules/xhrQueue');
let log = console.log;
let core;
let os;
let env;
let path = "~/.pEp/";
let connectionInfo = {
address: "127.0.0.1",
port: 4224,
path: "/ja/0.1/",
security_token: "kUjsPnrsWdHp4JMH6Ld_e5szaniVdubuNNGuVke"
};
let files;
let utils = pEpUtils;
let deferred;
describe('pEp Decrypt Feature', () => {
//TODO Launch a pEp Desktop Adapter instance before each test
describe('Perfect scenario', () => {
let adapter;
let result = "initial value";
before(() => {
let server = new pEpServer(log, core, os, env, path, connectionInfo, XhrQueue, files, utils);
adapter = new pEpAdapter(console.log, server);
let subject = "pEp";
let body = "-----BEGIN PGP MESSAGE-----\n" +
"\n" +
"hQEMA3nTjPcdpPimAQgA2yAWJ7f3UdRvL/D8PI6KgAExPnQ4g8bEOUpwOgmo435x\n" +
"rEKlkP/QMGUWZfliDlhTAugaxqAxzVE4+rfyp9OqQUSj9S5xToIj0/qMa3ae4wLF\n" +
"WUxPksBVbb0r8nPQgGP9cpWa0+MWi3vUWeEvdcpcPCGsgmTKkxOKbqDAOD5GEKxX\n" +
"xj7iodBCevzf+nFtrHoMU56qkdreY/Pw1BTCFUPAUB8cEfqIp58CAfwP+WJUM2LM\n" +
"uMkZ4tq+F+bT5Q6oZUVqwdWeARlD6lu6LYFM/MQTBwHL9vVtpz35e7/yYa0O7lMB\n" +
"ev9ccn2a2qPaCdQt3tGfKREluT4GBhljxR5Oe55SUdJHASOnYNeFd48wfToxkXkv\n" +
"j1urYFxRZmq9atq0upqd2EnWlxq2OitrcG0PM4uuLKsw+vGjkElAqotLxdQqwXMJ\n" +
"jkogthSisZ8=\n" +
"=dTBg\n" +
"-----END PGP MESSAGE-----";
let from = {
user_id: "790E6B02",
username: "Hussein Kasem",
address: "huss@pep-project.org",
fingerprint: "5CC6 7646 D67A 33D8 A2E4 FF84 9E61 B9BC 790E 6B02"
};
let to = [{
user_id: "95E4A594",
username: "Chris",
address: "cfg@pep.security",
fingerprint: "B277 5D7B 919C 9E28 EC1B 9B49 2C0E 8DE5 95E4 A594"
}];
let cc = null;
let replyTo = null;
result = adapter.decrypt(subject, body, from, to, cc, replyTo);
});
it('should return a Object', () => {
return result.should.become({
longmsg: "Test Body",
shortmsg: "Test Subject",
persons: {
"from": {
"address": "huss@pep-project.org",
"comm_type": 56,
"fpr": "5CC67646D67A33D8A2E4FF849E61B9BC790E6B02",
"user_id": "790E6B02",
"username": "Hussein Kasem",
},
"to": [
{
"address": "cfg@pep.security",
"comm_type": 0,
"user_id": "95E4A594",
"username": "Chris",
}
],
"reply_to": undefined,
"cc": undefined
},
rating: 5,
"fpr": [
"",
"5CC67646D67A33D8A2E4FF849E61B9BC790E6B02",
"B2775D7B919C9E28EC1B9B492C0E8DE595E4A594",
]
});
});
});
});

+ 123
- 82
tests/features/encrypt_feature_spec.js View File

@ -2,100 +2,141 @@
let {describe, it, before, beforeEach}= require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let expect = chai.expect;
// let pEp = require('../../package/pEp.jsm');
// let encrypter = pEp.EnigmailpEp.encryptMessage;
// let pEp = {
// EnigmailpEp: {
// encryptMessage: function (from, toList, subject, msgObj, mode) {
// return new Promise(function (resolve, reject) {
// let condition = false;
// if ( condition ) {
// reject("shiet");
// return;
// }
// resolve("foo");
// return;
//
// });
// }
// }
// };
let PEPEncrypter = require ( '../../chrome/content/modules/pEpEncrypter.js');
function hasKeyAttached() {
//TODO Implement function to check if a key is attached to the mail
return false;
}
function mockPepRunner() {
let mockedEncryptedMail = {
id: "msgId",
shortmsg: "Encrypted subject",
longmsg: "Encrypted body",
dir: "1",
from:{
"user_id": "",
"username": "anonymous",
"address": "from@domain"
},
to: [{
"user_id": "",
"username": "anonymous",
"address": "to@domain"
}]
};
return new Promise( (resolve, reject) => { resolve(mockedEncryptedMail); } );
}
let mockPromiseUtils = {};
describe.skip('Encrypte Feature', () => {
let encrypter;
let encryptPromise;
before(() => {
encrypter = new PEPEncrypter(console.debug, mockPepRunner, mockPromiseUtils, null, null);
let pEpAdapter = require ( '../../chrome/content/modules/pEpAdapter');
let pEpServer = require ( '../../chrome/content/modules/pEpServer');
let pEpUtils = require ( '../../chrome/content/modules/utils');
let XhrQueue = require ( '../../chrome/content/modules/xhrQueue');
let log = console.log;
let core;
let os;
let env;
let path = "~/.pEp/";
let connectionInfo = {
address: "127.0.0.1",
port: 4223,
path: "/ja/0.1/",
security_token: "87alnE340q0GeE7kXGR_Vpp2lJs9N1B55buZIEj"
};
let files;
let utils = pEpUtils;
let deferred;
let result;
describe('Encrypte Feature', () => {
describe('Empty TO: scenario', () => {
before(() => {
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";
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);
});
it('should resolve into an encrypted mail', () => {
return result.should.be.fulfilled;
});
it("should have at least 2 attachments", () => {
return Promise.all([
result.should.eventually.have.property("attachments"),
result.should.eventually.to.deep.include({
"attachments": [
{
"mime_type": "application/pgp-encrypted",
"size": 10,
"value": "VmVyc2lvbjogMQ==",
},
{
"filename": "file://msg.asc",
"mime_type": "application/octet-stream",
"size": 3401,
"value": "LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpoUUVNQXdNM0ZwbWxDU052QVFmL1RBRlo3Tzczc2ZrMGRpK3Evdnc3RDU4ZzlTQXN5TnFNc0ROdnlJeGRhUGpMClJMQlpjRzY1dllpaUVQNlRxUTVhZk1JTnloV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haEdQNmI0M3JzQTBleEZPNHc2N1B2YkFqNEttQjRTWGRpVlhvblhyLzdPbgpDNndwTGhuTHN5NXh6UmNrbUFpeW1RPT0KPTh3TDYKLS0tLS1FTkQgUEdQIE1FU1NBR0UtLS0tLQo=",
}
],
"dir": 1,
"enc_format": 3,
"from": {
"address": "from@test.com",
"comm_type": 255,
"fpr": "0FB24DAC112475FD6E8BF9B69C6F37522D2C7B52",
"user_id": "pEp_own_userId",
"username": "anonymous"
},
"id": "pEp.PJKUYJ.0Z1XKRIO30TIW.767B436F-99CE-496D-A1F7-D7C2EB9A9CE9@test.com",
"longmsg": "this message was encrypted with p≡p https://pEp-project.org",
"opt_fields": [
{
"key": "X-pEp-Version",
"value": "2.0",
}
],
"shortmsg": "p≡p",
})
]);
});
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.should.be.equal("X-pEp-Version");
});
it("should have pEp subject", () => {
return expect(result.shortmsg).to.become("p≡p");
return result.shortmsg.equal("p≡p");
});
it('should have enctypted body', () => {
return expect(result.longmsg).to.become("this message was encrypted with p≡p https://pEp-project.org");
});
});
describe('Perfect scenario', () => {
before(() => {
let fromAddr, toAddrList, subject, messageObj, pEpMode;
fromAddr = "from@test.com";
toAddrList = "to@test.com";
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"}];
subject = "subject";
messageObj = {"longmsg":"Not Encrypted Message"};
pEpMode = 1;
encryptPromise = encrypter.encryptMessage(fromAddr, toAddrList, subject, messageObj, pEpMode);
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);
});
it('should return a Promise', () => {
return encryptPromise.should.be.a('promise');
it('should resolve into an encrypted mail', () => {
return result.should.become({});
return result.should.be.fulfilled;
});
it('should be fulfilled', () => {
return encryptPromise.should.be.fulfilled;
it("should have at least 2 attachments", () => {
return result.should.hasOwnProperty("attachments");
return result.attachments.length.should.be.gt(2);
});
it('should resolve into an encrypted mail', () => {
return encryptPromise.should.eventually.eql({
id: "msgId",
shortmsg: "Encrypted subject",
longmsg: "Encrypted body",
dir: "1",
from:{
"user_id": "",
"username": "anonymous",
"address": "from@domain"
},
to: [{
"user_id": "",
"username": "anonymous",
"address": "to@domain"
}]
});
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");
});
it("should have pEp subject", () => {
return result.shortmsg.equal("p≡p");
});
it('should has attached key', () => {
//return encryptPromise.should.eventually.equal("Encrypted email");
return hasKeyAttached().should.be.true;
it('should have enctypted body', () => {
result.longmsg.equal("this message was encrypted with p≡p https://pEp-project.org");
});
});
});

+ 2
- 6
tests/features/get_version_feature_spec.js View File

@ -7,9 +7,6 @@ chai.should();
let pEpAdapter = require ( '../../chrome/content/modules/pEpAdapter');
let pEpServer = require ( '../../chrome/content/modules/pEpServer');
let pEpUtils = require ( '../../chrome/content/modules/utils');
let pEpOs = require ( '../../chrome/content/modules/pEpOs');
let pEpFiles = require ( '../../chrome/content/modules/pEpFiles');
let pEpCore = require ( '../../chrome/content/modules/pEpCore');
let XhrQueue = require ( '../../chrome/content/modules/xhrQueue');
let log = console.log;
@ -19,13 +16,12 @@ let env;
let path = "~/.pEp/";
let connectionInfo = {
address: "127.0.0.1",
port: 4225,
port: 4223,
path: "/ja/0.1/",
security_token: "ygmmw1Gt429N2AIQCyV_s23M8tOSh76IhyBljc7"
security_token: "87alnE340q0GeE7kXGR_Vpp2lJs9N1B55buZIEj"
};
let files;
let utils = pEpUtils;
let deferred;
describe('pEp Get Version Feature', () => {


+ 1
- 2
tests/mocha.opts View File

@ -1,4 +1,3 @@
--colors
--compilers js:babel-register
--require config/testSetup.js
--require tests/config/testSetup.js
--sort

+ 5
- 1
tests/unit/pepserver_spec.js View File

@ -1,3 +1,7 @@
let {describe, it, before, beforeEach, afterEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
let should = chai.should();
let pEpServer = require ( '../../chrome/content/modules/pEpServer');
let pEpUtils = require ( '../../chrome/content/modules/utils');
let pEpOs = require ( '../mocks/mockpepos');
@ -42,7 +46,7 @@ function cleanState() {
security_token: ""
};
deferred = new pEpUtils.deferred();
deferred = new pEpUtils.deferred;
server = null;
result = null;


Loading…
Cancel
Save