* Update find-port.js Reuse the Port Number Generator * feat(passive): initialize port factory in server Ensures that each passive connection does not have to start from the beginning of the pasv port range https://github.com/trs/ftp-srv/pull/110 * fix(connector): ensure data socket is destroyed and resolved If there was a data socket, this would never resolve * test: use bluebird promises for tests, fix stubs * fix(commands): ensure connector is ended before resuming
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const Promise = require('bluebird');
|
|
const {expect} = require('chai');
|
|
const sinon = require('sinon');
|
|
|
|
const CMD = 'AUTH';
|
|
describe(CMD, function () {
|
|
let sandbox;
|
|
const mockClient = {
|
|
reply: () => Promise.resolve(),
|
|
server: {
|
|
_tls: {}
|
|
}
|
|
};
|
|
const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient);
|
|
|
|
beforeEach(() => {
|
|
sandbox = sinon.sandbox.create().usingPromise(Promise);
|
|
|
|
sandbox.spy(mockClient, 'reply');
|
|
});
|
|
afterEach(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
it('TLS // supported', () => {
|
|
return cmdFn({command: {arg: 'TLS', directive: CMD}})
|
|
.then(() => {
|
|
expect(mockClient.reply.args[0][0]).to.equal(234);
|
|
expect(mockClient.secure).to.equal(true);
|
|
});
|
|
});
|
|
|
|
it('SSL // not supported', () => {
|
|
return cmdFn({command: {arg: 'SSL', directive: CMD}})
|
|
.then(() => {
|
|
expect(mockClient.reply.args[0][0]).to.equal(504);
|
|
});
|
|
});
|
|
|
|
it('bad // bad', () => {
|
|
return cmdFn({command: {arg: 'bad', directive: CMD}})
|
|
.then(() => {
|
|
expect(mockClient.reply.args[0][0]).to.equal(504);
|
|
});
|
|
});
|
|
});
|