Move GroupsError to BoxError
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
database = require('../database.js'),
|
||||
DatabaseError = require('../databaseerror.js'),
|
||||
expect = require('expect.js'),
|
||||
groups = require('../groups.js'),
|
||||
GroupsError = groups.GroupsError,
|
||||
hat = require('../hat.js'),
|
||||
mailboxdb = require('../mailboxdb.js'),
|
||||
userdb = require('../userdb.js');
|
||||
@@ -79,35 +79,35 @@ describe('Groups', function () {
|
||||
|
||||
it('cannot create group - too small', function (done) {
|
||||
groups.create('', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.BAD_FIELD);
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot create group - too big', function (done) {
|
||||
groups.create(new Array(256).join('a'), function (error) {
|
||||
expect(error.reason).to.be(GroupsError.BAD_FIELD);
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot create group - bad name', function (done) {
|
||||
groups.create('bad:name', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.BAD_FIELD);
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot create group - reserved', function (done) {
|
||||
groups.create('users', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.BAD_FIELD);
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot create group - invalid', function (done) {
|
||||
groups.create('cloudron+admin', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.BAD_FIELD);
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -123,21 +123,21 @@ describe('Groups', function () {
|
||||
it('cannot create existing group with mixed case', function (done) {
|
||||
var name = GROUP0_NAME[0].toUpperCase() + GROUP0_NAME.substr(1);
|
||||
groups.create(name, function (error) {
|
||||
expect(error.reason).to.be(GroupsError.ALREADY_EXISTS);
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot add existing group', function (done) {
|
||||
groups.create(GROUP0_NAME, function (error) {
|
||||
expect(error.reason).to.be(GroupsError.ALREADY_EXISTS);
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot get invalid group', function (done) {
|
||||
groups.get('sometrandom', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -152,7 +152,7 @@ describe('Groups', function () {
|
||||
|
||||
it('cannot delete invalid group', function (done) {
|
||||
groups.remove('random', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -191,14 +191,14 @@ describe('Group membership', function () {
|
||||
|
||||
it('cannot add non-existent user', function (done) {
|
||||
groups.addMember(group0Object.id, 'randomuser', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot add non-existent group', function (done) {
|
||||
groups.addMember('randomgroup', USER_0.id, function (error) {
|
||||
expect(error.reason).to.be(GroupsError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -252,14 +252,14 @@ describe('Group membership', function () {
|
||||
|
||||
it('cannot remove non-existent user', function (done) {
|
||||
groups.removeMember(group0Object.id, 'randomuser', function (error) {
|
||||
expect(error.reason).to.be(GroupsError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot remove non-existent group', function (done) {
|
||||
groups.removeMember('randomgroup', USER_0.id, function (error) {
|
||||
expect(error.reason).to.be(GroupsError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user