mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 16:42:17 +03:00
8f2dc2ff02
refs TryGhost/Ghost#9150 - added a new validator for password validations that will take care of the rules client side - Passwort rules added: - Disallow obviously bad passwords: 1234567890, qwertyuiop, asdfghjkl; and asdfghjklm - Disallow passwords that contain the words "password" or "ghost" - Disallow passwords that match the user's email address - Disallow passwords that match the blog domain or blog title - Disallow passwords that include 50% or more of the same characters: 'aaaaaaaaaa', '1111111111' and 'ababababab' for example. - When changing the own password, the old password is not affected by the new validations - Validation are running on - setup - signup - password change in Team - User (only new passwords are validated) - passwort reset
116 lines
3.8 KiB
JavaScript
116 lines
3.8 KiB
JavaScript
import {describe, it} from 'mocha';
|
|
import {run} from '@ember/runloop';
|
|
import {setupModelTest} from 'ember-mocha';
|
|
|
|
describe('Unit: Model: user', function () {
|
|
setupModelTest('user', {
|
|
needs: [
|
|
'model:role',
|
|
'serializer:application',
|
|
'serializer:user',
|
|
'service:ajax',
|
|
'service:config',
|
|
'service:ghostPaths',
|
|
'service:notifications',
|
|
'service:session'
|
|
]
|
|
});
|
|
|
|
it('has a validation type of "user"', function () {
|
|
let model = this.subject();
|
|
|
|
expect(model.get('validationType')).to.equal('user');
|
|
});
|
|
|
|
it('isActive/isSuspended properties are correct', function () {
|
|
let model = this.subject({
|
|
status: 'active'
|
|
});
|
|
|
|
expect(model.get('isActive')).to.be.ok;
|
|
expect(model.get('isSuspended')).to.not.be.ok;
|
|
|
|
['warn-1', 'warn-2', 'warn-3', 'warn-4', 'locked'].forEach(function (status) {
|
|
run(() => {
|
|
model.set('status', status);
|
|
});
|
|
expect(model.get('isActive')).to.be.ok;
|
|
expect(model.get('isSuspended')).to.not.be.ok;
|
|
});
|
|
|
|
run(() => {
|
|
model.set('status', 'inactive');
|
|
});
|
|
expect(model.get('isSuspended')).to.be.ok;
|
|
expect(model.get('isActive')).to.not.be.ok;
|
|
});
|
|
|
|
it('role property is correct', function () {
|
|
let model = this.subject();
|
|
|
|
run(() => {
|
|
let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Author'}}});
|
|
model.get('roles').pushObject(role);
|
|
});
|
|
expect(model.get('role.name')).to.equal('Author');
|
|
|
|
run(() => {
|
|
let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Editor'}}});
|
|
model.set('role', role);
|
|
});
|
|
expect(model.get('role.name')).to.equal('Editor');
|
|
});
|
|
|
|
it('isAuthor property is correct', function () {
|
|
let model = this.subject();
|
|
|
|
run(() => {
|
|
let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Author'}}});
|
|
model.set('role', role);
|
|
});
|
|
expect(model.get('isAuthor')).to.be.ok;
|
|
expect(model.get('isEditor')).to.not.be.ok;
|
|
expect(model.get('isAdmin')).to.not.be.ok;
|
|
expect(model.get('isOwner')).to.not.be.ok;
|
|
});
|
|
|
|
it('isEditor property is correct', function () {
|
|
let model = this.subject();
|
|
|
|
run(() => {
|
|
let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Editor'}}});
|
|
model.set('role', role);
|
|
});
|
|
expect(model.get('isEditor')).to.be.ok;
|
|
expect(model.get('isAuthor')).to.not.be.ok;
|
|
expect(model.get('isAdmin')).to.not.be.ok;
|
|
expect(model.get('isOwner')).to.not.be.ok;
|
|
});
|
|
|
|
it('isAdmin property is correct', function () {
|
|
let model = this.subject();
|
|
|
|
run(() => {
|
|
let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Administrator'}}});
|
|
model.set('role', role);
|
|
});
|
|
expect(model.get('isAdmin')).to.be.ok;
|
|
expect(model.get('isAuthor')).to.not.be.ok;
|
|
expect(model.get('isEditor')).to.not.be.ok;
|
|
expect(model.get('isOwner')).to.not.be.ok;
|
|
});
|
|
|
|
it('isOwner property is correct', function () {
|
|
let model = this.subject();
|
|
|
|
run(() => {
|
|
let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Owner'}}});
|
|
model.set('role', role);
|
|
});
|
|
expect(model.get('isOwner')).to.be.ok;
|
|
expect(model.get('isAuthor')).to.not.be.ok;
|
|
expect(model.get('isAdmin')).to.not.be.ok;
|
|
expect(model.get('isEditor')).to.not.be.ok;
|
|
});
|
|
});
|