Debian Codegraph @

dirsrvtests/tests/suites/password/pwp_test.py

raw
1 """
2 # --- BEGIN COPYRIGHT BLOCK ---
3 # Copyright (C) 2020 Red Hat, Inc.
4 # All rights reserved.
5 #
6 # License: GPL (version 3 or any later version).
7 # See LICENSE for details.
8 # --- END COPYRIGHT BLOCK ---
9 """
10
11 import os
12 import subprocess
13 import pytest
14 from test389.topologies import topology_st as topo
15 from lib389.idm.user import UserAccounts, UserAccount
16 from lib389.idm.directorymanager import DirectoryManager
17 from lib389._constants import DEFAULT_SUFFIX, PASSWORD
18 from lib389.config import Config
19 from lib389.pwpolicy import PwPolicyManager
20 from lib389.idm.group import Group
21 from lib389.utils import ds_is_older
22 import ldap
23 import time
24
25 pytestmark = pytest.mark.tier1
26
27 if ds_is_older('1.4'):
28 DEFAULT_PASSWORD_STORAGE_SCHEME = 'SSHA512'
29 else:
30 DEFAULT_PASSWORD_STORAGE_SCHEME = 'PBKDF2-SHA512'
31
32
33 def _create_user(topo, uid, cn, uidNumber, userpassword):
34 """
35 Will Create user
36 """
37 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create(properties={
38 'uid': uid,
39 'sn': cn.split(' ')[-1],
40 'cn': cn,
41 'givenname': cn.split(' ')[0],
42 'uidNumber': uidNumber,
43 'gidNumber': uidNumber,
44 'mail': f'{uid}@example.com',
45 'userpassword': userpassword,
46 'homeDirectory': f'/home/{uid}'
47 })
48 return user
49
50
51 def _change_password_with_own(topo, user_dn, password, new_password):
52 """
53 Change user password with user self
54 """
55 conn = UserAccount(topo.standalone, user_dn).bind(password)
56 real_user = UserAccount(conn, user_dn)
57 real_user.replace('userpassword', new_password)
58
59
60 def _change_password_with_root(topo, user_dn, new_password):
61 """
62 Root will change user password
63 """
64 UserAccount(topo.standalone, user_dn).replace('userpassword', new_password)
65
66
67 @pytest.fixture(scope="function")
68 def _fix_password(topo, request):
69 user = _create_user(topo, 'dbyers', 'Danny Byers', '1001', 'dbyers1')
70 user.replace('userpassword', 'dbyers1')
71
72 def fin():
73 user.delete()
74 request.addfinalizer(fin)
75
76
77 def test_passwordchange_to_no(topo, _fix_password):
78 """Change password fo a user even password even though pw policy is set to no
79
80 :id: 16c64ef0-5a20-11ea-a902-8c16451d917b
81 :setup: Standalone
82 :steps:
83 1. Adding an user with uid=dbyers
84 2. Set Password change to Must Not Change After Reset
85 3. Setting Password policy to May Not Change Password
86 4. Try to change password fo a user even password even though pw policy is set to no
87 5. Set Password change to May Change Password
88 6. Try to change password fo a user even password
89 7. Try to change password with invalid credentials. Should see error message.
90 :expectedresults:
91 1. Success
92 2. Success
93 3. Success
94 4. Success
95 5. Success
96 6. Success
97 7. Success
98 """
99 # Adding an user with uid=dbyers
100 user = f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}'
101 config = Config(topo.standalone)
102 # Set Password change to Must Not Change After Reset
103 config.replace_many(
104 ('passwordmustchange', 'off'),
105 ('passwordchange', 'off'))
106 # Try to change password fo a user even password even though pw policy is set to no
107 with pytest.raises(ldap.UNWILLING_TO_PERFORM):
108 _change_password_with_own(topo, user, 'dbyers1', 'AB')
109 # Set Password change to May Change Password
110 config.replace('passwordchange', 'on')
111 _change_password_with_own(topo, user, 'dbyers1', 'dbyers1')
112 # Try to change password with invalid credentials. Should see error message.
113 with pytest.raises(ldap.INVALID_CREDENTIALS):
114 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'AB', 'dbyers1')
115
116
117 def test_password_check_syntax(topo, _fix_password):
118 """Password check syntax
119
120 :id: 1e6fcc9e-5a20-11ea-9659-8c16451d917b
121 :setup: Standalone
122 :steps:
123 1. Sets Password check syntax to on
124 2. Try to change to a password that violates length. Should get error
125 3. Attempt to Modify password to db which is in error to policy
126 4. change min pw length to 5
127 5. Attempt to Modify password to dby3rs which is in error to policy
128 6. Attempt to Modify password to danny which is in error to policy
129 7. Attempt to Modify password to byers which is in error to policy
130 8. Change min pw length to 6
131 9. Try to change the password
132 10. Trying to set to a password containing value of sn
133 11. Sets policy to not check pw syntax
134 12. Test that when checking syntax is off, you can use small passwords
135 13. Test that when checking syntax is off, trivial passwords can be used
136 14. Changing password minimum length from 6 to 10
137 15. Setting policy to Check Password Syntax again
138 16. Try to change to a password that violates length
139 17. Reset Password
140 :expectedresults:
141 1. Success
142 2. Success
143 3. Success
144 4. Success
145 5. Success
146 6. Success
147 7. Success
148 8. Success
149 9. Success
150 10. Success
151 11. Success
152 12. Success
153 13. Success
154 14. Success
155 15. Success
156 16. Fail
157 17. Success
158 """
159 config = Config(topo.standalone)
160 # Sets Password check syntax to on
161 config.replace('passwordchecksyntax', 'on')
162 # Try to change to a password that violates length. Should get error
163 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
164 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers2')
165 # Attempt to Modify password to db which is in error to policy
166 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
167 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'db')
168 # change min pw length to 5
169 config.replace('passwordminlength', '5')
170 # Attempt to Modify password to dby3rs which is in error to policy
171 # Attempt to Modify password to danny which is in error to policy
172 # Attempt to Modify password to byers which is in error to policy
173 for password in ['dbyers', 'Danny', 'byers']:
174 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
175 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', password)
176 # Change min pw length to 6
177 config.replace('passwordminlength', '6')
178 # Try to change the password
179 # Trying to set to a password containing value of sn
180 for password in ['dby3rs1', 'dbyers2', '67Danny89', 'YAByers8']:
181 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
182 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', password)
183 # Sets policy to not check pw syntax
184 # Test that when checking syntax is off, you can use small passwords
185 # Test that when checking syntax is off, trivial passwords can be used
186 config.replace('passwordchecksyntax', 'off')
187 for password, new_pass in [('dbyers1', 'db'), ('db', 'dbyers'), ('dbyers', 'dbyers1')]:
188 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', password, new_pass)
189 # Changing password minimum length from 6 to 10
190 # Setting policy to Check Password Syntax again
191 config.replace_many(
192 ('passwordminlength', '10'),
193 ('passwordchecksyntax', 'on'))
194 # Try to change to a password that violates length
195 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
196 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'db')
197 UserAccount(topo.standalone, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}').replace('userpassword', 'dbyers1')
198
199
200 def test_too_big_password(topo, _fix_password):
201 """Test for long long password
202
203 :id: 299a3fb4-5a20-11ea-bba8-8c16451d917b
204 :setup: Standalone
205 :steps:
206 1. Setting policy to keep password histories
207 2. Changing number of password in history to 3
208 3. Modify password from dby3rs1 to dby3rs2
209 4. Checking that the passwordhistory attribute has been added
210 5. Add a password test for long long password
211 6. Changing number of password in history to 6 and passwordhistory off
212 :expectedresults:
213 1. Success
214 2. Success
215 3. Success
216 4. Success
217 5. Success
218 6. Success
219 """
220 config = Config(topo.standalone)
221 # Setting policy to keep password histories
222 config.replace_many(
223 ('passwordchecksyntax', 'off'),
224 ('passwordhistory', 'on'))
225 assert config.get_attr_val_utf8('passwordinhistory') == '6'
226 # Changing number of password in history to 3
227 config.replace('passwordinhistory', '3')
228 # Modify password from dby3rs1 to dby3rs2
229 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers2')
230 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
231 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', 'dbyers1')
232 # Checking that the passwordhistory attribute has been added
233 assert UserAccount(topo.standalone, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}').get_attr_val_utf8('passwordhistory')
234 # Add a password test for long long password
235 long_pass = 50*'0123456789'+'LENGTH=510'
236 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', long_pass)
237 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
238 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', long_pass, long_pass)
239 _change_password_with_root(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1')
240 # Changing number of password in history to 6 and passwordhistory off
241 config.replace_many(('passwordhistory', 'off'),
242 ('passwordinhistory', '6'))
243
244
245 def test_pwminage(topo, _fix_password):
246 """Test pwminage
247
248 :id: 2df7bf32-5a20-11ea-ad23-8c16451d917b
249 :setup: Standalone
250 :steps:
251 1. Get pwminage; should be 0 currently
252 2. Sets policy to pwminage 3
253 3. Change current password
254 4. Try to change password again
255 5. Try now after 3 secs is up, should work.
256 :expectedresults:
257 1. Success
258 2. Success
259 3. Success
260 4. Fail
261 5. Success
262 """
263 config = Config(topo.standalone)
264 # Get pwminage; should be 0 currently
265 assert config.get_attr_val_utf8('passwordminage') == '0'
266 # Sets policy to pwminage 3
267 config.replace('passwordminage', '3')
268 # Change current password
269 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers2')
270 # Try to change password again
271 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
272 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', 'dbyers1')
273 for _ in range(3):
274 time.sleep(1)
275 # Try now after 3 secs is up, should work.
276 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers2', 'dbyers1')
277 config.replace('passwordminage', '0')
278
279
280 def test_invalid_credentials(topo, _fix_password):
281 """Test bind again with valid password: We should be locked
282
283 :id: 3233ca78-5a20-11ea-8d35-8c16451d917b
284 :setup: Standalone
285 :steps:
286 1. Search if passwordlockout is off
287 2. Turns on passwordlockout
288 3. sets lockout duration to 3 seconds
289 4. Changing pw failure count reset duration to 3 sec and passwordminlength to 10
290 5. Try to bind with invalid credentials
291 6. Change password to password lockout forever
292 7. Try to bind with invalid credentials
293 8. Now bind again with valid password: We should be locked
294 9. Delete dby3rs before exiting
295 10. Reset server
296 :expectedresults:
297 1. Success
298 2. Success
299 3. Success
300 4. Success
301 5. Fail
302 6. Success
303 7. Success
304 8. Success
305 9. Success
306 10. Success
307 """
308 config = Config(topo.standalone)
309 # Search if passwordlockout is off
310 assert config.get_attr_val_utf8('passwordlockout') == 'off'
311 # Turns on passwordlockout
312 # sets lockout duration to 3 seconds
313 # Changing pw failure count reset duration to 3 sec and passwordminlength to 10
314 config.replace_many(
315 ('passwordlockout', 'on'),
316 ('passwordlockoutduration', '3'),
317 ('passwordresetfailurecount', '3'),
318 ('passwordminlength', '10'))
319 # Try to bind with invalid credentials
320 for _ in range(3):
321 with pytest.raises(ldap.INVALID_CREDENTIALS):
322 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
323 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
324 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
325 for _ in range(3):
326 time.sleep(1)
327 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers1')
328 # Change password to password lockout forever
329 config.replace('passwordunlock', 'off')
330 # Try to bind with invalid credentials
331 for _ in range(3):
332 with pytest.raises(ldap.INVALID_CREDENTIALS):
333 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
334 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
335 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'Invalid', 'dbyers1')
336 for _ in range(3):
337 time.sleep(1)
338 # Now bind again with valid password: We should be locked
339 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
340 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers1')
341 # Delete dby3rs before exiting
342 _change_password_with_root(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1')
343 time.sleep(1)
344 _change_password_with_own(topo, f'uid=dbyers,ou=People,{DEFAULT_SUFFIX}', 'dbyers1', 'dbyers1')
345 # Reset server
346 config.replace_many(
347 ('passwordinhistory', '6'),
348 ('passwordlockout', 'off'),
349 ('passwordlockoutduration', '3600'),
350 ('passwordminlength', '6'),
351 ('passwordresetfailurecount', '600'),
352 ('passwordunlock', 'on'))
353
354
355 def test_expiration_date(topo, _fix_password):
356 """Test check the expiration date is still in the future
357
358 :id: 3691739a-5a20-11ea-8712-8c16451d917b
359 :setup: Standalone
360 :steps:
361 1. Password expiration
362 2. Add a user with a password expiration date
363 3. Modify their password
364 4. Check the expiration date is still in the future
365 5. Modify the password expiration date
366 6. Check the expiration date is still in the future
367 7. Change policy so that user can change passwords
368 8. Deleting user
369 9. Adding user
370 10. Set password history ON
371 11. Modify password Once
372 12. Try to change the password with same one
373 :expectedresults:
374 1. Success
375 2. Success
376 3. Success
377 4. Success
378 5. Success
379 6. Success
380 7. Success
381 8. Success
382 9. Success
383 10. Success
384 11. Success
385 12. Fail
386 """
387 # Add a user with a password expiration date
388 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()
389 user.replace_many(
390 ('userpassword', 'bind4now'),
391 ('passwordExpirationTime', '20380119031404Z'))
392 # Modify their password
393 user.replace('userPassword', 'secreter')
394 # Check the expiration date is still in the future
395 assert user.get_attr_val_utf8('passwordExpirationTime') == '20380119031404Z'
396 # Modify the password expiration date
397 user.replace('passwordExpirationTime', '20380119031405Z')
398 # Check the expiration date is still in the future
399 assert user.get_attr_val_utf8('passwordExpirationTime') == '20380119031405Z'
400 config = Config(topo.standalone)
401 # Change policy so that user can change passwords
402 config.replace('passwordchange', 'on')
403 # Deleting user
404 UserAccount(topo.standalone, f'uid=test_user_1000,ou=People,{DEFAULT_SUFFIX}').delete()
405 # Adding user
406 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()
407 # Set password history ON
408 config.replace('passwordhistory', 'on')
409 # Modify password Once
410 user.replace('userPassword', 'secreter')
411 time.sleep(1)
412 assert DEFAULT_PASSWORD_STORAGE_SCHEME in user.get_attr_val_utf8('userPassword')
413 # Try to change the password with same one
414 for _ in range(3):
415 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
416 _change_password_with_own(topo, user.dn, 'secreter', 'secreter')
417 user.delete()
418
419
420 def test_passwordlockout(topo, _fix_password):
421 """Test adding admin user diradmin to Directory Administrator group
422
423 :id: 3ffcffda-5a20-11ea-a3af-8c16451d917b
424 :setup: Standalone
425 :steps:
426 1. Account Lockout must be cleared on successful password change
427 2. Adding admin user diradmin
428 3. Adding admin user diradmin to Directory Administrator group
429 4. Turn on passwordlockout
430 5. Sets lockout duration to 30 seconds
431 6. Sets failure count reset duration to 30 sec
432 7. Sets max password bind failure count to 3
433 8. Reset password retry count (to 0)
434 9. Try to bind with invalid credentials(3 times)
435 10. Try to bind with valid pw, should give lockout error
436 11. Reset password using admin login
437 12. Try to login as the user to check the unlocking of account. Will also change
438 the password back to original
439 13. Change to account lockout forever until reset
440 14. Reset password retry count (to 0)
441 15. Try to bind with invalid credentials(3 times)
442 16. Try to bind with valid pw, should give lockout error
443 17. Reset password using admin login
444 18. Try to login as the user to check the unlocking of account. Will also change the
445 password back to original
446 :expectedresults:
447 1. Success
448 2. Success
449 3. Success
450 4. Success
451 5. Success
452 6. Success
453 7. Success
454 8. Success
455 9. Fail
456 10. Success
457 11. Success
458 12. Success
459 13. Success
460 14. Success
461 15. Fail
462 16. Success
463 17. Success
464 18. Success
465 """
466 config = Config(topo.standalone)
467 # Adding admin user diradmin
468 user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()
469 user.replace('userpassword', 'dby3rs2')
470 admin = _create_user(topo, 'diradmin', 'Anuj Borah', '1002', 'diradmin')
471 # Adding admin user diradmin to Directory Administrator group
472 Group(topo.standalone, f'cn=user_passwd_reset,ou=permissions,{DEFAULT_SUFFIX}').add('member', admin.dn)
473 # Turn on passwordlockout
474 # Sets lockout duration to 30 seconds
475 # Sets failure count reset duration to 30 sec
476 # Sets max password bind failure count to 3
477 # Reset password retry count (to 0)
478 config.replace_many(
479 ('passwordlockout', 'on'),
480 ('passwordlockoutduration', '30'),
481 ('passwordresetfailurecount', '30'),
482 ('passwordmaxfailure', '3'),
483 ('passwordhistory', 'off'))
484 user.replace('passwordretrycount', '0')
485 # Try to bind with invalid credentials(3 times)
486 for _ in range(3):
487 with pytest.raises(ldap.INVALID_CREDENTIALS):
488 _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
489 # Try to bind with valid pw, should give lockout error
490 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
491 _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
492 # Reset password using admin login
493 conn = admin.bind('diradmin')
494 UserAccount(conn, user.dn).replace('userpassword', 'dby3rs2')
495 time.sleep(1)
496 # Try to login as the user to check the unlocking of account. Will also change
497 # the password back to original
498 _change_password_with_own(topo, user.dn, 'dby3rs2', 'secreter')
499 # Change to account lockout forever until reset
500 # Reset password retry count (to 0)
501 config.replace('passwordunlock', 'off')
502 user.replace('passwordretrycount', '0')
503 # Try to bind with invalid credentials(3 times)
504 for _ in range(3):
505 with pytest.raises(ldap.INVALID_CREDENTIALS):
506 _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
507 # Try to bind with valid pw, should give lockout error
508 with pytest.raises(ldap.CONSTRAINT_VIOLATION):
509 _change_password_with_own(topo, user.dn, 'Invalid', 'secreter')
510 # Reset password using admin login
511 UserAccount(conn, user.dn).replace('userpassword', 'dby3rs2')
512 time.sleep(1)
513 # Try to login as the user to check the unlocking of account. Will also change the
514 # password back to original
515 _change_password_with_own(topo, user.dn, 'dby3rs2', 'secreter')
516
517
518 def test_password_must_change_ignores_min_age(topo):
519 """Test that passwordMinAge does not block password update when the password was reset.
520
521 :id: a1b2c3d4-e5f6-4903-9abc-def012345678
522 :setup: Standalone instance
523 :steps:
524 1. Enable TLS (for ldappasswd StartTLS)
525 2. Set global policy via PwPolicyManager: passwordMustChange, passwordExp,
526 passwordMaxAge, passwordMinAge (high), passwordChange
527 3. Bind as Directory Manager
528 4. Create user
529 5. Reset user password as Directory Manager
530 6. User binds and changes own password (must succeed; min age must not block)
531 7. Rebind as Directory Manager, reset user password again
532 8. Run ldappasswd as user (StartTLS) to change password to password2
533 9. Bind as user with password2 to verify
534 10. Cleanup: delete user
535 :expectedresults:
536 1. TLS enabled
537 2. Policy set successfully
538 3. Bind succeeds
539 4. User created
540 5. Reset succeeds
541 6. User password change succeeds (min age does not block after reset)
542 7. Reset succeeds
543 8. ldappasswd succeeds
544 9. Bind succeeds
545 10. User deleted
546 """
547
548 topo.standalone.enable_tls()
549
550 policy = PwPolicyManager(topo.standalone)
551 policy.set_global_policy(properties={'nsslapd-pwpolicy-local': 'on',
552 'passwordMustChange': 'on',
553 'passwordExp': 'on',
554 'passwordMaxAge': '86400000',
555 'passwordMinAge': '8640000',
556 'passwordChange': 'on'})
557 dm = DirectoryManager(topo.standalone)
558 dm.bind()
559
560 user = _create_user(topo, 'user', 'Test User', '1002', PASSWORD)
561 try:
562 # Reset password as Directory Manager
563 user.replace('userpassword', PASSWORD)
564 time.sleep(1)
565
566 # Reset password as user (must succeed; min age must not block after reset)
567 user.rebind(PASSWORD)
568 user.replace('userpassword', PASSWORD)
569 time.sleep(1)
570
571 # Reset again as Directory Manager
572 dm.rebind(PASSWORD)
573 user.replace('userpassword', PASSWORD)
574 time.sleep(1)
575
576 # Change password through ldappasswd as user to ensure functionality
577 env = os.environ.copy()
578 env['LDAPTLS_CACERTDIR'] = topo.standalone.get_cert_dir()
579 cmd = [
580 'ldappasswd',
581 '-ZZ','-H', f"ldap://{topo.standalone.host}:{topo.standalone.port}",
582 '-D', user.dn, '-w', PASSWORD,
583 '-a', PASSWORD, '-s', 'password2',
584 user.dn,
585 ]
586 result = subprocess.run(cmd, env=env, capture_output=True, text=True)
587 assert result.returncode == 0, f'ldappasswd failed: {result.stderr}'
588
589 # Bind as user with new password
590 user.bind('password2')
591 finally:
592 dm.rebind(PASSWORD)
593 user.delete()
594
595
596 if __name__ == "__main__":
597 CURRENT_FILE = os.path.realpath(__file__)
598 pytest.main("-s -v %s" % CURRENT_FILE)