@@ -21,6 +21,10 @@ vi.mock('@/lib/supabase/service-role.js', () => ({
2121 } ) )
2222} ) ) ;
2323
24+ function paddedCookieValue ( ) {
25+ return 'base64-eyJhY2Nlc3NfdG9rZW4iOiJhYmMiLCJwYWRkaW5nIjoieCJ9==' ;
26+ }
27+
2428function createUsersQuery ( ) {
2529 const query = {
2630 select : vi . fn ( ( ) => query ) ,
@@ -110,6 +114,27 @@ describe('GET /api/chat/conversations/[id]/participants', () => {
110114 expect ( mocks . participantEq ) . toHaveBeenCalledWith ( 'conversation_id' , 'conversation-1' ) ;
111115 } ) ;
112116
117+ it ( 'preserves equals padding in base64 auth cookies' , async ( ) => {
118+ mocks . serviceFrom . mockImplementation ( ( table ) => {
119+ if ( table === 'users' ) return createUsersQuery ( ) ;
120+ if ( table === 'conversation_participants' ) {
121+ return createParticipantCheckQuery ( ) ;
122+ }
123+ throw new Error ( `Unexpected table: ${ table } ` ) ;
124+ } ) ;
125+
126+ const { GET } = await import ( './route.js' ) ;
127+ const response = await GET (
128+ new Request ( 'https://qrypt.chat/api/chat/conversations/conversation-1/participants' , {
129+ headers : { cookie : `sb-xydzwxwsbgmznthiiscl-auth-token=${ paddedCookieValue ( ) } ` }
130+ } ) ,
131+ { params : Promise . resolve ( { id : 'conversation-1' } ) }
132+ ) ;
133+
134+ expect ( response . status ) . toBe ( 200 ) ;
135+ expect ( mocks . authGetUser ) . toHaveBeenCalledWith ( 'abc' ) ;
136+ } ) ;
137+
113138 it ( 'rejects missing async route params after authentication' , async ( ) => {
114139 mocks . serviceFrom . mockImplementation ( ( table ) => {
115140 if ( table === 'users' ) return createUsersQuery ( ) ;
0 commit comments