Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ticket 18163 - use faster password hasher in tests. #28

Merged
merged 3 commits into from almost 2 years ago

2 participants

Anssi Kääriäinen Karen Tracey
Anssi Kääriäinen
Owner

No description provided.

Karen Tracey kmtracey merged commit b86a001 into from
Karen Tracey kmtracey closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
9  django/contrib/auth/hashers.py
... ...
@@ -1,6 +1,8 @@
1 1
 import hashlib
2 2
 
  3
+from django.dispatch import receiver
3 4
 from django.conf import settings
  5
+from django.test.signals import setting_changed
4 6
 from django.utils import importlib
5 7
 from django.utils.datastructures import SortedDict
6 8
 from django.utils.encoding import smart_str
@@ -14,6 +16,13 @@
14 16
 HASHERS = None  # lazily loaded from PASSWORD_HASHERS
15 17
 PREFERRED_HASHER = None  # defaults to first item in PASSWORD_HASHERS
16 18
 
  19
+@receiver(setting_changed)
  20
+def reset_hashers(**kwargs):
  21
+    if kwargs['setting'] == 'PASSWORD_HASHERS':
  22
+        global HASHERS, PREFERRED_HASHER
  23
+        HASHERS = None
  24
+        PREFERRED_HASHER = None
  25
+
17 26
 
18 27
 def is_password_usable(encoded):
19 28
     return (encoded is not None and encoded != UNUSABLE_PASSWORD)
1  django/contrib/auth/tests/context_processors.py
@@ -13,6 +13,7 @@
13 13
             os.path.join(os.path.dirname(__file__), 'templates'),
14 14
         ),
15 15
     USE_TZ=False,                           # required for loading the fixture
  16
+    PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
16 17
 )
17 18
 class AuthContextProcessorTests(TestCase):
18 19
     """
12  django/contrib/auth/tests/forms.py
@@ -11,7 +11,7 @@
11 11
 from django.utils.translation import ugettext as _
12 12
 
13 13
 
14  
-@override_settings(USE_TZ=False)
  14
+@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
15 15
 class UserCreationFormTest(TestCase):
16 16
 
17 17
     fixtures = ['authtestdata.json']
@@ -77,7 +77,7 @@ def test_success(self):
77 77
         self.assertEqual(repr(u), '<User: jsmith@example.com>')
78 78
 
79 79
 
80  
-@override_settings(USE_TZ=False)
  80
+@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
81 81
 class AuthenticationFormTest(TestCase):
82 82
 
83 83
     fixtures = ['authtestdata.json']
@@ -129,7 +129,7 @@ def test_success(self):
129 129
         self.assertEqual(form.non_field_errors(), [])
130 130
 
131 131
 
132  
-@override_settings(USE_TZ=False)
  132
+@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
133 133
 class SetPasswordFormTest(TestCase):
134 134
 
135 135
     fixtures = ['authtestdata.json']
@@ -156,7 +156,7 @@ def test_success(self):
156 156
         self.assertTrue(form.is_valid())
157 157
 
158 158
 
159  
-@override_settings(USE_TZ=False)
  159
+@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
160 160
 class PasswordChangeFormTest(TestCase):
161 161
 
162 162
     fixtures = ['authtestdata.json']
@@ -204,7 +204,7 @@ def test_field_order(self):
204 204
                          ['old_password', 'new_password1', 'new_password2'])
205 205
 
206 206
 
207  
-@override_settings(USE_TZ=False)
  207
+@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
208 208
 class UserChangeFormTest(TestCase):
209 209
 
210 210
     fixtures = ['authtestdata.json']
@@ -251,7 +251,7 @@ def test_bug_17944_unknown_password_algorithm(self):
251 251
         form.as_table()
252 252
 
253 253
 
254  
-@override_settings(USE_TZ=False)
  254
+@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
255 255
 class PasswordResetFormTest(TestCase):
256 256
 
257 257
     fixtures = ['authtestdata.json']
2  django/contrib/auth/tests/signals.py
@@ -3,7 +3,7 @@
3 3
 from django.contrib.auth import signals
4 4
 
5 5
 
6  
-@override_settings(USE_TZ=False)
  6
+@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
7 7
 class SignalTestCase(TestCase):
8 8
     urls = 'django.contrib.auth.tests.urls'
9 9
     fixtures = ['authtestdata.json']
1  django/contrib/auth/tests/views.py
@@ -27,6 +27,7 @@
27 27
         os.path.join(os.path.dirname(__file__), 'templates'),
28 28
     ),
29 29
     USE_TZ=False,
  30
+    PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
30 31
 )
31 32
 class AuthViewsTestCase(TestCase):
32 33
     """
