| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2020 William Brown <[email protected]> |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# License: GPL (version 3 or any later version). |
| 6 |
# See LICENSE for details. |
| 7 |
# --- END COPYRIGHT BLOCK --- |
| 8 |
# |
| 9 |
import pytest |
| 10 |
import os |
| 11 |
from test389.topologies import topology_st |
| 12 |
from lib389.utils import ds_is_older |
| 13 |
from lib389.idm.user import nsUserAccounts |
| 14 |
from lib389._constants import DEFAULT_SUFFIX |
| 15 |
|
| 16 |
pytestmark = pytest.mark.tier1 |
| 17 |
|
| 18 |
@pytest.mark.skipif(ds_is_older('1.4.3'), reason="Not implemented") |
| 19 |
def test_migrate_openldap_password_hash(topology_st): |
| 20 |
"""Test import of an openldap password value into the directory and assert |
| 21 |
it can bind. |
| 22 |
|
| 23 |
:id: e4898e0d-5d18-4765-9249-84bcbf862fde |
| 24 |
:setup: Standalone Instance |
| 25 |
:steps: |
| 26 |
1. Import a hash |
| 27 |
2. Attempt a bind |
| 28 |
3. Goto 1 |
| 29 |
|
| 30 |
:expectedresults: |
| 31 |
1. Success |
| 32 |
2. Success |
| 33 |
3. Success |
| 34 |
""" |
| 35 |
inst = topology_st.standalone |
| 36 |
inst.config.set('nsslapd-allow-hashed-passwords', 'on') |
| 37 |
|
| 38 |
# You generate these with: |
| 39 |
# slappasswd -s password -o module-load=/usr/lib64/openldap/pw-argon2.so -h {ARGON2} |
| 40 |
pwds = [ |
| 41 |
'{CRYPT}ZZKRwXSu3tt8s', |
| 42 |
'{SSHA}jdALDtX0+MVMkRsX0ilHz0O6Uos95D4s', |
| 43 |
'{MD5}X03MO1qnZdYdgyfeuILPmQ==', |
| 44 |
'{SMD5}RnexgcsjdBHMQ1yhB7+sD+a+qDI=', |
| 45 |
'{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=', |
| 46 |
'{SHA256}XohImNooBHFR0OVvjcYpJ3NgPQ1qq73WKhHvch0VQtg=', |
| 47 |
'{SSHA256}covFryM35UrKB3gMYxtYpQYTHbTn5kFphjcNHewfj581SLJwjA9jew==', |
| 48 |
'{SHA384}qLZLq9CsqRpZvbt3YbQh1PK7OCgNOnW6DyHyvrxFWD1EbFmGYMlM5oDEfRnDB4On', |
| 49 |
'{SSHA384}kNjTWdmyy2G1IgJF8WrOpq0N//Yc2Ec5TIQYceuiuHQXRXpC1bfnMqyOx0NxrSREjBWDwUpqXjo=', |
| 50 |
'{SHA512}sQnzu7wkTrgkQZF+0G1hi5AI3Qmzvv0bXgc5THBqi7mAsdd4Xll27ASbRt9fEyavWi6m0QP9B8lThf+rDKy8hg==', |
| 51 |
'{SSHA512}+7A8kA32q4mCBao4Cbatdyzl5imVwJ62ZAE7UOTP4pfrF90E9R2LabOfJFzx6guaYhTmUEVK2wRKC8bToqspdeTluX2d1BX2', |
| 52 |
# Need to check -- |
| 53 |
'{PBKDF2}10000$IlfapjA351LuDSwYC0IQ8Q$saHqQTuYnjJN/tmAndT.8mJt.6w', |
| 54 |
'{PBKDF2-SHA1}10000$ZBEH6B07rgQpJSikyvMU2w$TAA03a5IYkz1QlPsbJKvUsTqNV', |
| 55 |
'{PBKDF2-SHA256}10000$henZGfPWw79Cs8ORDeVNrQ$1dTJy73v6n3bnTmTZFghxHXHLsAzKaAy8SksDfZBPIw', |
| 56 |
'{PBKDF2-SHA512}10000$Je1Uw19Bfv5lArzZ6V3EPw$g4T/1sqBUYWl9o93MVnyQ/8zKGSkPbKaXXsT8WmysXQJhWy8MRP2JFudSL.N9RklQYgDPxPjnfum/F2f/TrppA', |
| 57 |
# '{ARGON2}$argon2id$v=19$m=65536,t=2,p=1$IyTQMsvzB2JHDiWx8fq7Ew$VhYOA7AL0kbRXI5g2kOyyp8St1epkNj7WZyUY4pAIQQ', |
| 58 |
] |
| 59 |
|
| 60 |
accounts = nsUserAccounts(inst, basedn=DEFAULT_SUFFIX) |
| 61 |
account = accounts.create(properties={ |
| 62 |
'uid': 'pw_migrate_test_user', |
| 63 |
'cn': 'pw_migrate_test_user', |
| 64 |
'displayName': 'pw_migrate_test_user', |
| 65 |
'uidNumber': '12345', |
| 66 |
'gidNumber': '12345', |
| 67 |
'homeDirectory': '/var/empty', |
| 68 |
}) |
| 69 |
|
| 70 |
for pwhash in pwds: |
| 71 |
inst.log.debug(f"Attempting -> {pwhash}") |
| 72 |
account.set('userPassword', pwhash) |
| 73 |
nconn = account.bind('password') |