1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00
Commit Graph

205 Commits

Author SHA1 Message Date
Sondre Lillebø Gundersen
2c912c3488 Fixed #33061 -- Fixed handling nonexistent keys with negative deltas in incr()/decr() in memcached backends.
Thanks Chris Jerdonek for the review.
2021-08-31 07:34:53 +02:00
Sondre Lillebø Gundersen
96ab3a1379 Refs #33061 -- Added DummyCache.incr()/decr() tests for nonexistent keys with negative deltas. 2021-08-31 07:30:57 +02:00
Michael Lissner
5a8e8f80bb Fixed #32772 -- Made database cache count size once per set. 2021-05-26 11:21:11 +02:00
Mariusz Felisiak
958cdf65ae Fixed #32747 -- Prevented initialization of unused caches.
Thanks Alexander Ebral for the report.

Regression in 98e05ccde4.
2021-05-18 18:24:19 +02:00
ecogels
a0a5e0f4c8 Fixed #32705 -- Prevented database cache backend from checking .rowcount on closed cursor.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2021-05-05 12:41:59 +02:00
Nick Pope
bb64b99b78 Fixed #29867 -- Added support for storing None value in caches.
Many of the cache operations make use of the default argument to the
.get() operation to determine whether the key was found in the cache.
The default value of the default argument is None, so this results in
these operations assuming that None is not stored in the cache when it
actually is. Adding a sentinel object solves this issue.

Unfortunately the unmaintained python-memcached library does not support
a default argument to .get(), so the previous behavior is preserved for
the deprecated MemcachedCache backend.
2020-12-17 09:57:21 +01:00
Mariusz Felisiak
5ce31d6a71
Fixed #32193 -- Deprecated MemcachedCache. 2020-12-09 21:27:32 +01:00
Florian Apolloner
98e05ccde4 Fixed #32233 -- Cleaned-up duplicate connection functionality. 2020-12-08 08:55:44 +01:00
Mariusz Felisiak
0f00560d45 Refs #32233 -- Added tests for nonexistent cache backend. 2020-12-08 08:54:54 +01:00
Mariusz Felisiak
30f2d1af03 Refs #32233 -- Added tests for nonexistent cache and databases aliases. 2020-12-08 08:54:50 +01:00
Martin Thoma
302caa40e4 Made small readability improvements. 2020-10-28 20:20:20 +01:00
Mariusz Felisiak
0f18255848
Reverted "Reduced time.sleep() in cache touch() tests."
This reverts commit 177a49e79c
which caused more frequent failures of test_touch().
2020-10-19 19:54:23 +02:00
Nick Pope
177a49e79c Reduced time.sleep() in cache touch() tests.
There are 8 cache backends to test and each test of touch() takes
~7s → ~56s. This seems excessive and it feels like we should be able
to reduce this significantly. time.sleep() accepts floating point
values and is guaranteed to sleep for at least the number of seconds
specified as of Python 3.5.

We do run the risk that there may be spurious test failures from this,
but that already seemed to be the case anyway.
2020-10-16 13:13:15 +02:00
Nick Pope
b4d46df5ca Fixed #29887 -- Added a cache backend for pymemcache. 2020-09-16 09:40:30 +02:00
Nick Pope
cda0a3d777 Refs #29887, Refs #24212 -- Added more client servers tests for PyLibMCCache. 2020-09-16 07:38:32 +02:00
Tom Carrick
bcc2befd0e Fixed #31789 -- Added a new headers interface to HttpResponse. 2020-09-14 08:41:59 +02:00
Nick Pope
a629139425 Refs #29887, Refs #24212 -- Added servers configuration hook for memcached backends.
The servers property can be overridden to allow memcached backends to
alter the server configuration prior to it being passed to instantiate
the client. This allows avoidance of documentation for per-backend
differences, e.g. stripping the 'unix:' prefix for pylibmc.
2020-09-02 08:51:17 +02:00
Nick Pope
cc1f2c6a19 Refs #29887 -- Simplified memcached client instantiation. 2020-09-01 10:51:00 +02:00
Mariusz Felisiak
1853724aca Fixed CVE-2020-24584 -- Fixed permission escalation in intermediate-level directories of the file system cache on Python 3.7+. 2020-09-01 09:17:23 +02:00
Kevin Michel
abbdd3a622 Added tests for cache middlewares constructors. 2020-08-28 10:00:39 +02:00
Nick Pope
b5acb9db75 Fixed #31907 -- Fixed missing validate_key() calls in cache backends. 2020-08-24 09:41:21 +02:00
Nick Pope
9e04b242ee Refs #31907 -- Added cache key validation tests for cache operations. 2020-08-24 09:33:55 +02:00
Claude Paroz
258c88a913 Refs #5691 -- Made cache keys independent of USE_L10N.
This mostly reverts af1893c4ff.
2020-06-22 10:55:12 +02:00
Guillermo Bonvehí
f386454d13 Fixed #31728 -- Fixed cache culling when no key is found for deletion.
DatabaseCache._cull implementation could fail if no key was found to
perform a deletion in the table. This prevented the new cache key/value
from being correctly added.
2020-06-22 06:29:35 +02:00
Mariusz Felisiak
926148ef01
Fixed #31654 -- Fixed cache key validation messages. 2020-06-05 07:21:52 +02:00
David Smith
dbdc192ca3 Preferred usage of among/while to amongst/whilst. 2020-06-03 21:02:48 +02:00
Mariusz Felisiak
229c9c6653 Refs CVE-2020-13254 -- Fixed cache.tests when KEY_PREFIX is defined.
Follow up to 2c82414914.
2020-06-03 13:00:37 +02:00
Dan Palmer
2c82414914 Fixed CVE-2020-13254 -- Enforced cache key validation in memcached backends. 2020-06-03 09:24:26 +02:00
Jon Dufresne
c1c361677d Made BaseCacheTests skip culling tests if culling is not supported. 2020-03-19 15:34:16 +01:00
Claude Paroz
4d973f5939 Refs #26601 -- Deprecated passing None as get_response arg to middleware classes.
This is the new contract since middleware refactoring in Django 1.10.

Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-02-18 20:03:44 +01:00
Claude Paroz
6fba85b766 Removed unused cache.tests.CacheUtils._set_cache().
Unused since its introduction in 71a03e01aa.
2020-02-13 13:53:12 +01:00
Hasan Ramezani
579f33eb79 Replaced assertWarns() with SimpleTestCase.assertWarnsMessage() in tests. 2020-01-30 11:19:50 +01:00
Flavio Curella
d08d4f464a Fixed #30765 -- Made cache_page decorator take precedence over max-age Cache-Control directive. 2020-01-16 13:39:16 +01:00
Jon Dufresne
9762617a03 Improved tests assertions in cache tests.
Added assertions to compare results of .add(), .delete(), .touch(),
.incr(), .decr(), and .get_or_set() methods.

