Make canonicalScopeString return sorted array

This commit is contained in:
Girish Ramakrishnan
2018-06-27 14:07:25 -07:00
parent ce4424d115
commit d66dc11f01
2 changed files with 14 additions and 10 deletions

View File

@@ -16,11 +16,7 @@ describe('access control', function () {
});
it('identity for non-*', function () {
expect(accesscontrol.canonicalScopeString('foo,bar')).to.be('foo,bar');
});
it('* is not expanded otherwise', function () {
expect(accesscontrol.canonicalScopeString('foo,bar,*')).to.be('foo,bar,*');
expect(accesscontrol.canonicalScopeString('foo,bar')).to.be('bar,foo'); // becomes sorted
});
});
@@ -35,7 +31,12 @@ describe('access control', function () {
});
it('everything is different', function () {
expect(accesscontrol.intersectScopes(['cloudron', 'domains' ], ['clients', 'apps'])).to.eql('');
expect(accesscontrol.intersectScopes(['cloudron', 'domains' ], ['clients', 'apps'])).to.eql([]);
});
xit('subscopes', function () {
expect(accesscontrol.intersectScopes(['apps:read' ], ['apps'])).to.eql(['apps:read']);
expect(accesscontrol.intersectScopes(['apps:read','profile','domains'], ['apps','domains:manage','profile'])).to.eql(['apps:read','domains:manage','profile']);
});
});