Skip to content

Commit 723aaf1

Browse files
authored
test: cover project-scoped role claim (#102)
1 parent 50205ef commit 723aaf1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/hasRole.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ describe('hasRole', () => {
2626
expect(hasRole(user, 'admin')).toBe(false);
2727
});
2828

29+
it('should return true for project-scoped role claims', () => {
30+
const user = {
31+
profile: {
32+
sub: 'user-1',
33+
'urn:zitadel:iam:org:project:306217913633734659:roles': {
34+
admin: { '306130699507728387': 'my-org.localhost' },
35+
},
36+
},
37+
} as unknown as User;
38+
39+
expect(hasRole(user, 'admin')).toBe(true);
40+
});
41+
2942
it('should return false when there is no user', () => {
3043
expect(hasRole(null, 'admin')).toBe(false);
3144
});

0 commit comments

Comments
 (0)