Browse Source

add a default empty value for fingerprints

1.1.101
francesco 3 years ago
parent
commit
681dd1cfc0
7 changed files with 40 additions and 27 deletions
  1. +2
    -2
      chrome/content/modules/pEp.js
  2. +4
    -2
      chrome/content/modules/pEpAdapter.js
  3. +12
    -6
      package-lock.json
  4. +1
    -0
      package.json
  5. +12
    -8
      tests/features/encrypt_feature_spec.js
  6. +8
    -8
      tests/features/get_ongoing_message_rating_feature.js
  7. +1
    -1
      tests/unit/controller.js

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

@ -234,7 +234,7 @@ class pEp {
return new pEp.Message(source.id,
source.shortmsg,
source.longmsg,
source.from,
deepCopy(source.from),
deepCopy(source.to),
source.dir,
source.enc_format,
@ -244,7 +244,7 @@ class pEp {
}
pEp.Identity = class {
constructor(address, id = "", name = "anonymous", fingerprint) {
constructor(address, id = "", name = "anonymous", fingerprint = "") {
if (typeof address === "string") {
this.user_id = id;


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

@ -38,6 +38,8 @@ const RATING_COLOR_RED = "red";
const RATING_COLOR_GREEN = "green";
const RATING_COLOR_YELLOW = "yellow";
function clone(obj) { return JSON.parse(JSON.stringify(obj)); }
class pEpAdapter {
constructor(log, server) {
@ -250,7 +252,7 @@ class pEpAdapter {
break;
case(PEP_UNENCRYPTED):
decryptedMessage = message;
decryptedMessage = clone(message);
decryptedMessage.rating = response.result.outParams[1].rating;
this.log("callPepAdapter: 'decrypt' returned with UNENCRYPTED status: ", response);
break;
@ -316,7 +318,7 @@ class pEpAdapter {
case(PEP_UNENCRYPTED):
case(PEP_KEY_NOT_FOUND):
case(PEP_KEY_HAS_AMBIG_NAME):
encryptedMessage = message;
encryptedMessage = clone(message);
encryptedMessage.enc_format = 0; // unencrypted
this.log("callPepAdapter: 'encrypt' returned with UNENCRYPTED status: ", response);
break;


+ 12
- 6
package-lock.json View File

@ -542,9 +542,9 @@
"dev": true
},
"handlebars": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.2.0.tgz",
"integrity": "sha512-Kb4xn5Qh1cxAKvQnzNWZ512DhABzyFNmsaJf3OAkWNa4NkaqWcNI8Tao8Tasi0/F4JD9oyG0YxuFyvyR57d+Gw==",
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.2.tgz",
"integrity": "sha512-cIv17+GhL8pHHnRJzGu2wwcthL5sb8uDKBHvZ2Dtu5s1YNt0ljbzKbamnc+gr69y7bzwQiBdr5+hOpRd5pnOdg==",
"dev": true,
"requires": {
"neo-async": "^2.6.0",
@ -1141,6 +1141,12 @@
"integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=",
"dev": true
},
"ramda": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.26.1.tgz",
"integrity": "sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ==",
"dev": true
},
"read-pkg": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",
@ -1424,9 +1430,9 @@
},
"dependencies": {
"commander": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
"version": "2.20.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.1.tgz",
"integrity": "sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==",
"dev": true,
"optional": true
},


+ 1
- 0
package.json View File

@ -9,6 +9,7 @@
"chai-as-promised": "*",
"mocha": "*",
"nyc": "^14.1.1",
"ramda": "^0.26.1",
"sinon": "^7.4.2",
"xhr2": "^0.1.4"
},


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

@ -3,7 +3,7 @@ let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let pEp = require('../../chrome/content/modules/pEp');
function deepCopy (obj) { return JSON.parse(JSON.stringify(obj)); }
let R = require('ramda');
describe('pEp Encrypt Feature', () => {
@ -22,9 +22,6 @@ describe('pEp Encrypt Feature', () => {
to = "to@test.com";
subject = "subject";
body = "Not Encrypted Message";
message = new pEp.Message("pEp-0", subject, body, from, to);
message.longmsg_formatted = "";
message.setCc([]);
result = pEpController.encryptMail(subject, body, "", from, to);
});
after(() => {
@ -33,8 +30,15 @@ describe('pEp Encrypt Feature', () => {
});
it('returns an unencrypted message', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"encrypt_message","params":[{"id":"pEp-0","shortmsg":"subject","longmsg":"Not Encrypted Message","longmsg_formatted":"","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"to@test.com"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[],"cc":[]},[],["OP"],3,0],"id":1,"jsonrpc":"2.0"});
return result.should.eventually.have.property('enc_format', 0);
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"encrypt_message","params":[{"id":"pEp-0","shortmsg":"subject","longmsg":"Not Encrypted Message","longmsg_formatted":"","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"to@test.com","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[],"cc":[]},[],["OP"],3,0],"id":1,"jsonrpc":"2.0"});
result.should.eventually.have.property('enc_format', 0);
message = new pEp.Message("pEp-0", subject, body, from, to);
message.longmsg_formatted = "";
message.setCc([]);
message.enc_format = 0;
return result.should.become(message);
});
});
@ -58,7 +62,7 @@ describe('pEp Encrypt Feature', () => {
});
it('sends as expected', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"encrypt_message","params":[{"id":"pEp-0","shortmsg":"subject","longmsg":"Not Encrypted Message","longmsg_formatted":"","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[],"cc":[]},[],["OP"],3,0],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"encrypt_message","params":[{"id":"pEp-0","shortmsg":"subject","longmsg":"Not Encrypted Message","longmsg_formatted":"","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[],"cc":[]},[],["OP"],3,0],"id":1,"jsonrpc":"2.0"});
});
it('should resolve into an encrypted mail', () => {
@ -149,7 +153,7 @@ describe('pEp Encrypt Feature', () => {
});
it('sends as expected', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"encrypt_message","params":[{"id":"pEp-0","shortmsg":"subject","longmsg":"Not Encrypted Message","longmsg_formatted":"","from":{"user_id":"","username":"anonymous","address":"fo@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"},{"user_id":"","username":"anonymous","address":"rg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[],"cc":[{"user_id":"","username":"anonymous","address":"kinga@pep-security.net"}]},[],["OP"],3,0],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"encrypt_message","params":[{"id":"pEp-0","shortmsg":"subject","longmsg":"Not Encrypted Message","longmsg_formatted":"","from":{"user_id":"","username":"anonymous","address":"fo@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},{"user_id":"","username":"anonymous","address":"rg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[],"cc":[{"user_id":"","username":"anonymous","address":"kinga@pep-security.net","fpr":""}]},[],["OP"],3,0],"id":1,"jsonrpc":"2.0"});
});
it('should resolve into an encrypted mail', () => {


+ 8
- 8
tests/features/get_ongoing_message_rating_feature.js View File

@ -25,7 +25,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
@ -38,7 +38,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
@ -51,7 +51,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
@ -64,7 +64,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(0);
});
});
@ -77,7 +77,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(0);
});
});
@ -90,7 +90,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});
@ -103,7 +103,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(0);
});
});
@ -117,7 +117,7 @@ describe('pEp Get Ongoing Message Rating Feature', () => {
});
it('should return a Object', () => {
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
});


+ 1
- 1
tests/unit/controller.js View File

@ -32,7 +32,7 @@ describe('controller calls', () => {
it('get ongoing rating', () => {
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}});
let result = controller.getOngoingRating("cfg@pep.security", ["cfg@pep.security", "hk@pep.security"]);
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security"},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security"},{"user_id":"","username":"anonymous","address":"hk@pep.security"}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
queue.expectSent({"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"id":"pEp-0","shortmsg":"test","longmsg":"test","from":{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"anonymous","address":"cfg@pep.security","fpr":""},{"user_id":"","username":"anonymous","address":"hk@pep.security","fpr":""}],"dir":1,"enc_format":3,"attachments":[],"opt_fields":[]},"0"],"id":1,"jsonrpc":"2.0"});
return result.should.become(3);
});
it('myself', () => {


Loading…
Cancel
Save