Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e798b16

Browse filesBrowse files
committed
Add tests to document the issue
1 parent cb7e78c commit e798b16
Copy full SHA for e798b16

File tree

1 file changed

+21
-0
lines changed
Filter options

1 file changed

+21
-0
lines changed

‎src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,27 @@ public function testSetsTheXContentDigestResponseHeaderBeforeStoring()
9797
$this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]);
9898
}
9999

100+
public function testDoesNotTrustXContentDigestFromUpstream()
101+
{
102+
$response = new Response('test', 200, ['X-Content-Digest' => 'untrusted-from-elsewhere']);
103+
104+
$cacheKey = $this->store->write($this->request, $response);
105+
$entries = $this->getStoreMetadata($cacheKey);
106+
[, $res] = $entries[0];
107+
108+
$this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]);
109+
$this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $response->headers->get('X-Content-Digest'));
110+
}
111+
112+
public function testWritesResponseEvenIfXContentDigestIsPresent()
113+
{
114+
// Prime the store
115+
$this->store->write($this->request, new Response('test', 200, ['X-Content-Digest' => 'untrusted-from-elsewhere']));
116+
117+
$response = $this->store->lookup($this->request);
118+
$this->assertNotNull($response);
119+
}
120+
100121
public function testFindsAStoredEntryWithLookup()
101122
{
102123
$this->storeSimpleEntry();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.