@@ -473,6 +473,62 @@ public function testAPrivateCacheStoresAResponseWithPrivateDirective()
473473 self ::assertSame ('foo ' , $ response ->getContent ());
474474 }
475475
476+ public function testASharedCacheDoesntStoreAResponseWithAuthenticationHeader ()
477+ {
478+ $ mockClient = new MockHttpClient ([
479+ new MockResponse ('foo ' , [
480+ 'http_code ' => 200 ,
481+ 'response_headers ' => [
482+ 'Cache-Control ' => 'max-age=300 ' ,
483+ 'Set-Cookie ' => 'foo=bar ' ,
484+ ],
485+ ]),
486+ new MockResponse ('bar ' ),
487+ ]);
488+
489+ $ client = new CachingHttpClient (
490+ $ mockClient ,
491+ $ this ->cacheAdapter ,
492+ sharedCache: true ,
493+ );
494+
495+ $ response = $ client ->request ('GET ' , 'http://example.com/foo-bar ' );
496+ self ::assertSame (200 , $ response ->getStatusCode ());
497+ self ::assertSame ('foo ' , $ response ->getContent ());
498+
499+ $ response = $ client ->request ('GET ' , 'http://example.com/foo-bar ' );
500+ self ::assertSame (200 , $ response ->getStatusCode ());
501+ self ::assertSame ('bar ' , $ response ->getContent ());
502+ }
503+
504+ public function testAPrivateCacheStoresAResponseWithAuthenticationHeader ()
505+ {
506+ $ mockClient = new MockHttpClient ([
507+ new MockResponse ('foo ' , [
508+ 'http_code ' => 200 ,
509+ 'response_headers ' => [
510+ 'Cache-Control ' => 'max-age=300 ' ,
511+ 'Set-Cookie ' => 'foo=bar ' ,
512+ ],
513+ ]),
514+ new MockResponse ('should not be served ' ),
515+ ]);
516+
517+ $ client = new CachingHttpClient (
518+ $ mockClient ,
519+ $ this ->cacheAdapter ,
520+ sharedCache: false ,
521+ );
522+
523+ $ response = $ client ->request ('GET ' , 'http://example.com/foo-bar ' );
524+ self ::assertSame (200 , $ response ->getStatusCode ());
525+ self ::assertSame ('foo ' , $ response ->getContent ());
526+
527+ $ response = $ client ->request ('GET ' , 'http://example.com/foo-bar ' );
528+ self ::assertSame (200 , $ response ->getStatusCode ());
529+ self ::assertSame ('foo ' , $ response ->getContent ());
530+ }
531+
476532 public function testCacheMissAfterInvalidation ()
477533 {
478534 $ mockClient = new MockHttpClient ([
0 commit comments