@@ -273,6 +273,39 @@ tom.test('GET HTTPS, secure cookie attribute set - remove it', async function ()
273
273
}
274
274
} , { timeout : 120000 } )
275
275
276
+ tom . test ( 'GET HTTPS, `secure` and `SameSite=none` attributes set - remove them both' , async function ( ) {
277
+ class SecureCookie {
278
+ middleware ( config , lws ) {
279
+ return function ( ctx , next ) {
280
+ const secure = true
281
+ ctx . cookies . set ( 'test' , 'one' , { secure, sameSite : 'none' } )
282
+ ctx . body = 'test'
283
+ }
284
+ }
285
+ }
286
+ const remotePort = 10000 + this . index
287
+ const remoteLws = await Lws . create ( {
288
+ port : remotePort ,
289
+ https : true ,
290
+ stack : [ SecureCookie ]
291
+ } )
292
+
293
+ const port = 8100 + this . index
294
+ const lws = await Lws . create ( {
295
+ port,
296
+ stack : [ Rewrite , Static ] ,
297
+ rewrite : { from : '/' , to : `https://localhost:${ remotePort } /` }
298
+ } )
299
+ try {
300
+ const response = await fetch ( `http://localhost:${ port } /` )
301
+ a . strictEqual ( response . status , 200 )
302
+ a . strictEqual ( response . headers . get ( 'set-cookie' ) , 'test=one; path=/; httponly' )
303
+ } finally {
304
+ lws . server . close ( )
305
+ remoteLws . server . close ( )
306
+ }
307
+ } , { timeout : 120000 } )
308
+
276
309
tom . test ( 'GET HTTPS, --rewrite.keep-secure-attr' , async function ( ) {
277
310
class SecureCookie {
278
311
middleware ( config , lws ) {
@@ -342,4 +375,39 @@ tom.test('GET HTTPS, --rewrite.keep-secure-attr, multiple cookies', async functi
342
375
}
343
376
} , { timeout : 120000 } )
344
377
378
+ tom . test ( 'GET HTTPS, --rewrite.keep-secure-attr keeps sameSite value too, multiple cookies' , async function ( ) {
379
+ class SecureCookie {
380
+ middleware ( config , lws ) {
381
+ return function ( ctx , next ) {
382
+ const secure = true
383
+ ctx . cookies . set ( 'test' , 'one' , { secure, sameSite : 'none' } )
384
+ ctx . cookies . set ( 'test2' , 'two' , { secure, sameSite : 'none' } )
385
+ ctx . body = 'test'
386
+ }
387
+ }
388
+ }
389
+ const remotePort = 10000 + this . index
390
+ const remoteLws = await Lws . create ( {
391
+ port : remotePort ,
392
+ https : true ,
393
+ stack : [ SecureCookie ]
394
+ } )
395
+
396
+ const port = 8100 + this . index
397
+ const lws = await Lws . create ( {
398
+ port,
399
+ stack : [ Rewrite , Static ] ,
400
+ rewrite : { from : '/' , to : `https://localhost:${ remotePort } /` } ,
401
+ rewriteKeepSecureAttr : true
402
+ } )
403
+ try {
404
+ const response = await fetch ( `http://localhost:${ port } /` )
405
+ a . strictEqual ( response . status , 200 )
406
+ a . strictEqual ( response . headers . get ( 'set-cookie' ) , 'test=one; path=/; samesite=none; secure; httponly, test2=two; path=/; samesite=none; secure; httponly' )
407
+ } finally {
408
+ lws . server . close ( )
409
+ remoteLws . server . close ( )
410
+ }
411
+ } , { timeout : 120000 } )
412
+
345
413
export default tom
0 commit comments