validateRequestedScopes -> hasScopes

This commit is contained in:
Girish Ramakrishnan
2018-06-14 16:32:24 -07:00
parent f7089c52ff
commit dc86b0f319
3 changed files with 27 additions and 15 deletions

View File

@@ -44,6 +44,18 @@ describe('access control', function () {
it('everything is different', function () {
expect(accesscontrol.intersectScope('cloudron,domains', 'clients,apps')).to.be('');
});
});
describe('hasScopes', function () {
it('succeeds if it contains the scope', function () {
expect(accesscontrol.hasScopes({ scope: 'apps' }, [ 'apps' ])).to.be(null);
expect(accesscontrol.hasScopes({ scope: 'apps,mail' }, [ 'mail' ])).to.be(null);
expect(accesscontrol.hasScopes({ scope: 'clients,*,apps,mail' }, [ 'mail' ])).to.be(null);
});
it('fails if it does not contain the scope', function () {
expect(accesscontrol.hasScopes({ scope: 'apps' }, [ 'mail' ])).to.be.an(Error);
expect(accesscontrol.hasScopes({ scope: 'apps,mail' }, [ 'clients' ])).to.be.an(Error);
});
});
});