principaltype tests

This commit is contained in:
Miroslav Bajtoš 2018-03-23 10:38:08 +01:00
parent 77a35231dc
commit f77442706e
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
1 changed files with 42 additions and 0 deletions

View File

@ -212,6 +212,48 @@ describe('Multiple users with custom principalType', function() {
});
describe('getUser()', function() {
it('returns correct principalType', () => {
return Promise.all([
OneUser.login(commonCredentials),
AnotherUser.login(commonCredentials),
]).spread((userOneToken, userTwoToken) => {
let context = new AccessContext({
registry: OneUser.registry,
accessToken: userOneToken,
});
expect(context.getUser()).to.eql({
id: userFromOneModel.id,
principalType: OneUser.modelName,
});
context = new AccessContext({
registry: AnotherUser.registry,
accessToken: userTwoToken,
});
expect(context.getUser()).to.eql({
id: userFromAnotherModel.id,
principalType: AnotherUser.modelName,
});
});
});
it('another getUser test', () => {
addToAccessContext([
{type: Principal.ROLE},
{type: Principal.APP},
{type: Principal.SCOPE},
{type: OneUser.modelName, id: userFromOneModel.id},
]);
const user = accessContext.getUser();
expect(user).to.eql({
id: userFromOneModel.id,
principalType: OneUser.modelName,
});
});
it('returns user although principals contain non USER principals',
function() {
return Promise.try(function() {