32
32
import shutil
33
33
import sys
34
34
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
36
36
from tests .support .picklesupp import PickleAssertMixin
37
37
38
38
from mig .server .createuser import _main as createuser
@@ -82,7 +82,15 @@ def test_user_db_is_created_when_absent(self):
82
82
83
83
84
84
def test_user_entry_is_recorded (self ):
85
+ def _generate_salt ():
86
+ return b'CCCC12344321CCCC'
87
+
85
88
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
+
86
94
args = [
87
95
"Test User" ,
88
96
"Test Org" ,
@@ -94,16 +102,12 @@ def test_user_entry_is_recorded(self):
94
102
]
95
103
print ("" ) # acount for output generated by the logic
96
104
97
- def _generate_salt ():
98
- return b'CCCC12344321CCCC'
99
105
createuser (self .configuration , args , default_renew = True ,
100
106
_generate_salt = _generate_salt )
101
107
102
108
pickled = self .assertPickledFile (self .expected_user_db_file )
103
-
104
109
self .assertIn (expected_user_id , pickled )
105
110
actual_user_object = dict (pickled [expected_user_id ])
106
-
107
111
# TODO: remove resetting the handful of keys here done because changes
108
112
# to make them assertion frienfly values will increase the size
109
113
# of the diff which, at time of commit, are best minimised.
@@ -124,9 +128,9 @@ def _generate_salt():
124
128
'organization' : 'Test Org' ,
125
129
'organizational_unit' : '' ,
126
130
"password" : "" ,
127
- "password_hash" : "PBKDF2$sha256$10000$b'CCCC12344321CCCC'$b'bph8p/avUq42IYeOdJoJuUqrJ7Q32eaT'" ,
131
+ "password_hash" : expected_user_password_hash ,
128
132
'state' : 'NA' ,
129
- 'unique_id' : '__UNIQUE_ID__'
133
+ 'unique_id' : '__UNIQUE_ID__' ,
130
134
})
131
135
132
136
0 commit comments