summaryrefslogtreecommitdiff
path: root/passlib/tests
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-04-17 15:34:14 -0400
committerEli Collins <elic@assurancetechnologies.com>2012-04-17 15:34:14 -0400
commite56e08c56ea0a4a8ac45aff7bfcd39d351e04e53 (patch)
tree00b170736effd3ec37cfd96ab21a0af8e1707913 /passlib/tests
parentd1932877f847c74d20c7e5311a4dd91c2b6d03f0 (diff)
downloadpasslib-e56e08c56ea0a4a8ac45aff7bfcd39d351e04e53.tar.gz
CryptPolicy deprecated, part2 - updated rest of library to use CryptContext directly
Diffstat (limited to 'passlib/tests')
-rw-r--r--passlib/tests/test_apps.py8
-rw-r--r--passlib/tests/test_ext_django.py15
-rw-r--r--passlib/tests/test_handlers.py4
-rw-r--r--passlib/tests/test_hosts.py2
4 files changed, 15 insertions, 14 deletions
diff --git a/passlib/tests/test_apps.py b/passlib/tests/test_apps.py
index d48654d..1758c38 100644
--- a/passlib/tests/test_apps.py
+++ b/passlib/tests/test_apps.py
@@ -25,7 +25,7 @@ class AppsTest(TestCase):
def test_custom_app_context(self):
ctx = apps.custom_app_context
- self.assertEqual(ctx.policy.schemes(), ["sha512_crypt", "sha256_crypt"])
+ self.assertEqual(ctx.schemes(), ("sha512_crypt", "sha256_crypt"))
for hash in [
('$6$rounds=41128$VoQLvDjkaZ6L6BIE$4pt.1Ll1XdDYduEwEYPCMOBiR6W6'
'znsyUEoNlcVXpv2gKKIbQolgmTGe6uEEVJ7azUxuc8Tf7zV9SD2z7Ij751'),
@@ -93,10 +93,12 @@ class AppsTest(TestCase):
h1 = '$2a$10$Ljj0Kgu7Ddob9xWoqzn0ae.uNfxPRofowWdksk.6jCUHKTGYLD.QG'
if hashmod.bcrypt.has_backend():
self.assertTrue(ctx.verify("test", h1))
- self.assertEqual(ctx.policy.get_handler().name, "bcrypt")
+ self.assertEqual(ctx.default_scheme(), "bcrypt")
+ self.assertEqual(ctx.handler().name, "bcrypt")
else:
self.assertEqual(ctx.identify(h1), "bcrypt")
- self.assertEqual(ctx.policy.get_handler().name, "phpass")
+ self.assertEqual(ctx.default_scheme(), "phpass")
+ self.assertEqual(ctx.handler().name, "phpass")
def test_phpbb3_context(self):
ctx = apps.phpbb3_context
diff --git a/passlib/tests/test_ext_django.py b/passlib/tests/test_ext_django.py
index f4ea932..0a8764f 100644
--- a/passlib/tests/test_ext_django.py
+++ b/passlib/tests/test_ext_django.py
@@ -9,7 +9,7 @@ import sys
import warnings
#site
#pkg
-from passlib.context import CryptContext, CryptPolicy
+from passlib.context import CryptContext
from passlib.apps import django_context
from passlib.ext.django import utils
from passlib.hash import sha256_crypt
@@ -118,9 +118,9 @@ sample1_sha1 = 'sha1$b215d$9ee0a66f84ef1ad99096355e788135f7e949bd41'
# context for testing category funcs
category_context = CryptContext(
schemes = [ "sha256_crypt" ],
- sha256_crypt__rounds = 1000,
- staff__sha256_crypt__rounds = 2000,
- superuser__sha256_crypt__rounds = 3000,
+ sha256_crypt__default_rounds = 1000,
+ staff__sha256_crypt__default_rounds = 2000,
+ superuser__sha256_crypt__default_rounds = 3000,
)
def get_cc_rounds(**kwds):
@@ -258,7 +258,6 @@ class PatchTest(TestCase):
def test_01_patch_bad_types(self):
"test set_django_password_context bad inputs"
set = utils.set_django_password_context
- self.assertRaises(TypeError, set, CryptPolicy())
self.assertRaises(TypeError, set, "")
def test_02_models_check_password(self):
@@ -540,7 +539,7 @@ class PluginTest(TestCase):
def test_20_categories(self):
"test PASSLIB_GET_CATEGORY unset"
update_settings(
- PASSLIB_CONTEXT=category_context.policy.to_string(),
+ PASSLIB_CONTEXT=category_context.to_string(),
)
import passlib.ext.django.models
@@ -553,7 +552,7 @@ class PluginTest(TestCase):
def get_category(user):
return user.first_name or None
update_settings(
- PASSLIB_CONTEXT = category_context.policy.to_string(),
+ PASSLIB_CONTEXT = category_context.to_string(),
PASSLIB_GET_CATEGORY = get_category,
)
import passlib.ext.django.models
@@ -566,7 +565,7 @@ class PluginTest(TestCase):
def test_22_categories_disabled(self):
"test PASSLIB_GET_CATEGORY = None"
update_settings(
- PASSLIB_CONTEXT = category_context.policy.to_string(),
+ PASSLIB_CONTEXT = category_context.to_string(),
PASSLIB_GET_CATEGORY = None,
)
import passlib.ext.django.models
diff --git a/passlib/tests/test_handlers.py b/passlib/tests/test_handlers.py
index 259a58f..a5dd3ae 100644
--- a/passlib/tests/test_handlers.py
+++ b/passlib/tests/test_handlers.py
@@ -2040,10 +2040,10 @@ class scram_test(HandlerCase):
self.assertEqual(handler.extract_digest_algs(h), ["md5", "sha-1"])
self.assertFalse(c1.hash_needs_update(h))
- c2 = c1.replace(scram__algs="sha1")
+ c2 = c1.copy(scram__algs="sha1")
self.assertFalse(c2.hash_needs_update(h))
- c2 = c1.replace(scram__algs="sha1,sha256")
+ c2 = c1.copy(scram__algs="sha1,sha256")
self.assertTrue(c2.hash_needs_update(h))
def test_96_full_verify(self):
diff --git a/passlib/tests/test_hosts.py b/passlib/tests/test_hosts.py
index de744a8..a64fb30 100644
--- a/passlib/tests/test_hosts.py
+++ b/passlib/tests/test_hosts.py
@@ -72,7 +72,7 @@ class HostsTest(TestCase):
# validate schemes is non-empty,
# and contains unix_disabled + at least one real scheme
- schemes = ctx.policy.schemes()
+ schemes = list(ctx.schemes())
self.assertTrue(schemes, "appears to be unix system, but no known schemes supported by crypt")
self.assertTrue('unix_disabled' in schemes)
schemes.remove("unix_disabled")