File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1596,6 +1596,38 @@ Tinytest.addAsync(
15961596 }
15971597) ;
15981598
1599+
1600+ Tinytest . addAsync (
1601+ "roles -can get all users in role by scope and passes through mongo query arguments only to the users collection when included in the options" ,
1602+ async function ( test ) {
1603+ await clearData ( ) ;
1604+ await Roles . createRoleAsync ( "admin" ) ;
1605+ await Roles . createRoleAsync ( "user" ) ;
1606+
1607+ await Roles . addUsersToRolesAsync (
1608+ [ users . eve , users . joe ] ,
1609+ [ "admin" , "user" ] ,
1610+ "scope1"
1611+ ) ;
1612+ await Roles . addUsersToRolesAsync (
1613+ [ users . bob , users . joe ] ,
1614+ [ "admin" ] ,
1615+ "scope2"
1616+ ) ;
1617+
1618+ const cursor = await Roles . getUsersInRoleAsync ( "admin" , { scope : "scope1" , queryOptions : {
1619+ fields : { _id : 1 , username : 1 } ,
1620+ limit : 1 ,
1621+ } } ) ;
1622+ const results = await cursor . fetchAsync ( ) ;
1623+
1624+ test . equal ( 1 , results . length ) ;
1625+ test . isTrue ( hasProp ( results [ 0 ] , "_id" ) ) ;
1626+ test . isTrue ( hasProp ( results [ 0 ] , "username" ) ) ;
1627+ }
1628+ ) ;
1629+
1630+
15991631Tinytest . addAsync (
16001632 "roles -can use Roles.GLOBAL_SCOPE to assign blanket roles" ,
16011633 async function ( test ) {
You can’t perform that action at this time.
0 commit comments