| | 313 | #-------------------------------------------------------------------------- |
| | 314 | |
| | 315 | def test_wrong_url(self): |
| | 316 | """ |
| | 317 | Test if the cache middleware checks bad characters in the url. |
| | 318 | Normaly the urls-re doesn't match on bad urls. But the process_request |
| | 319 | method of a middleware called before this. |
| | 320 | """ |
| | 321 | content = "Should never comes from the cache!" |
| | 322 | shortcut = "bad$char&here" |
| | 323 | url = "/%s/" % shortcut |
| | 324 | cache_key = settings.PAGE_CACHE_PREFIX + shortcut |
| | 325 | |
| | 326 | # Insert a cache entry, so the cache middleware can found the cached |
| | 327 | # page and will be response the cached content, if the shortcut will |
| | 328 | # not be veryfied. |
| | 329 | response = HttpResponse(content) |
| | 330 | cache.set(cache_key, response, 9999) |
| | 331 | |
| | 332 | # Request the cached page and check the response. It should not resonse |
| | 333 | # the cached content. It should be apperar a 404 page not found. |
| | 334 | response = self.client.get(url) |
| | 335 | #debug_response(response) |
| | 336 | self.failUnlessEqual(response.status_code, 404) |
| | 337 | self.assertResponse(response, must_not_contain=(content,)) |
| | 338 | |