2015-09-07 21:53:43 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2014-11-06 22:16:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
describe('Protocol', function() {
|
|
|
|
|
|
|
|
describe('Unencrypted PushMessageProto "decrypt"', function() {
|
|
|
|
//exclusive
|
|
|
|
it('works', function(done) {
|
|
|
|
localStorage.clear();
|
|
|
|
|
2015-06-01 21:08:21 +00:00
|
|
|
var text_message = new textsecure.protobuf.DataMessage();
|
2014-11-06 22:16:54 +00:00
|
|
|
text_message.body = "Hi Mom";
|
|
|
|
var server_message = {
|
|
|
|
type: 4, // unencrypted
|
|
|
|
source: "+19999999999",
|
|
|
|
timestamp: 42,
|
|
|
|
message: text_message.encode()
|
|
|
|
};
|
|
|
|
|
2015-06-01 21:08:21 +00:00
|
|
|
return textsecure.protocol_wrapper.handleEncryptedMessage(
|
|
|
|
server_message.source,
|
|
|
|
server_message.source_device,
|
|
|
|
server_message.type,
|
|
|
|
server_message.message
|
|
|
|
).then(function(message) {
|
2014-11-06 22:16:54 +00:00
|
|
|
assert.equal(message.body, text_message.body);
|
|
|
|
assert.equal(message.attachments.length, text_message.attachments.length);
|
|
|
|
assert.equal(text_message.attachments.length, 0);
|
|
|
|
}).then(done).catch(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-01-16 09:38:29 +00:00
|
|
|
// TODO: Use fake_api's hiding of api.sendMessage to test sendmessage.js' maze
|
2014-11-06 22:16:54 +00:00
|
|
|
});
|