2015-12-10 15:21:06 +00:00
|
|
|
from app.main.encryption import hashpw, check_hash
|
2015-11-27 09:47:29 +00:00
|
|
|
|
|
|
|
|
|
2015-11-30 15:33:40 +00:00
|
|
|
def test_should_hash_password():
|
|
|
|
|
password = 'passwordToHash'
|
|
|
|
|
assert password != hashpw(password)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_should_check_password():
|
2015-11-27 09:47:29 +00:00
|
|
|
value = 's3curePassword!'
|
2015-11-30 15:33:40 +00:00
|
|
|
encrypted = hashpw(value)
|
2015-12-10 15:21:06 +00:00
|
|
|
assert check_hash(value, encrypted) is True
|
2015-11-27 09:47:29 +00:00
|
|
|
|
|
|
|
|
|
2015-11-30 15:33:40 +00:00
|
|
|
def test_checkpw_should_fail_when_pw_does_not_match():
|
|
|
|
|
value = hashpw('somePassword')
|
2015-12-10 15:21:06 +00:00
|
|
|
assert check_hash('somethingDifferent', value) is False
|