blob: e6b2c25486dd16196b21e98274a0e0aad4cd361c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// @flow
import { setupIpcAndStore, setupBackendAndStore } from './helpers/ipc-helpers';
import { IpcChain } from './helpers/IpcChain';
import { Backend } from '../app/lib/backend';
describe('authentication', () => {
it('authenticates before ipc call if unauthenticated', (done) => {
const { store, mockIpc } = setupIpcAndStore();
const chain = new IpcChain(mockIpc);
chain.onSuccessOrFailure(done);
chain.expect('authenticate').withInputValidation((secret) => {
expect(secret).to.equal(credentials.sharedSecret);
});
chain.expect('connect');
const credentials = {
sharedSecret: '',
connectionString: '',
};
const backend = new Backend(store, credentials, mockIpc);
backend.connect();
});
it('reauthenticates on reconnect', async () => {
const { mockIpc, backend } = setupBackendAndStore();
mockIpc.authenticate = spy(mockIpc.authenticate);
mockIpc.killWebSocket();
expect(mockIpc.authenticate).to.not.have.been.called();
await backend.connect();
expect(mockIpc.authenticate).to.have.been.called.once;
});
});
|