File tree 1 file changed +21
-0
lines changed
Filter options
src/Symfony/Component/HttpKernel/Tests/HttpCache 1 file changed +21
-0
lines changed
Original file line number Diff line number Diff line change @@ -97,6 +97,27 @@ public function testSetsTheXContentDigestResponseHeaderBeforeStoring()
97
97
$ this ->assertEquals ('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 ' , $ res ['x-content-digest ' ][0 ]);
98
98
}
99
99
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
+
100
121
public function testFindsAStoredEntryWithLookup ()
101
122
{
102
123
$ this ->storeSimpleEntry ();
You can’t perform that action at this time.
0 commit comments