|
|
@ -0,0 +1,140 @@ |
|
|
|
/* eslint-disable no-console */ |
|
|
|
let {describe, it, before, beforeEach} = require('mocha'); |
|
|
|
let chai = require('chai').use(require('chai-as-promised')); |
|
|
|
chai.should(); |
|
|
|
|
|
|
|
describe('pEp Get Outgoing Message Rating Feature', () => { |
|
|
|
|
|
|
|
let getController = require('../boilerplate').getController; |
|
|
|
let getQueue = require('../mock').getQueue; |
|
|
|
let queue, pEpController; |
|
|
|
before(() => { |
|
|
|
queue = getQueue(); |
|
|
|
pEpController = getController(queue); |
|
|
|
}); |
|
|
|
after(() => { |
|
|
|
queue.after(); |
|
|
|
pEpController.after(); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Perfect scenario', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", ["cfg@pep.security"]); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Perfect scenario 2', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", ["hk@pep.security"]); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Perfect scenario 3', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", [{address: "hk@pep.security", username: ""}]); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Empty to (1)', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", [{}]); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Empty to (2)', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", [{address: "", username: "test"}]); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('With 2 receviers', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", ["cfg@pep.security", "hk@pep.security"]); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('With none receviers (1)', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", []); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(0); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('With none receviers (2)', () => { |
|
|
|
let result = "initial value"; |
|
|
|
before(() => { |
|
|
|
queue.respondWith({"jsonrpc":"2.0","id":3,"result":{"outParams":[{"rating":3}],"return":{"status":0,"hex":"0 \"PEP_STATUS_OK\""},"errorstack":["(1 elements cleared)"]}}); |
|
|
|
result = pEpController.getOutgoingRating("cfg@pep.security", ["randomguy@randomdomain.com"]); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return a Object', () => { |
|
|
|
queue.expectSent( |
|
|
|
{"security_token":"0847cqi9WqqE5ZcVtA8_mDIgEmYMv14xlNAvSZW","method":"outgoing_message_rating","params":[{"dir":1,"id":"pEp-0","shortmsg":"test","longmsg":"test","attachments":[],"rawmsg_ref":"","rawmsg_size":"","from":{"user_id":"","username":"","address":"cfg@pep.security","fpr":""},"to":[{"user_id":"","username":"","address":"cfg@pep.security","fpr":""}],"in_reply_to":[],"opt_fields":[],"enc_format":4},"0"],"id":1,"jsonrpc":"2.0"} |
|
|
|
); |
|
|
|
return result.should.become(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |