groups: add app access tests
This commit is contained in:
@@ -13,7 +13,7 @@ const BoxError = require('../boxerror.js'),
|
||||
safe = require('safetydance');
|
||||
|
||||
describe('Groups', function () {
|
||||
const { setup, cleanup, admin, user, auditSource } = common;
|
||||
const { setup, cleanup, admin, user, auditSource, app } = common;
|
||||
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
@@ -196,6 +196,63 @@ describe('Groups', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('app access', function () {
|
||||
let groupObject;
|
||||
|
||||
before(async function () {
|
||||
const [error, result] = await safe(groups.add({ name: 'kootam' }, auditSource));
|
||||
expect(error).to.be(null);
|
||||
groupObject = result;
|
||||
});
|
||||
|
||||
it('has no app access', async function () {
|
||||
expect(groupObject.appIds).to.eql([]);
|
||||
|
||||
const g1 = await groups.get(groupObject.id);
|
||||
expect(g1.appIds).to.eql([]);
|
||||
|
||||
const g2 = await groups.getByName(groupObject.name);
|
||||
expect(g2.appIds).to.eql([]);
|
||||
|
||||
const g3 = await groups.getWithMembers(groupObject.id);
|
||||
expect(g3.appIds).to.eql([]);
|
||||
});
|
||||
|
||||
it('set app access', async function () {
|
||||
await groups.setAllowedApps(groupObject, [ app.id ], auditSource);
|
||||
|
||||
const g1 = await groups.get(groupObject.id);
|
||||
expect(g1.appIds).to.eql([ app.id ]);
|
||||
|
||||
const g2 = await groups.getByName(groupObject.name);
|
||||
expect(g2.appIds).to.eql([ app.id ]);
|
||||
|
||||
const g3 = await groups.getWithMembers(groupObject.id);
|
||||
expect(g3.appIds).to.eql([ app.id ]);
|
||||
|
||||
const allGroups = await groups.listWithMembers();
|
||||
const g4 = allGroups.filter(g => g.id === groupObject.id)[0];
|
||||
expect(g4.appIds).to.eql([ app.id ]);
|
||||
});
|
||||
|
||||
it('cleared app access', async function () {
|
||||
await groups.setAllowedApps(groupObject, [ ], auditSource);
|
||||
|
||||
const g1 = await groups.get(groupObject.id);
|
||||
expect(g1.appIds).to.eql([ ]);
|
||||
|
||||
const g2 = await groups.getByName(groupObject.name);
|
||||
expect(g2.appIds).to.eql([ ]);
|
||||
|
||||
const g3 = await groups.getWithMembers(groupObject.id);
|
||||
expect(g3.appIds).to.eql([ ]);
|
||||
|
||||
const allGroups = await groups.listWithMembers();
|
||||
const g4 = allGroups.filter(g => g.id === groupObject.id)[0];
|
||||
expect(g4.appIds).to.eql([ ]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ldap group', function () {
|
||||
let ldapGroup;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user