pull/1153/head
Mikunj 5 years ago
parent cd58e9b86e
commit 2e02e7d67b

@ -25,10 +25,12 @@ describe('MessageEncrypter', () => {
},
});
TestUtils.mockData('getItemById', undefined).resolves({
id: 'number_id',
value: 'abc.1',
});
TestUtils.mockData('getItemById', undefined)
.withArgs('number_id')
.resolves({
id: 'number_id',
value: 'abc.1',
});
});
afterEach(() => {
@ -40,8 +42,14 @@ describe('MessageEncrypter', () => {
describe('MediumGroup', () => {
it('should throw an error', async () => {
const data = crypto.randomBytes(10);
const promise = MessageEncrypter.encrypt('1', data, EncryptionType.MediumGroup);
await expect(promise).to.be.rejectedWith('Encryption is not yet supported');
const promise = MessageEncrypter.encrypt(
'1',
data,
EncryptionType.MediumGroup
);
await expect(promise).to.be.rejectedWith(
'Encryption is not yet supported'
);
});
});
@ -62,11 +70,13 @@ describe('MessageEncrypter', () => {
body: 'body',
});
await MessageEncrypter.encrypt('1', data, EncryptionType.Signal);
expect(stub.called).to.equal(true, 'SessionCipher.encrypt should be called.');
expect(stub.called).to.equal(
true,
'SessionCipher.encrypt should be called.'
);
});
it('should pass the padded message body to encrypt', async () => {
});
it('should pass the padded message body to encrypt', async () => {});
});
});
});

@ -8,7 +8,9 @@ export class SessionCipherBasicStub {
this.address = address;
}
public async encrypt(buffer: ArrayBuffer | Uint8Array): Promise<CipherTextObject> {
public async encrypt(
buffer: ArrayBuffer | Uint8Array
): Promise<CipherTextObject> {
throw new Error('Should stub this out');
}
}

@ -13,6 +13,9 @@ type DataFunction = typeof Shape;
*
* Note: This uses `ImportMock` so you will have to call `ImportMock.restore()` or `stub.restore()` after each test.
*/
export function mockData(fn: keyof DataFunction, returns?: any): sinon.SinonStub {
export function mockData(
fn: keyof DataFunction,
returns?: any
): sinon.SinonStub {
return ImportMock.mockFunction(Data, fn, returns);
}

@ -1,4 +1,3 @@
import { LibsignalProtocol } from './types/libsignal-protocol';
import { SignalInterface } from './types/signal';
import { LocalizerType } from '../types/Util';
@ -77,7 +76,7 @@ interface WindowInterface extends Window {
// In the case for tests
// tslint:disable-next-line: no-typeof-undefined
if (typeof(window) === 'undefined') {
if (typeof window === 'undefined') {
const globalAny: any = global;
globalAny.window = {};
}

@ -1,7 +1,5 @@
import { SignalService } from '../../protobuf';
import {
CipherTextObject,
} from './libsignal-protocol';
import { CipherTextObject } from './libsignal-protocol';
export declare class SecretSessionCipher {
constructor(storage: any);

@ -10,6 +10,7 @@ export type CipherTextObject = {
export declare class SignalProtocolAddress {
constructor(hexEncodedPublicKey: string, deviceId: number);
// tslint:disable-next-line: function-name
public static fromString(encodedAddress: string): SignalProtocolAddress;
public getName(): string;
public getDeviceId(): number;
@ -26,7 +27,11 @@ interface CurveSync {
generateKeyPair(): KeyPair;
createKeyPair(privKey: ArrayBuffer): KeyPair;
calculateAgreement(pubKey: ArrayBuffer, privKey: ArrayBuffer): ArrayBuffer;
verifySignature(pubKey: ArrayBuffer, msg: ArrayBuffer, sig: ArrayBuffer): void;
verifySignature(
pubKey: ArrayBuffer,
msg: ArrayBuffer,
sig: ArrayBuffer
): void;
calculateSignature(privKey: ArrayBuffer, message: ArrayBuffer): ArrayBuffer;
validatePubKeyFormat(pubKey: ArrayBuffer): ArrayBuffer;
}
@ -103,7 +108,9 @@ export declare class SessionCipher {
public decryptPreKeyWhisperMessage(
buffer: ArrayBuffer | Uint8Array
): Promise<ArrayBuffer>;
public decryptWhisperMessage(buffer: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>;
public decryptWhisperMessage(
buffer: ArrayBuffer | Uint8Array
): Promise<ArrayBuffer>;
public getRecord(encodedNumber: string): Promise<any | undefined>;
public getRemoteRegistrationId(): Promise<number>;
public hasOpenSession(): Promise<boolean>;

Loading…
Cancel
Save