/
test_crypto.py
37 lines (30 loc) · 1.43 KB
/
test_crypto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (C) 2009 by Kai Blin
#
# WOMBAT is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
from wombat.lib.auth import crypt_password, parse_pass, check_password
def test_parse_pass():
password = u"{method}$SALTSALT$PASSWORDPASSWORD"
method, salt, crypt = parse_pass(password)
assert method == "{method}", "failed to parse method"
assert salt == "SALTSALT", "failed to parse salt"
assert crypt == "PASSWORDPASSWORD"
def test_password_MD5():
pass_string = crypt_password("secret")
method, salt, crypt = parse_pass(pass_string)
assert method == "{MD5}", "method is %s, not {MD5}" % method
assert salt is not None, "salt is None"
assert crypt is not None, "crypt is None"
def test_check_password_MD5():
pass_string = crypt_password("secret")
assert check_password(pass_string, "secret"), "Password verification failed"