@@ -798,15 +798,14 @@ describe('an SSO sign-in grants the permission set its IdP group is mapped to',
798798
799799 it ( 'the break-glass guard still refuses through the sign-in: the last administrator\'s grant is not removed, and the sign-in still lands' , async ( ) => {
800800 const rp = await makeGroupRp ( ) ;
801- // Mia already exists and is the only administrator, through a grant carrying this provider's marker.
802- await rp . engine . delete ( 'sys_user' , { where : { id : 'usr_admin' } } , SYSTEM as never ) ;
803- await rp . engine . insert ( 'sys_user' , { id : 'usr_mia' , email : EMAIL , name : 'Mia Chen' , email_verified : true } , SYSTEM ) ;
801+ // Mia is the only administrator, through a grant carrying this provider's marker
802+ // (a row the projection would remove: no mapping names it).
803+ const { userId } = await signInWithClaims ( rp , { groups : [ ] } ) ;
804804 await rp . engine . insert ( 'sys_user_permission_set' , {
805- user_id : 'usr_mia' , permission_set : ADMIN_FULL_ACCESS , organization_id : DEFAULT_ORG , reason : SSO_MARKER ,
805+ user_id : userId , permission_set : ADMIN_FULL_ACCESS , organization_id : DEFAULT_ORG , reason : SSO_MARKER ,
806806 } , SYSTEM ) ;
807807
808- const { userId } = await signInWithClaims ( rp , { groups : [ ] } ) ;
809- expect ( userId ) . toBe ( 'usr_mia' ) ;
808+ await signInWithClaims ( rp , { groups : [ ] } ) ;
810809 expect ( await grantsOf ( rp , userId ) ) . toEqual ( [ { permission_set : ADMIN_FULL_ACCESS , organization_id : DEFAULT_ORG , reason : SSO_MARKER } ] ) ;
811810 expect ( rp . error ) . toHaveBeenCalledTimes ( 1 ) ;
812811 expect ( String ( rp . error . mock . calls [ 0 ] [ 0 ] ) ) . toMatch ( / a p p l y i n g t h e p r o v i d e r ' s I d P g r o u p m a p p i n g s .* F A I L E D / ) ;
0 commit comments