test(cloudcmd) coverage

This commit is contained in:
coderaiser 2018-03-30 15:12:59 +03:00
parent 0dd475fcff
commit ab83db8059
8 changed files with 74 additions and 153 deletions

View file

@ -28,7 +28,6 @@ const nomine = require('nomine');
const fileop = require('@cloudcmd/fileop');
const auth = currify(_auth);
const authenticate = currify(_authenticate);
const setUrl = currify(_setUrl);
const root = () => config('root');
@ -86,14 +85,6 @@ function getPrefix(prefix) {
return prefix || '';
}
module.exports._authCheck = authCheck;
function authCheck(socket, success) {
if (!config('auth'))
return success();
socket.on('auth', authenticate(socket, success));
}
module.exports._auth = _auth;
function _auth(accept, reject, username, password) {
if (!config('auth'))
@ -108,18 +99,6 @@ function _auth(accept, reject, username, password) {
reject();
}
module.exports._authenticate = _authenticate;
function _authenticate(socket, success, name, pass) {
const isName = name === config('username');
const isPass = pass === config('password');
if (!isName || !isPass)
return socket.emit('reject');
success();
socket.emit('accept');
}
function listen(prefix, socket) {
prefix = getPrefix(prefix);