@@ -2317,17 +2317,9 @@ const addAbacAttributesToUserDirectly = async (userId: string, abacAttributes: I
23172317
23182318 before ( async function ( ) {
23192319 this . timeout ( 10000 ) ;
2320- // Wait for background sync to run once before tests start
2320+ // ldap.syncNow now also syncs ABAC attributes for all users
23212321 await request . post ( `${ v1 } /ldap.syncNow` ) . set ( credentials ) ;
23222322 await sleep ( 5000 ) ;
2323-
2324- // Force abac attribute sync for user john.young, that way we test it too :p
2325- await request
2326- . post ( `${ v1 } /abac/users/sync` )
2327- . set ( credentials )
2328- . send ( { emails : [ 'john.young@space.air' ] } ) ;
2329-
2330- await sleep ( 2000 ) ;
23312323 } ) ;
23322324
23332325 it ( 'should sync LDAP user john.young with mapped ABAC attributes' , async ( ) => {
@@ -2347,55 +2339,6 @@ const addAbacAttributesToUserDirectly = async (userId: string, abacAttributes: I
23472339 } ) ;
23482340
23492341 it ( 'should sync ABAC attributes for SOME users via /abac/users/sync' , async ( ) => {
2350- // Users already imported from LDAP, but without ABAC attributes.
2351- // We now sync only SOME users, identified by their emails.
2352- const resAlan = await request . get ( `${ v1 } /users.info` ) . set ( credentials ) . query ( { username : 'alan.bean' } ) . expect ( 200 ) ;
2353- const resBuzz = await request . get ( `${ v1 } /users.info` ) . set ( credentials ) . query ( { username : 'buzz.aldrin' } ) . expect ( 200 ) ;
2354-
2355- const alanBefore = resAlan . body . user as IUser ;
2356- const buzzBefore = resBuzz . body . user as IUser ;
2357-
2358- // Ensure they start without ABAC attributes (or with an empty array)
2359- expect ( alanBefore ) . to . have . property ( 'username' , 'alan.bean' ) ;
2360- const alanBeforeAttrs = alanBefore . abacAttributes || [ ] ;
2361- expect ( alanBeforeAttrs ) . to . be . an ( 'array' ) . that . has . lengthOf ( 0 ) ;
2362-
2363- expect ( buzzBefore ) . to . have . property ( 'username' , 'buzz.aldrin' ) ;
2364- const buzzBeforeAttrs = buzzBefore . abacAttributes || [ ] ;
2365- expect ( buzzBeforeAttrs ) . to . be . an ( 'array' ) . that . has . lengthOf ( 0 ) ;
2366-
2367- // Sync SOME users by email
2368- await request
2369- . post ( `${ v1 } /abac/users/sync` )
2370- . set ( credentials )
2371- . send ( {
2372- emails : [ 'alan.bean@space.air' , 'buzz.aldrin@space.air' ] ,
2373- } )
2374- . expect ( 200 ) ;
2375-
2376- const resAlanAfter = await request . get ( `${ v1 } /users.info` ) . set ( credentials ) . query ( { username : 'alan.bean' } ) . expect ( 200 ) ;
2377- const resBuzzAfter = await request . get ( `${ v1 } /users.info` ) . set ( credentials ) . query ( { username : 'buzz.aldrin' } ) . expect ( 200 ) ;
2378-
2379- const alanAfter = resAlanAfter . body . user as IUser ;
2380- const buzzAfter = resBuzzAfter . body . user as IUser ;
2381-
2382- const alanAfterAttrs = alanAfter . abacAttributes || [ ] ;
2383- const buzzAfterAttrs = buzzAfter . abacAttributes || [ ] ;
2384-
2385- expect ( alanAfterAttrs ) . to . be . an ( 'array' ) . that . is . not . empty ;
2386- expect ( buzzAfterAttrs ) . to . be . an ( 'array' ) . that . is . not . empty ;
2387-
2388- const alanDept = alanAfterAttrs . find ( ( attr : IAbacAttributeDefinition ) => attr . key === 'department' ) ;
2389- const buzzDept = buzzAfterAttrs . find ( ( attr : IAbacAttributeDefinition ) => attr . key === 'department' ) ;
2390-
2391- expect ( alanDept ) . to . exist ;
2392- expect ( alanDept ?. values || [ ] ) . to . be . an ( 'array' ) . that . is . not . empty ;
2393-
2394- expect ( buzzDept ) . to . exist ;
2395- expect ( buzzDept ?. values || [ ] ) . to . be . an ( 'array' ) . that . is . not . empty ;
2396- } ) ;
2397-
2398- it ( 'should support /abac/users/sync with usernames as param' , async ( ) => {
23992342 await request
24002343 . post ( `${ v1 } /abac/users/sync` )
24012344 . set ( credentials )
0 commit comments