Made tests use assertIs() rather than assertTrue/False().
2019-12-31 12:49:36 +01:00
Jon Dufresne
8ea3ff155e Fixed typo in tests/cache/tests.py docstring. 2019-12-11 17:39:21 +01:00
daniel a rios
efc3e32d6d Fixed #30759 -- Made cache.delete() return whether it succeeded.
Thanks Simon Charette for the review.
2019-11-14 11:14:11 +01:00
Jon Dufresne
74f2a58b3a Refs #29983 -- Added tests for FileBasedCache pathlib support. 2019-11-06 10:01:01 +01:00
Nick Pope
7552de7866 Used more specific unittest assertions in tests.
* assertIsNone()/assertIsNotNone() instead of comparing to None.
* assertLess() for < comparisons.
* assertIs() for 'is' expressions.
* assertIsInstance() for isinstance() expressions.
* rounding of assertAlmostEqual() for round() expressions.
* assertIs(..., True/False) instead of comparing to True/False.
* assertIs()/assertIsNot() for ==/!= comparisons.
* assertNotEqual() for == comparisons.
* assertTrue()/assertFalse() instead of comparing to True/False.
2019-10-29 12:37:30 +01:00
Flavio Curella
ed112fadc1 Fixed #23755 -- Added support for multiple field names in the no-cache Cache-Control directive to patch_cache_control().
https://tools.ietf.org/html/rfc7234#section-5.2.2.2
2019-10-10 19:30:51 +02:00
Flavio Curella
9facc90020 Refs #23755 -- Added tests for patch_cache_control() with no-cache Cache-Control directive. 2019-10-10 12:24:52 +02:00
Daniel Fairhead
5cb3ed187b Fixed #30772 -- Optimized make_template_fragment_key().
Removed usage of urllib.quote(), unnecessary since cbbe60c7fc.
Used hasher's .update() on key fragments.
2019-09-18 14:53:05 +02:00
Adnan Umer
6805c0f99f Fixed #30701 -- Updated patch_vary_headers() to handle an asterisk according to RFC 7231. 2019-08-16 15:25:42 +02:00
Jakub Szafrański
0104b5a417 Fixed #30181 -- Made cache.get() with default work correctly on PyLibMCCache if None is cached. 2019-02-14 19:57:38 -05:00
Jon Dufresne
7785e03ba8 Fixed #30137 -- Replaced OSError aliases with the canonical OSError.
Used more specific errors (e.g. FileExistsError) as appropriate.
2019-01-28 11:15:06 -05:00
Jon Dufresne
00b2e4b67c Added missing assert in FileBasedCacheTests.test_creates_cache_dir_if_nonexistent(). 2019-01-26 16:38:46 -05:00
Simon Charette
8c775391b7 Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases. 2019-01-10 19:11:21 -05:00
Simon Charette
0f212db29d Made reused RequestFactory instances class attributes. 2018-11-27 09:49:02 -05:00
Tim Graham
193c109327 Switched TestCase to SimpleTestCase where possible in Django's tests. 2018-11-27 08:58:44 -05:00
oliver
abd0ad7681 Fixed #29626, #29584 -- Added optimized versions of get_many() and delete_many() for the db cache backend. 2018-08-17 15:13:09 -04:00
oliver
3ca24fd1c0 Optimized some cache tests with set_many(). 2018-08-16 09:02:21 -04:00