Skip to content

Commit c7b7e3f

Browse files
committed
repair expected pw hash
1 parent ac0836e commit c7b7e3f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/test_mig_server_createuser.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import shutil
3333
import sys
3434

35-
from tests.support import MIG_BASE, TEST_OUTPUT_DIR, MigTestCase, testmain
35+
from tests.support import PY2, MIG_BASE, TEST_OUTPUT_DIR, MigTestCase, testmain
3636
from tests.support.picklesupp import PickleAssertMixin
3737

3838
from mig.server.createuser import _main as createuser
@@ -82,7 +82,15 @@ def test_user_db_is_created_when_absent(self):
8282

8383

8484
def test_user_entry_is_recorded(self):
85+
def _generate_salt():
86+
return b'CCCC12344321CCCC'
87+
8588
expected_user_id = '/C=DK/ST=NA/L=NA/O=Test Org/OU=NA/CN=Test User/emailAddress=user@example.com'
89+
if PY2:
90+
expected_user_password_hash = 'PBKDF2$sha256$10000$CCCC12344321CCCC$bph8p/avUq42IYeOdJoJuUqrJ7Q32eaT'
91+
else:
92+
expected_user_password_hash = "PBKDF2$sha256$10000$b'CCCC12344321CCCC'$b'bph8p/avUq42IYeOdJoJuUqrJ7Q32eaT'"
93+
8694
args = [
8795
"Test User",
8896
"Test Org",
@@ -94,16 +102,12 @@ def test_user_entry_is_recorded(self):
94102
]
95103
print("") # acount for output generated by the logic
96104

97-
def _generate_salt():
98-
return b'CCCC12344321CCCC'
99105
createuser(self.configuration, args, default_renew=True,
100106
_generate_salt=_generate_salt)
101107

102108
pickled = self.assertPickledFile(self.expected_user_db_file)
103-
104109
self.assertIn(expected_user_id, pickled)
105110
actual_user_object = dict(pickled[expected_user_id])
106-
107111
# TODO: remove resetting the handful of keys here done because changes
108112
# to make them assertion frienfly values will increase the size
109113
# of the diff which, at time of commit, are best minimised.
@@ -124,9 +128,9 @@ def _generate_salt():
124128
'organization': 'Test Org',
125129
'organizational_unit': '',
126130
"password": "",
127-
"password_hash": "PBKDF2$sha256$10000$b'CCCC12344321CCCC'$b'bph8p/avUq42IYeOdJoJuUqrJ7Q32eaT'",
131+
"password_hash": expected_user_password_hash,
128132
'state': 'NA',
129-
'unique_id': '__UNIQUE_ID__'
133+
'unique_id': '__UNIQUE_ID__',
130134
})
131135

132136

0 commit comments

Comments
 (0)