3  tests/modeltests/test_client/models.py
@@ -25,10 +25,11 @@
25 25
 from django.conf import settings
26 26
 from django.core import mail
27 27
 from django.test import Client, TestCase, RequestFactory
  28
+from django.test.utils import override_settings
28 29
 
29 30
 from .views import get_view
30 31
 
31  
-
  32
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
32 33
 class ClientTest(TestCase):
33 34
     fixtures = ['testdata.json']
34 35
 
3  tests/modeltests/timezones/tests.py
@@ -934,7 +934,8 @@ def test_model_form(self):
934 934
         self.assertEqual(e.dt, datetime.datetime(2011, 9, 1, 10, 20, 30, tzinfo=UTC))
935 935
 
936 936
 
937  
-@override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=True)
  937
+@override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=True,
  938
+                  PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
938 939
 class AdminTests(TestCase):
939 940
 
940 941
     urls = 'modeltests.timezones.urls'
2  tests/regressiontests/admin_custom_urls/tests.py
@@ -3,10 +3,12 @@
3 3
 from django.core.urlresolvers import reverse
4 4
 from django.template.response import TemplateResponse
5 5
 from django.test import TestCase
  6
+from django.test.utils import override_settings
6 7
 
7 8
 from .models import Action
8 9
 
9 10
 
  11
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
10 12
 class AdminCustomUrlsTest(TestCase):
11 13
     fixtures = ['users.json', 'actions.json']
12 14
 
6  tests/regressiontests/admin_inlines/tests.py
@@ -5,6 +5,7 @@
5 5
 from django.contrib.auth.models import User, Permission
6 6
 from django.contrib.contenttypes.models import ContentType
7 7
 from django.test import TestCase
  8
+from django.test.utils import override_settings
8 9
 
9 10
 # local test models
10 11
 from .admin import InnerInline
@@ -13,6 +14,7 @@
13 14
     ProfileCollection)
14 15
 
15 16
 
  17
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
16 18
 class TestInline(TestCase):
17 19
     urls = "regressiontests.admin_inlines.urls"
18 20
     fixtures = ['admin-views-users.xml']
@@ -145,6 +147,7 @@ def test_non_related_name_inline(self):
145 147
                 '<input id="id_-2-0-name" type="text" class="vTextField" '
146 148
                 'name="-2-0-name" maxlength="100" />', html=True)
147 149
 
  150
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
148 151
 class TestInlineMedia(TestCase):
149 152
     urls = "regressiontests.admin_inlines.urls"
150 153
     fixtures = ['admin-views-users.xml']
@@ -384,6 +387,7 @@ def test_inline_change_fk_all_perms(self):
384 387
         self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
385 388
 
386 389
 
  390
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
387 391
 class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
388 392
     webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
389 393
     fixtures = ['admin-views-users.xml']
@@ -502,4 +506,4 @@ class SeleniumChromeTests(SeleniumFirefoxTests):
502 506
     webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
503 507
 
504 508
 class SeleniumIETests(SeleniumFirefoxTests):
505  
-    webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
  509
+    webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
32  tests/regressiontests/admin_views/tests.py
@@ -47,6 +47,7 @@
47 47
 ERROR_MESSAGE = "Please enter the correct username and password \
48 48
 for a staff account. Note that both fields are case-sensitive."
49 49
 
  50
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
50 51
 class AdminViewBasicTest(TestCase):
51 52
     fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
52 53
                 'admin-views-fabrics.xml', 'admin-views-books.xml']
@@ -588,6 +589,7 @@ def test_hide_change_password(self):
588 589
             msg='The "change password" link should not be displayed if a user does not have a usable password.')
