Skip to content

Commit 551cdaf

Browse files
committed
feat(cloudflare-cache-header-middleware): added assertions to ensure cookies are being stripped
1 parent f7c8fd8 commit 551cdaf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/Feature/app/Http/Middleware/CloudflareCacheHeaderMiddlewareTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ private function markerEndpointDataProvider()
3030
/**
3131
* @dataProvider markerEndpointDataProvider
3232
*/
33-
public function test_handle_sets_cache_for_api_endpoints($uri)
33+
public function test_handle_sets_cache_and_strips_cookies_for_api_endpoints($uri)
3434
{
3535
$response = $this->get($uri);
36+
$this->assertCount(0, $response->headers->getCookies(), 'the response should not include any cookie headers');
3637
$this->assertEquals('max-age=60, public, s-maxage=60', $response->headers->get('cache-control'), 'resource should be declared public for cloudflare to cache');
3738
}
3839

@@ -49,9 +50,10 @@ private function pageDataProvider()
4950
/**
5051
* @dataProvider pageDataProvider
5152
*/
52-
public function test_handle_does_not_set_cache_for_page_endpoints($uri)
53+
public function test_handle_does_not_set_cache_or_strip_cookies_for_page_endpoints($uri)
5354
{
5455
$response = $this->get($uri);
56+
$this->assertCount(2, $response->headers->getCookies(), 'the response should include cookie headers');
5557
$this->assertEquals('no-cache, private', $response->headers->get('cache-control'), 'resource should be declared public for cloudflare to cache');
5658
}
5759
}

0 commit comments

Comments
 (0)