Add tests
parent
b644e2a05f
commit
736cbc06da
@ -0,0 +1,47 @@
|
|||||||
|
import { expect } from 'chai';
|
||||||
|
import * as crypto from 'crypto';
|
||||||
|
import * as sinon from 'sinon';
|
||||||
|
import * as window from '../../../window';
|
||||||
|
import { MessageEncrypter } from '../../../session/crypto';
|
||||||
|
import { EncryptionType } from '../../../session/types/EncryptionType';
|
||||||
|
|
||||||
|
describe('MessageEncrypter', () => {
|
||||||
|
const sandbox = sinon.sandbox.create();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
sandbox.stub(window);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sandbox.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('EncryptionType', () => {
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
describe('SessionReset', () => {
|
||||||
|
it('should call FallbackSessionCipher', async () => {
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass the padded message body to encrypt', async () => {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Signal', () => {
|
||||||
|
it('should call SessionCipher', async () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass the padded message body to encrypt', async () => {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,27 @@
|
|||||||
|
import { SignalProtocolAddress } from "../../../../libtextsecure/libsignal-protocol";
|
||||||
|
|
||||||
|
export class SignalProtocolAddressStub extends SignalProtocolAddress {
|
||||||
|
private readonly hexEncodedPublicKey: string;
|
||||||
|
private readonly deviceId: number;
|
||||||
|
constructor(hexEncodedPublicKey: string, deviceId: number) {
|
||||||
|
super(hexEncodedPublicKey, deviceId);
|
||||||
|
this.hexEncodedPublicKey = hexEncodedPublicKey;
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line: function-name
|
||||||
|
public static fromString(encodedAddress: string): SignalProtocolAddressStub {
|
||||||
|
const values = encodedAddress.split('.');
|
||||||
|
|
||||||
|
return new SignalProtocolAddressStub(values[0], Number(values[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public getName(): string { return this.hexEncodedPublicKey; }
|
||||||
|
public getDeviceId(): number { return this.deviceId; }
|
||||||
|
|
||||||
|
public equals(other: SignalProtocolAddress): boolean {
|
||||||
|
return other.getName() === this.hexEncodedPublicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public toString(): string { return this.hexEncodedPublicKey; }
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
export * from './SignalAddressProtocolStub';
|
Loading…
Reference in New Issue