589 590
 
590 591
 
  592
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
591 593
 class AdminViewFormUrlTest(TestCase):
592 594
     urls = "regressiontests.admin_views.urls"
593 595
     fixtures = ["admin-views-users.xml"]
@@ -619,6 +621,7 @@ def test_filter_with_custom_template(self):
619 621
             self.assertTrue('custom_filter_template.html' in [t.name for t in response.templates])
620 622
 
621 623
 
  624
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
622 625
 class AdminJavaScriptTest(TestCase):
623 626
     fixtures = ['admin-views-users.xml']
624 627
 
@@ -686,6 +689,7 @@ def test_js_minified_only_if_debug_is_false(self):
686 689
             self.assertNotContains(response, 'inlines.min.js')
687 690
 
688 691
 
  692
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
689 693
 class SaveAsTests(TestCase):
690 694
     urls = "regressiontests.admin_views.urls"
691 695
     fixtures = ['admin-views-users.xml','admin-views-person.xml']
@@ -775,6 +779,7 @@ def get_perm(Model, perm):
775 779
     ct = ContentType.objects.get_for_model(Model)
776 780
     return Permission.objects.get(content_type=ct, codename=perm)
777 781
 
  782
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
778 783
 class AdminViewPermissionsTest(TestCase):
779 784
     """Tests for Admin Views Permissions."""
780 785
 
@@ -1179,6 +1184,7 @@ def testDisabledPermissionsWhenLoggedIn(self):
1179 1184
         self.assertContains(response, 'id="login-form"')
1180 1185
 
1181 1186
 
  1187
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
1182 1188
 class AdminViewsNoUrlTest(TestCase):
1183 1189
     """Regression test for #17333"""
1184 1190
 
@@ -1210,6 +1216,7 @@ def test_no_standard_modeladmin_urls(self):
1210 1216
         self.client.get('/test_admin/admin/logout/')
1211 1217
 
1212 1218
 
  1219
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
1213 1220
 class AdminViewDeletedObjectsTest(TestCase):
1214 1221
     urls = "regressiontests.admin_views.urls"
1215 1222
     fixtures = ['admin-views-users.xml', 'deleted-objects.xml']
@@ -1326,6 +1333,7 @@ def test_generic_relations(self):
1326 1333
         response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3))
1327 1334
         self.assertContains(response, should_contain)
1328 1335
 
  1336
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
1329 1337
 class AdminViewStringPrimaryKeyTest(TestCase):
1330 1338
     urls = "regressiontests.admin_views.urls"
1331 1339
     fixtures = ['admin-views-users.xml', 'string-primary-key.xml']
@@ -1418,6 +1426,7 @@ def test_url_conflicts_with_history(self):
1418 1426
         self.assertContains(response, should_contain)
1419 1427
 
1420 1428
 
  1429
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
1421 1430
 class SecureViewTests(TestCase):
1422 1431
     urls = "regressiontests.admin_views.urls"
1423 1432
     fixtures = ['admin-views-users.xml']
@@ -1576,6 +1585,7 @@ def test_shortcut_view_only_available_to_staff(self):
1576 1585
         self.assertEqual(response.status_code, 302)
1577 1586
         self.assertEqual(response['Location'], 'http://example.com/users/super/')
1578 1587
 
  1588
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
1579 1589
 class AdminViewUnicodeTest(TestCase):
1580 1590
     urls = "regressiontests.admin_views.urls"
1581 1591
     fixtures = ['admin-views-unicode.xml']
@@ -1630,6 +1640,7 @@ def testUnicodeDelete(self):
1630 1640
         self.assertRedirects(response, '/test_admin/admin/admin_views/book/')
1631 1641
 
1632 1642
 
  1643
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
1633 1644
 class AdminViewListEditable(TestCase):
1634 1645
     urls = "regressiontests.admin_views.urls"
1635 1646
     fixtures = ['admin-views-users.xml', 'admin-views-person.xml']
@@ -2004,6 +2015,7 @@ def test_pk_hidden_fields_with_list_display_links(self):
2004 2015
         self.assertContains(response, '<th><a href="%d/">%d</a></th>' % (story2.id, story2.id), 1)
