Show More
@@ -1,21 +1,26 b'' | |||||
|
1 | # coding: utf-8 | |||
1 | from IPython.lib import passwd |
|
2 | from IPython.lib import passwd | |
2 | from IPython.lib.security import passwd_check, salt_len |
|
3 | from IPython.lib.security import passwd_check, salt_len | |
3 | import nose.tools as nt |
|
4 | import nose.tools as nt | |
4 |
|
5 | |||
5 | def test_passwd_structure(): |
|
6 | def test_passwd_structure(): | |
6 | p = passwd('passphrase') |
|
7 | p = passwd('passphrase') | |
7 | algorithm, salt, hashed = p.split(':') |
|
8 | algorithm, salt, hashed = p.split(':') | |
8 | nt.assert_equal(algorithm, 'sha1') |
|
9 | nt.assert_equal(algorithm, 'sha1') | |
9 | nt.assert_equal(len(salt), salt_len) |
|
10 | nt.assert_equal(len(salt), salt_len) | |
10 | nt.assert_equal(len(hashed), 40) |
|
11 | nt.assert_equal(len(hashed), 40) | |
11 |
|
12 | |||
12 | def test_roundtrip(): |
|
13 | def test_roundtrip(): | |
13 | p = passwd('passphrase') |
|
14 | p = passwd('passphrase') | |
14 | nt.assert_equal(passwd_check(p, 'passphrase'), True) |
|
15 | nt.assert_equal(passwd_check(p, 'passphrase'), True) | |
15 |
|
16 | |||
16 | def test_bad(): |
|
17 | def test_bad(): | |
17 | p = passwd('passphrase') |
|
18 | p = passwd('passphrase') | |
18 | nt.assert_equal(passwd_check(p, p), False) |
|
19 | nt.assert_equal(passwd_check(p, p), False) | |
19 | nt.assert_equal(passwd_check(p, 'a:b:c:d'), False) |
|
20 | nt.assert_equal(passwd_check(p, 'a:b:c:d'), False) | |
20 | nt.assert_equal(passwd_check(p, 'a:b'), False) |
|
21 | nt.assert_equal(passwd_check(p, 'a:b'), False) | |
21 |
|
22 | |||
|
23 | def test_passwd_check_unicode(): | |||
|
24 | # GH issue #4524 | |||
|
25 | phash = u'sha1:9dc18846ca26:6bb62badc41fde529c258a8a7fbe259a91313df8' | |||
|
26 | assert passwd_check(phash, u'mypassword³') No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now