0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/test/unit/auth/validation_spec.js
Katharina Irrgang 7549473a86 🚑 Disable remote authentication (#8346)
closes #8342
- extend auth validation to deny auth type "ghost" for now
- skip some tests
2017-04-24 18:56:49 +01:00

93 lines
2.9 KiB
JavaScript

var should = require('should'),
sinon = require('sinon'),
Promise = require('bluebird'),
auth = require('../../../server/auth'),
models = require('../../../server/models'),
sandbox = sinon.sandbox.create();
/**
* See https://github.com/TryGhost/Ghost/issues/8342
* We have disabled Ghost authentication temporary.
* That's why some tests are skipped for now.
*/
describe('UNIT: auth validation', function () {
before(function () {
models.init();
});
afterEach(function () {
sandbox.restore();
});
describe('ghost is enabled', function () {
it('[failure]', function () {
return auth.validation.validate({
authType: 'ghost'
}).catch(function (err) {
should.exist(err);
err.code.should.eql('AUTH_TYPE');
});
});
it.skip('[success]', function () {
sandbox.stub(models.User, 'isSetup').returns(Promise.resolve(false));
return auth.validation.validate({
authType: 'ghost'
});
});
it.skip('[success]', function () {
sandbox.stub(models.User, 'isSetup').returns(Promise.resolve(true));
sandbox.stub(models.Client, 'findOne').returns(Promise.resolve(true));
return auth.validation.validate({
authType: 'ghost'
});
});
it.skip('[failure]', function () {
sandbox.stub(models.User, 'isSetup').returns(Promise.resolve(true));
sandbox.stub(models.Client, 'findOne').returns(Promise.resolve(true));
return auth.validation.validate({
authType: 'password'
}).catch(function (err) {
should.exist(err);
err.code.should.eql('AUTH_SWITCH');
});
});
});
describe('password is enabled', function () {
it('[success]', function () {
sandbox.stub(models.User, 'isSetup').returns(Promise.resolve(false));
return auth.validation.validate({
authType: 'password'
});
});
it('[success]', function () {
sandbox.stub(models.User, 'isSetup').returns(Promise.resolve(true));
sandbox.stub(models.Client, 'findOne').returns(Promise.resolve(false));
return auth.validation.validate({
authType: 'password'
});
});
it.skip('[failure]', function () {
sandbox.stub(models.User, 'isSetup').returns(Promise.resolve(true));
sandbox.stub(models.Client, 'findOne').returns(Promise.resolve(true));
return auth.validation.validate({
authType: 'ghost'
}).catch(function (err) {
should.exist(err);
err.code.should.eql('AUTH_SWITCH');
});
});
});
});