Skip to content

Commit

Permalink
fixup! lib: emit events about connection messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lundibundi committed Jul 14, 2017
1 parent 9873ed7 commit 555b4c6
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions test/node/connection-emit-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const jstp = require('../..');
const app = require('../fixtures/application');

const application = new jstp.Application(app.name, app.interfaces);
const serverConfig =
{ applications: [application], authPolicy: app.authCallback };
const serverConfig = {
applications: [application],
authPolicy: app.authCallback
};

let server;
let connection;
Expand Down Expand Up @@ -48,18 +50,20 @@ test.test('must emit server and client events upon anonymous handshake',

const port = server.address().port;
const socket = net.connect(port);
socket.on('error',
() => test.fail('must create socket and connect to server'));
socket.on('error', () => {
test.fail('must create socket and connect to server');
});
socket.on('connect', () => {
serverConnection.on('handshakeRequest',
(applicationName, authStrategy, credentials) => {
test.equal(applicationName, app.name,
'application name must match');
test.equal(authStrategy, 'anonymous',
'auth strategy must be anonymous by default');
test.assertNot(credentials,
'credentials must not exist with anonymous handshake');
});
(applicationName, authStrategy, credentials) => {
test.equal(applicationName, app.name,
'application name must match');
test.equal(authStrategy, 'anonymous',
'auth strategy must be anonymous by default');
test.assertNot(credentials,
'credentials must not exist with anonymous handshake');
}
);

const transport = new jstp.net.Transport(socket);
const connection = new jstp.Connection(transport, null, client);
Expand Down Expand Up @@ -95,18 +99,20 @@ test.test('must emit server and client events upon login/password handshake',

const port = server.address().port;
const socket = net.connect(port);
socket.on('error',
() => test.fail('must create socket and connect to server'));
socket.on('error', () => {
test.fail('must create socket and connect to server');
});
socket.on('connect', () => {
serverConnection.on('handshakeRequest',
(applicationName, authStrategy, credentials) => {
test.equal(applicationName, app.name,
'application name must match');
test.equal(authStrategy, 'login',
'auth strategy must be \'login\' with login/password');
test.strictSame(credentials, [app.login, app.password],
'credentials must match upon login/password handshake');
});
(applicationName, authStrategy, credentials) => {
test.equal(applicationName, app.name,
'application name must match');
test.equal(authStrategy, 'login',
'auth strategy must be \'login\' with login/password');
test.strictSame(credentials, [app.login, app.password],
'credentials must match upon login/password handshake');
}
);

const transport = new jstp.net.Transport(socket);
const connection = new jstp.Connection(transport, null, client);
Expand Down

0 comments on commit 555b4c6

Please sign in to comment.