Review fixes

pull/1167/head
Mikunj 5 years ago
parent 4a5146025b
commit 9f27d62f76

@ -11,6 +11,7 @@ import { SignalService } from '../../../protobuf';
import LokiPublicChatFactoryAPI from '../../../../js/modules/loki_public_chat_api'; import LokiPublicChatFactoryAPI from '../../../../js/modules/loki_public_chat_api';
import { OpenGroupMessage } from '../../../session/messages/outgoing'; import { OpenGroupMessage } from '../../../session/messages/outgoing';
import { LokiPublicChannelAPI } from '../../../../js/modules/loki_app_dot_net_api'; import { LokiPublicChannelAPI } from '../../../../js/modules/loki_app_dot_net_api';
import { EncryptionType } from '../../../session/types/EncryptionType';
describe('MessageSender', () => { describe('MessageSender', () => {
const sandbox = sinon.createSandbox(); const sandbox = sinon.createSandbox();
@ -23,7 +24,8 @@ describe('MessageSender', () => {
describe('send', () => { describe('send', () => {
const ourNumber = 'ourNumber'; const ourNumber = 'ourNumber';
let lokiMessageAPIStub: sinon.SinonStubbedInstance<LokiMessageAPI>; let lokiMessageAPIStub: sinon.SinonStubbedInstance<LokiMessageAPI>;
let stubEnvelopeType = SignalService.Envelope.Type.CIPHERTEXT; let messageEncyrptReturnEnvelopeType =
SignalService.Envelope.Type.CIPHERTEXT;
beforeEach(() => { beforeEach(() => {
// We can do this because LokiMessageAPI has a module export in it // We can do this because LokiMessageAPI has a module export in it
@ -36,7 +38,7 @@ describe('MessageSender', () => {
sandbox sandbox
.stub(MessageEncrypter, 'encrypt') .stub(MessageEncrypter, 'encrypt')
.callsFake(async (_device, plainTextBuffer, _type) => ({ .callsFake(async (_device, plainTextBuffer, _type) => ({
envelopeType: stubEnvelopeType, envelopeType: messageEncyrptReturnEnvelopeType,
cipherText: plainTextBuffer, cipherText: plainTextBuffer,
})); }));
}); });
@ -50,7 +52,7 @@ describe('MessageSender', () => {
identifier: '1', identifier: '1',
device, device,
plainTextBuffer: crypto.randomBytes(10), plainTextBuffer: crypto.randomBytes(10),
encryption: 0, encryption: EncryptionType.Signal,
timestamp, timestamp,
ttl, ttl,
}); });
@ -62,7 +64,7 @@ describe('MessageSender', () => {
}); });
it('should correctly build the envelope', async () => { it('should correctly build the envelope', async () => {
stubEnvelopeType = SignalService.Envelope.Type.CIPHERTEXT; messageEncyrptReturnEnvelopeType = SignalService.Envelope.Type.CIPHERTEXT;
// This test assumes the encryption stub returns the plainText passed into it. // This test assumes the encryption stub returns the plainText passed into it.
const plainTextBuffer = crypto.randomBytes(10); const plainTextBuffer = crypto.randomBytes(10);
@ -72,7 +74,7 @@ describe('MessageSender', () => {
identifier: '1', identifier: '1',
device: '0', device: '0',
plainTextBuffer, plainTextBuffer,
encryption: 0, encryption: EncryptionType.Signal,
timestamp, timestamp,
ttl: 1, ttl: 1,
}); });
@ -100,7 +102,8 @@ describe('MessageSender', () => {
describe('UNIDENTIFIED_SENDER', () => { describe('UNIDENTIFIED_SENDER', () => {
it('should set the envelope source to be empty', async () => { it('should set the envelope source to be empty', async () => {
stubEnvelopeType = SignalService.Envelope.Type.UNIDENTIFIED_SENDER; messageEncyrptReturnEnvelopeType =
SignalService.Envelope.Type.UNIDENTIFIED_SENDER;
// This test assumes the encryption stub returns the plainText passed into it. // This test assumes the encryption stub returns the plainText passed into it.
const plainTextBuffer = crypto.randomBytes(10); const plainTextBuffer = crypto.randomBytes(10);
@ -110,7 +113,7 @@ describe('MessageSender', () => {
identifier: '1', identifier: '1',
device: '0', device: '0',
plainTextBuffer, plainTextBuffer,
encryption: 0, encryption: EncryptionType.Signal,
timestamp, timestamp,
ttl: 1, ttl: 1,
}); });
@ -134,7 +137,7 @@ describe('MessageSender', () => {
); );
expect(envelope.source).to.equal( expect(envelope.source).to.equal(
'', '',
'envelope source should not exist in UNIDENTIFIED_SENDER' 'envelope source should be empty in UNIDENTIFIED_SENDER'
); );
}); });
}); });

Loading…
Cancel
Save