@@ -7,9 +7,10 @@ import weaviate, {
77 RolesAction ,
88 TenantsAction ,
99 WeaviateClient ,
10+ UserAssignment ,
1011} from '..' ;
12+ import { requireAtLeast } from '../../test/version' ;
1113import { WeaviateStartUpError , WeaviateUnexpectedStatusCodeError } from '../errors' ;
12- import { DbVersion } from '../utils/dbVersion' ;
1314
1415type TestCase = {
1516 roleName : string ;
@@ -278,11 +279,11 @@ const testCases: TestCase[] = [
278279 } ,
279280] ;
280281
281- const maybe = DbVersion . fromString ( `v ${ process . env . WEAVIATE_VERSION ! } ` ) . isAtLeast ( 1 , 29 , 0 )
282- ? describe
283- : describe . skip ;
284-
285- maybe ( 'Integration testing of the roles namespace' , ( ) => {
282+ requireAtLeast (
283+ 1 ,
284+ 29 ,
285+ 0
286+ ) ( 'Integration testing of the roles namespace' , ( ) => {
286287 let client : WeaviateClient ;
287288
288289 beforeAll ( async ( ) => {
@@ -316,6 +317,37 @@ maybe('Integration testing of the roles namespace', () => {
316317 expect ( exists ) . toBeFalsy ( ) ;
317318 } ) ;
318319
320+ requireAtLeast (
321+ 1 ,
322+ 30 ,
323+ 0
324+ ) ( 'namespaced users' , ( ) => {
325+ it ( 'retrieves assigned users with namespace' , async ( ) => {
326+ await client . roles . create ( 'landlord' , {
327+ collection : 'Buildings' ,
328+ tenant : 'john doe' ,
329+ actions : [ 'create_tenants' , 'delete_tenants' ] ,
330+ } ) ;
331+
332+ await client . users . db . create ( 'Innkeeper' ) . catch ( ( res ) => expect ( res . code ) . toEqual ( 409 ) ) ;
333+
334+ await client . users . db . assignRoles ( 'landlord' , 'custom-user' ) ;
335+ await client . users . db . assignRoles ( 'landlord' , 'Innkeeper' ) ;
336+
337+ const assignments = await client . roles . userAssignments ( 'landlord' ) ;
338+
339+ expect ( assignments ) . toEqual (
340+ expect . arrayContaining ( [
341+ expect . objectContaining < UserAssignment > ( { id : 'custom-user' , userType : 'db_env_user' } ) ,
342+ expect . objectContaining < UserAssignment > ( { id : 'Innkeeper' , userType : 'db_user' } ) ,
343+ ] )
344+ ) ;
345+
346+ await client . users . db . delete ( 'Innkeeper' ) ;
347+ await client . roles . delete ( 'landlord' ) ;
348+ } ) ;
349+ } ) ;
350+
319351 describe ( 'should be able to create roles using the permissions factory' , ( ) => {
320352 testCases . forEach ( ( testCase ) => {
321353 it ( `with ${ testCase . roleName } permissions` , async ( ) => {
0 commit comments