feature(cloudcmd) spero, ishtar, salam, remedy, omnes -> fileop

This commit is contained in:
coderaiser 2018-03-26 21:01:23 +03:00
parent cccffc57ba
commit bc25f1babb
5 changed files with 213 additions and 257 deletions

View file

@ -13,6 +13,7 @@ const {
_authenticate,
_getPrefix,
_authCheck,
_authCheckNew,
_replacePrefix,
_replaceDist,
} = cloudcmd;
@ -118,7 +119,62 @@ test('cloudcmd: replaceDist: !isDev', (t) => {
t.end();
});
test('cloudcmd: authCheck: success', (t) => {
test('cloudcmd: authCheckNew: reject', (t) => {
const auth = config('auth');
const accept = sinon.stub();
const reject = sinon.stub();
const username = 'root';
const password = 'toor';
const set = credentials();
const reset = set('hello', 'world');
config('auth', true);
_authCheckNew(accept, reject, username, password);
config('auth', auth);
reset();
t.ok(reject.called, 'should accept');
t.end();
});
test('cloudcmd: authCheckNew: accept', (t) => {
const auth = config('auth');
const accept = sinon.stub();
const reject = sinon.stub();
const username = 'root';
const password = 'toor';
const set = credentials();
const reset = set(username, password);
config('auth', true);
_authCheckNew(accept, reject, username, password);
config('auth', auth);
reset();
t.ok(accept.called, 'should accept');
t.end();
});
test('cloudcmd: authCheckNew: accept: no auth', (t) => {
const auth = config('auth');
const accept = sinon.stub();
const reject = sinon.stub();
const username = 'root';
const password = 'toor';
config('auth', false);
_authCheckNew(accept, reject, username, password);
config('auth', auth);
t.ok(accept.called, 'should accept');
t.end();
});
test('cloudcmd: authCheckNew: reject', (t) => {
const auth = config('auth');
const success = sinon.stub();
const on = sinon.stub;