2005 2016
 
2006 2017
 
  2018
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2007 2019
 class AdminSearchTest(TestCase):
2008 2020
     urls = "regressiontests.admin_views.urls"
2009 2021
     fixtures = ['admin-views-users', 'multiple-child-classes',
@@ -2051,6 +2063,7 @@ def test_beginning_matches(self):
2051 2063
         self.assertNotContains(response, "Guido")
2052 2064
 
2053 2065
 
  2066
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2054 2067
 class AdminInheritedInlinesTest(TestCase):
2055 2068
     urls = "regressiontests.admin_views.urls"
2056 2069
     fixtures = ['admin-views-users.xml',]
@@ -2137,6 +2150,7 @@ def testInline(self):
2137 2150
         self.assertEqual(BarAccount.objects.all()[0].username, "%s-1" % bar_user)
2138 2151
         self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
2139 2152
 
  2153
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2140 2154
 class AdminActionsTest(TestCase):
2141 2155
     urls = "regressiontests.admin_views.urls"
2142 2156
     fixtures = ['admin-views-users.xml', 'admin-views-actions.xml']
@@ -2355,6 +2369,7 @@ def test_popup_actions(self):
2355 2369
         self.assertEqual(response.context["action_form"], None)
2356 2370
 
2357 2371
 
  2372
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2358 2373
 class TestCustomChangeList(TestCase):
2359 2374
     urls = "regressiontests.admin_views.urls"
2360 2375
     fixtures = ['admin-views-users.xml']
@@ -2383,6 +2398,7 @@ def test_custom_changelist(self):
2383 2398
         self.assertNotContains(response, 'First Gadget')
2384 2399
 
2385 2400
 
  2401
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2386 2402
 class TestInlineNotEditable(TestCase):
2387 2403
     urls = "regressiontests.admin_views.urls"
2388 2404
     fixtures = ['admin-views-users.xml']
@@ -2401,6 +2417,7 @@ def test(self):
2401 2417
         response = self.client.get('/test_admin/admin/admin_views/parent/add/')
2402 2418
         self.assertEqual(response.status_code, 200)
2403 2419
 
  2420
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2404 2421
 class AdminCustomQuerysetTest(TestCase):
2405 2422
     urls = "regressiontests.admin_views.urls"
2406 2423
     fixtures = ['admin-views-users.xml']
@@ -2456,6 +2473,7 @@ def test_add_model_modeladmin_only_qs(self):
2456 2473
         # Message should contain non-ugly model name. Instance representation is set by model's __unicode__()
2457 2474
         self.assertContains(response, '<li class="info">The cover letter &quot;John Doe II&quot; was changed successfully.</li>', html=True)
2458 2475
 
  2476
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2459 2477
 class AdminInlineFileUploadTest(TestCase):
2460 2478
     urls = "regressiontests.admin_views.urls"
2461 2479
     fixtures = ['admin-views-users.xml', 'admin-views-actions.xml']
@@ -2502,6 +2520,7 @@ def test_inline_file_upload_edit_validation_error_post(self):
2502 2520
         self.assertTrue(response._container[0].find("Currently:") > -1)
2503 2521
 
2504 2522
 
  2523
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2505 2524
 class AdminInlineTests(TestCase):
2506 2525
     urls = "regressiontests.admin_views.urls"
2507 2526
     fixtures = ['admin-views-users.xml']
@@ -2820,6 +2839,7 @@ def test_ordered_inline(self):
2820 2839
         self.assertEqual(Category.objects.get(id=4).order, 0)
2821 2840
 
2822 2841
 
  2842
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2823 2843
 class NeverCacheTests(TestCase):
2824 2844
     urls = "regressiontests.admin_views.urls"
2825 2845
     fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml']
@@ -2893,6 +2913,7 @@ def testJsi18n(self):
2893 2913
         self.assertEqual(get_max_age(response), None)
2894 2914
 
2895 2915
 
  2916
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2896 2917
 class PrePopulatedTest(TestCase):
2897 2918
     urls = "regressiontests.admin_views.urls"
2898 2919
     fixtures = ['admin-views-users.xml']
@@ -2928,6 +2949,7 @@ def test_prepopulated_maxlength_localized(self):
2928 2949
         self.assertContains(response, "maxLength: 1000") # instead of 1,000
2929 2950
 
2930 2951
 
  2952
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
2931 2953
 class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
2932 2954
     webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
2933 2955
     urls = "regressiontests.admin_views.urls"
@@ -3051,6 +3073,7 @@ class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
3051 3073
     webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
3052 3074
 
3053 3075
 
  3076
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3054 3077
 class ReadonlyTest(TestCase):
3055 3078
     urls = "regressiontests.admin_views.urls"
3056 3079
     fixtures = ['admin-views-users.xml']
@@ -3124,6 +3147,7 @@ def test_user_password_change_limited_queryset(self):
3124 3147
         self.assertEquals(response.status_code, 404)
3125 3148
 
3126 3149
 
  3150
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3127 3151
 class RawIdFieldsTest(TestCase):
3128 3152
     urls = "regressiontests.admin_views.urls"
3129 3153
     fixtures = ['admin-views-users.xml']
@@ -3157,6 +3181,7 @@ def test_limit_choices_to(self):
3157 3181
         self.assertContains(response2, "Spain")
3158 3182
         self.assertNotContains(response2, "England")
3159 3183
 
  3184
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3160 3185
 class UserAdminTest(TestCase):
3161 3186
     """
3162 3187
     Tests user CRUD functionality.
@@ -3257,6 +3282,7 @@ def test_form_url_present_in_context(self):
3257 3282
         self.assertEqual(response.context['form_url'], 'pony')
3258 3283
 
3259 3284
 
  3285
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3260 3286
 class GroupAdminTest(TestCase):
3261 3287
     """
3262 3288
     Tests group CRUD functionality.
@@ -3288,6 +3314,7 @@ def test_group_permission_performance(self):
3288 3314
             self.assertEqual(response.status_code, 200)
3289 3315
 
3290 3316
 
  3317
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3291 3318
 class CSSTest(TestCase):
3292 3319
     urls = "regressiontests.admin_views.urls"
3293 3320
     fixtures = ['admin-views-users.xml']
@@ -3321,6 +3348,7 @@ def test_css_classes(self):
3321 3348
     docutils = None
3322 3349
 
3323 3350
 @unittest.skipUnless(docutils, "no docutils installed.")
  3351
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3324 3352
 class AdminDocsTest(TestCase):
3325 3353
     urls = "regressiontests.admin_views.urls"
3326 3354
     fixtures = ['admin-views-users.xml']
@@ -3363,6 +3391,7 @@ def test_filters(self):
3363 3391
         self.assertContains(response, '<li><a href="#built_in-add">add</a></li>', html=True)
3364 3392
 
3365 3393
 
  3394
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3366 3395
 class ValidXHTMLTests(TestCase):
3367 3396
     urls = "regressiontests.admin_views.urls"
3368 3397
     fixtures = ['admin-views-users.xml']
@@ -3386,6 +3415,7 @@ def testLangNamePresent(self):
3386 3415
         self.assertNotContains(response, ' xml:lang=""')
3387 3416
 
3388 3417
 
  3418
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3389 3419
 class DateHierarchyTests(TestCase):
3390 3420
     urls = "regressiontests.admin_views.urls"
3391 3421
     fixtures = ['admin-views-users.xml']
@@ -3512,6 +3542,7 @@ def test_multiple_years(self):
3512 3542
             self.assert_non_localized_year(response, 2003)
3513 3543
             self.assert_non_localized_year(response, 2005)
3514 3544
 
  3545
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3515 3546
 class AdminCustomSaveRelatedTests(TestCase):
3516 3547
     """
3517 3548
     Ensure that one can easily customize the way related objects are saved.
@@ -3580,6 +3611,7 @@ def test_should_be_able_to_edit_related_objects_on_changelist_view(self):
3580 3611
         self.assertEqual([u'Catherine Stone', u'Paul Stone'], children_names)
3581 3612
 
3582 3613
 
  3614
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
3583 3615
 class AdminViewLogoutTest(TestCase):
3584 3616
     urls = "regressiontests.admin_views.urls"
3585 3617
     fixtures = ['admin-views-users.xml']
6  tests/regressiontests/admin_widgets/tests.py
@@ -12,6 +12,7 @@
12 12
 from django.core.files.uploadedfile import SimpleUploadedFile
13 13
 from django.db.models import DateField
14 14
 from django.test import TestCase as DjangoTestCase
  15
+from django.test.utils import override_settings
15 16
 from django.utils import translation
16 17
 from django.utils.html import conditional_escape
17 18
 from django.utils.unittest import TestCase
@@ -122,6 +123,7 @@ def testInheritance(self):
122 123
         self.assertFormfield(models.Album, 'backside_art', widgets.AdminFileWidget)
123 124
 
124 125
 
  126
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
125 127
 class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
126 128
     fixtures = ["admin-widgets-users.xml"]
127 129
 
@@ -135,6 +137,7 @@ def testFilterChoicesByRequestUser(self):
135 137
         self.assertContains(response, "Volkswagon Passat")
136 138
 
137 139
 
  140
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
138 141
 class AdminForeignKeyWidgetChangeList(DjangoTestCase):
139 142
     fixtures = ["admin-widgets-users.xml"]
140 143
     admin_root = '/widget_admin'
@@ -150,6 +153,7 @@ def test_changelist_foreignkey(self):
150 153
         self.assertContains(response, '%s/auth/user/add/' % self.admin_root)
151 154
 
152 155
 
  156
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
153 157
 class AdminForeignKeyRawIdWidget(DjangoTestCase):
154 158
     fixtures = ["admin-widgets-users.xml"]
155 159
     admin_root = '/widget_admin'
@@ -411,6 +415,7 @@ def test_no_can_add_related(self):
411 415
 
412 416
 
413 417
 
  418
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
414 419
 class DateTimePickerSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
415 420
     webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
416 421
     fixtures = ['admin-widgets-users.xml']
@@ -466,6 +471,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
466 471
     webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
467 472
 
468 473
 
  474
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
469 475
 class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
470 476
     webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
471 477
     fixtures = ['admin-widgets-users.xml']
2  tests/regressiontests/comment_tests/tests/__init__.py
@@ -6,6 +6,7 @@
6 6
 from django.contrib.contenttypes.models import ContentType
7 7
 from django.contrib.sites.models import Site
8 8
 from django.test import TestCase
  9
+from django.test.utils import override_settings
9 10
 
10 11
 from ..models import Article, Author
11 12
 
@@ -13,6 +14,7 @@
13 14
 CT = ContentType.objects.get_for_model
14 15
 
15 16
 # Helper base class for comment tests that need data.
  17
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher',))
16 18
 class CommentTestCase(TestCase):
17 19
     fixtures = ["comment_tests"]
18 20
     urls = 'django.contrib.comments.urls'
1  tests/regressiontests/comment_tests/tests/moderation_view_tests.py
@@ -4,6 +4,7 @@
4 4
 from django.contrib.comments import signals
5 5
 from django.contrib.comments.models import Comment, CommentFlag
6 6
 from django.contrib.contenttypes.models import ContentType
  7
+from django.conf import settings
7 8
 
8 9
 from . import CommentTestCase
9 10
 
4  tests/regressiontests/generic_inline_admin/tests.py
@@ -9,6 +9,7 @@
9 9
     generic_inlineformset_factory, GenericTabularInline)
10 10
 from django.forms.models import ModelForm
11 11
 from django.test import TestCase
  12
+from django.test.utils import override_settings
12 13
 
13 14
 # local test models
14 15
 from .admin import MediaInline, MediaPermanentInline
@@ -16,6 +17,7 @@
16 17
     EpisodePermanent, Category)
17 18
 
18 19
 
  20
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
19 21
 class GenericAdminViewTest(TestCase):
20 22
     urls = "regressiontests.generic_inline_admin.urls"
21 23
     fixtures = ['users.xml']
@@ -128,6 +130,7 @@ def testGenericInlineFormsetFactory(self):
128 130
         formset = inline_formset(instance=e)
129 131
         self.assertTrue(formset.get_queryset().ordered)
130 132
 
  133
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
131 134
 class GenericInlineAdminParametersTest(TestCase):
132 135
     urls = "regressiontests.generic_inline_admin.urls"
133 136
     fixtures = ['users.xml']
@@ -181,6 +184,7 @@ def testMaxNumParam(self):
181 184
         self.assertEqual(formset.initial_form_count(), 1)
182 185
 
183 186
 
  187
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
184 188
 class GenericInlineAdminWithUniqueTogetherTest(TestCase):
185 189
     urls = "regressiontests.generic_inline_admin.urls"
186 190
     fixtures = ['users.xml']
2  tests/regressiontests/special_headers/tests.py
... ...
@@ -1,7 +1,9 @@
1 1
 from django.contrib.auth.models import User
2 2
 from django.test import TestCase
  3
+from django.test.utils import override_settings
3 4
 
4 5
 
  6
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
5 7
 class SpecialHeadersTest(TestCase):
6 8
     fixtures = ['data.xml']
7 9
     urls = 'regressiontests.special_headers.urls'
8  tests/regressiontests/test_client_regress/models.py
@@ -12,7 +12,7 @@
12 12
 import django.template.context
13 13
 from django.test import Client, TestCase
14 14
 from django.test.client import encode_file, RequestFactory
15  
-from django.test.utils import ContextList
  15
+from django.test.utils import ContextList, override_settings
16 16
 from django.template.response import SimpleTemplateResponse
17 17
 from django.http import HttpResponse
18 18
 
@@ -163,6 +163,7 @@ def test_assert_not_contains_using_non_template_response(self):
163 163
         response = HttpResponse('Hello')
164 164
         self.assertNotContains(response, 'Bye')
165 165
 
  166
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
166 167
 class AssertTemplateUsedTests(TestCase):
167 168
     fixtures = ['testdata.json']
168 169
 
@@ -522,6 +523,7 @@ def test_unknown_nonfield_error(self):
522 523
         except AssertionError as e:
523 524
             self.assertIn("abc: The form 'form' in context 0 does not contain the non-field error 'Some error.' (actual errors: )", str(e))
524 525
 
  526
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
525 527
 class LoginTests(TestCase):
526 528
     fixtures = ['testdata']
527 529
 
@@ -542,6 +544,7 @@ def test_login_different_client(self):
542 544
         self.assertRedirects(response, "http://testserver/test_client_regress/get_view/")
543 545
 
544 546
 
  547
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
545 548
 class SessionEngineTests(TestCase):
546 549
     fixtures = ['testdata']
547 550
 
@@ -588,6 +591,7 @@ def test_argument_with_space_post(self):
588 591
         self.assertEqual(response.status_code, 200)
589 592
         self.assertEqual(response.content, 'Hi, Arthur')
590 593
 
  594
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
591 595
 class ExceptionTests(TestCase):
592 596
     fixtures = ['testdata.json']
593 597
 
@@ -661,6 +665,7 @@ def test_urlconf_was_reverted(self):
661 665
         url = reverse('arg_view', args=['somename'])
662 666
         self.assertEqual(url, '/test_client_regress/arg_view/somename/')
663 667
 
  668
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
664 669
 class ContextTests(TestCase):
665 670
     fixtures = ['testdata']
666 671
 
@@ -707,6 +712,7 @@ def test_15368(self):
707 712
             django.template.context._standard_context_processors = None
708 713
 
709 714
 
  715
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
710 716
 class SessionTests(TestCase):
711 717
     fixtures = ['testdata.json']
712 718
 
6  tests/test_sqlite.py
@@ -22,3 +22,9 @@
22 22
 }
23 23
 
24 24
 SECRET_KEY = "django_tests_secret_key"
  25
+# To speed up tests under SQLite we use the MD5 hasher as the default one. 
  26
+# This should not be needed under other databases, as the relative speedup
  27
+# is only marginal there.
  28
+PASSWORD_HASHERS = (
  29
+    'django.contrib.auth.hashers.MD5PasswordHasher',
  30
+)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.