groups: members cannot be set for external groups
This commit is contained in:
+18
-10
@@ -18,10 +18,10 @@ describe('Groups', function () {
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
describe('add/get/del', function () {
|
||||
let group0Name = 'administrators', group0Object;
|
||||
let group1Name = 'externs', group1Object;
|
||||
let group0Name = 'administrators', group0Object;
|
||||
let group1Name = 'externs', group1Object;
|
||||
|
||||
describe('add', function () {
|
||||
it('cannot add group - too small', async function () {
|
||||
const [error] = await safe(groups.add({ name: '' }));
|
||||
expect(error.reason).to.be(BoxError.BAD_FIELD);
|
||||
@@ -72,7 +72,9 @@ describe('Groups', function () {
|
||||
const [error] = await safe(groups.add({name: group0Name, source: 'ldap' }));
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
});
|
||||
});
|
||||
|
||||
describe('get', function () {
|
||||
it('cannot get invalid group', async function () {
|
||||
const result = await groups.get('sometrandom');
|
||||
expect(result).to.be(null);
|
||||
@@ -82,18 +84,20 @@ describe('Groups', function () {
|
||||
const result = await groups.get(group0Object.id);
|
||||
expect(result.name).to.equal(group0Name);
|
||||
});
|
||||
});
|
||||
|
||||
describe('members', function () {
|
||||
it('isMember returns false', async function () {
|
||||
const isMember = await groups.isMember(group0Object.id, admin.id);
|
||||
expect(isMember).to.be(false);
|
||||
});
|
||||
|
||||
it('can set members', async function () {
|
||||
await groups.setMembers(group0Object.id, [ admin.id, user.id ]);
|
||||
await groups.setMembers(group0Object, [ admin.id, user.id ], {});
|
||||
});
|
||||
|
||||
it('cannot set duplicate members', async function () {
|
||||
const [error] = await safe(groups.setMembers(group0Object.id, [ admin.id, user.id, admin.id ]));
|
||||
const [error] = await safe(groups.setMembers(group0Object, [ admin.id, user.id, admin.id ], {}));
|
||||
expect(error.reason).to.be(BoxError.CONFLICT);
|
||||
});
|
||||
|
||||
@@ -127,17 +131,17 @@ describe('Groups', function () {
|
||||
expect(result.userIds).to.eql([ admin.id ]);
|
||||
});
|
||||
|
||||
it('can set groups', async function () {
|
||||
await groups.setMembership(admin.id, [ group0Object.id ]);
|
||||
it('can set group membership', async function () {
|
||||
await groups.setMembership(admin, [ group0Object.id ]);
|
||||
});
|
||||
|
||||
it('cannot set user to same group twice', async function () {
|
||||
const [error] = await safe(groups.setMembership(admin.id, [ group0Object.id, group0Object.id ]));
|
||||
const [error] = await safe(groups.setMembership(admin, [ group0Object.id, group0Object.id ]));
|
||||
expect(error.reason).to.be(BoxError.CONFLICT);
|
||||
});
|
||||
|
||||
it('can set user to multiple groups', async function () {
|
||||
await groups.setMembership(admin.id, [ group0Object.id, group1Object.id ]);
|
||||
await groups.setMembership(admin, [ group0Object.id, group1Object.id ]);
|
||||
});
|
||||
|
||||
it('can get groups membership', async function () {
|
||||
@@ -145,7 +149,9 @@ describe('Groups', function () {
|
||||
expect(groupIds.length).to.be(2);
|
||||
expect(groupIds.sort()).to.eql([ group0Object.id, group1Object.id ].sort());
|
||||
});
|
||||
});
|
||||
|
||||
describe('list', function () {
|
||||
it('can list', async function () {
|
||||
const result = await groups.list();
|
||||
expect(result.length).to.be(2);
|
||||
@@ -160,14 +166,16 @@ describe('Groups', function () {
|
||||
expect(result[1].userIds).to.eql([ admin.id ]);
|
||||
expect(result[1].name).to.be(group1Name);
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', function () {
|
||||
it('cannot delete invalid group', async function () {
|
||||
const [error] = await safe(groups.remove('random'));
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
});
|
||||
|
||||
it('can delete valid group', async function () {
|
||||
await groups.setMembers(group0Object.id, [ admin.id, user.id ]); // ensure group has some members
|
||||
await groups.setMembers(group0Object, [ admin.id, user.id ], {}); // ensure group has some members
|
||||
await groups.remove(group0Object.id);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user