2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2015-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-11-02 18:02:53 +00:00
|
|
|
/* global textsecure */
|
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
describe('Protocol', () => {
|
|
|
|
describe('Unencrypted PushMessageProto "decrypt"', () => {
|
|
|
|
// exclusive
|
|
|
|
it('works', done => {
|
2018-05-02 16:51:22 +00:00
|
|
|
localStorage.clear();
|
2014-11-06 22:16:54 +00:00
|
|
|
|
2018-11-02 18:02:53 +00:00
|
|
|
const textMessage = new textsecure.protobuf.DataMessage();
|
|
|
|
textMessage.body = 'Hi Mom';
|
|
|
|
const serverMessage = {
|
2018-05-02 16:51:22 +00:00
|
|
|
type: 4, // unencrypted
|
|
|
|
source: '+19999999999',
|
|
|
|
timestamp: 42,
|
2018-11-02 18:02:53 +00:00
|
|
|
message: textMessage.encode(),
|
2018-05-02 16:51:22 +00:00
|
|
|
};
|
2014-11-06 22:16:54 +00:00
|
|
|
|
2018-05-02 16:51:22 +00:00
|
|
|
return textsecure.protocol_wrapper
|
|
|
|
.handleEncryptedMessage(
|
2018-11-02 18:02:53 +00:00
|
|
|
serverMessage.source,
|
|
|
|
serverMessage.source_device,
|
|
|
|
serverMessage.type,
|
|
|
|
serverMessage.message
|
2018-05-02 16:51:22 +00:00
|
|
|
)
|
2018-07-21 21:51:20 +00:00
|
|
|
.then(message => {
|
2018-11-02 18:02:53 +00:00
|
|
|
assert.equal(message.body, textMessage.body);
|
2018-05-02 16:51:22 +00:00
|
|
|
assert.equal(
|
|
|
|
message.attachments.length,
|
2018-11-02 18:02:53 +00:00
|
|
|
textMessage.attachments.length
|
2018-05-02 16:51:22 +00:00
|
|
|
);
|
2018-11-02 18:02:53 +00:00
|
|
|
assert.equal(textMessage.attachments.length, 0);
|
2018-05-02 16:51:22 +00:00
|
|
|
})
|
|
|
|
.then(done)
|
|
|
|
.catch(done);
|
2014-11-06 22:16:54 +00:00
|
|
|
});
|
2018-05-02 16:51:22 +00:00
|
|
|
});
|
2014-11-06 22:16:54 +00:00
|
|
|
});
|