def test_upgrade_from_sha_with_unicode_password(self):
user = factories.User()
password = u'testpassword\xc2\xa0'
user_obj = model.User.by_name(user['name'])
# setup our user with an old password hash
old_hash = self._set_password(password)
user_obj._password = old_hash
user_obj.save()
nt.assert_true(user_obj.validate_password(password))
nt.assert_not_equals(old_hash, user_obj.password)
nt.assert_true(pbkdf2_sha512.identify(user_obj.password))
nt.assert_true(pbkdf2_sha512.verify(password, user_obj.password))
# check that we now allow unicode characters
nt.assert_false(pbkdf2_sha512.verify('testpassword',
user_obj.password))
python类assert_not_equals()的实例源码
def test_open_dois(self, test_data):
(doi, fulltext_url, license) = test_data
my_pub = pub.lookup_product_by_doi(doi)
my_pub.recalculate()
logger.info(u"was looking for {}, got {}\n\n".format(fulltext_url, my_pub.fulltext_url))
logger.info(u"doi: http://doi.org/{}".format(doi))
logger.info(u"title: {}".format(my_pub.best_title))
logger.info(u"evidence: {}\n\n".format(my_pub.evidence))
if my_pub.error:
logger.info(my_pub.error)
assert_not_equals(my_pub.fulltext_url, None)
# @data(*closed_dois)
# def test_closed_dois(self, test_data):
# (doi, fulltext_url, license) = test_data
# my_pub = pub.lookup_product_by_doi(doi)
# my_pub.recalculate()
#
# logger.info(u"was looking for {}, got {}\n\n".format(fulltext_url, my_pub.fulltext_url))
# logger.info(u"doi: http://doi.org/{}".format(doi))
# logger.info(u"title: {}".format(my_pub.best_title))
# logger.info(u"evidence: {}\n\n".format(my_pub.evidence))
# if my_pub.error:
# logger.info(my_pub.error)
#
# assert_equals(my_pub.fulltext_url, None)
#
# have to scrape the publisher pages to find these
def test_upgrade_from_sha(self):
user = factories.User()
user_obj = model.User.by_name(user['name'])
# setup our user with an old password hash
old_hash = self._set_password('testpass')
user_obj._password = old_hash
user_obj.save()
user_obj.validate_password('testpass')
nt.assert_not_equals(old_hash, user_obj.password)
nt.assert_true(pbkdf2_sha512.identify(user_obj.password))
nt.assert_true(pbkdf2_sha512.verify('testpass', user_obj.password))
def test_upgrade_from_pbkdf2_with_less_rounds(self):
'''set up a pbkdf key with less than the default rounds
If the number of default_rounds is increased in a later version of
passlib, ckan should upgrade the password hashes for people without
involvement from users'''
user = factories.User()
password = u'testpassword'
user_obj = model.User.by_name(user['name'])
# setup hash with salt/rounds less than the default
old_hash = pbkdf2_sha512.encrypt(password, salt_size=2, rounds=10)
user_obj._password = old_hash
user_obj.save()
nt.assert_true(user_obj.validate_password(password.encode('utf-8')))
# check that the hash has been updated
nt.assert_not_equals(old_hash, user_obj.password)
new_hash = pbkdf2_sha512.from_string(user_obj.password)
nt.assert_true(pbkdf2_sha512.default_rounds > 10)
nt.assert_equals(pbkdf2_sha512.default_rounds, new_hash.rounds)
nt.assert_true(pbkdf2_sha512.default_salt_size, 2)
nt.assert_equals(pbkdf2_sha512.default_salt_size,
len(new_hash.salt))
nt.assert_true(pbkdf2_sha512.verify(password, user_obj.password))
def assert_inode_not_equal(self, a, b):
nt.assert_not_equals(os.stat(a).st_ino, os.stat(b).st_ino,
"%r and %r do reference the same indoes" %(a, b))
def tests_init_is_successful(self):
''' Tests that the engine is successfully initialized i.e.
awslambda, awskinesis and awscwlogs are setup and initialized '''
config_path = config_dir + "/valid.yaml"
core.IAM = core.Lambda = core.Kinesis = core.CloudWatchLogs = Mock()
engine = core.Engine(config_path)
nt.assert_not_equals(engine.awslambda, None)
nt.assert_not_equals(engine.kinesis, None)
nt.assert_not_equals(engine.cwlogs, None)
def assert_inode_not_equal(self, a, b):
nt.assert_not_equals(os.stat(a).st_ino, os.stat(b).st_ino,
"%r and %r do reference the same indoes" %(a, b))
def assert_inode_not_equal(self, a, b):
nt.assert_not_equals(os.stat(a).st_ino, os.stat(b).st_ino,
"%r and %r do reference the same indoes" %(a, b))
def assert_inode_not_equal(self, a, b):
nt.assert_not_equals(os.stat(a).st_ino, os.stat(b).st_ino,
"%r and %r do reference the same indoes" %(a, b))
def assert_inode_not_equal(self, a, b):
nt.assert_not_equals(os.stat(a).st_ino, os.stat(b).st_ino,
"%r and %r do reference the same indoes" %(a, b))
def assert_inode_not_equal(self, a, b):
nt.assert_not_equals(os.stat(a).st_ino, os.stat(b).st_ino,
"%r and %r do reference the same indoes" %(a, b))