From 62a451416adbdb34deef747febf3c5acbd0fd332 Mon Sep 17 00:00:00 2001 From: Akshay Adhikari Date: Fri, 15 Dec 2017 16:50:30 +0530 Subject: [PATCH] Issue 49312 - Added new test case for "-D configdir" Bug Description: "pwdhash -D configdir" uses the DS default hashing algorithm Fix Description: add a test case that changes default pwdhash scheme https://pagure.io/389-ds-base/issue/49312 --- dirsrvtests/tests/suites/clu/clu_test.py | 41 +++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/dirsrvtests/tests/suites/clu/clu_test.py b/dirsrvtests/tests/suites/clu/clu_test.py index cec1762..6ea56e7 100644 --- a/dirsrvtests/tests/suites/clu/clu_test.py +++ b/dirsrvtests/tests/suites/clu/clu_test.py @@ -6,7 +6,8 @@ # See LICENSE for details. # --- END COPYRIGHT BLOCK --- # - +import time +import subprocess import pytest from lib389.tasks import * from lib389.utils import * @@ -37,7 +38,6 @@ def test_clu_pwdhash(topology_st): log.info('Running test_clu_pwdhash...') cmd = '%s -s ssha testpassword' % os.path.join(topology_st.standalone.get_bin_dir(), 'pwdhash') - p = os.popen(cmd) result = p.readline() p.close() @@ -49,11 +49,46 @@ def test_clu_pwdhash(topology_st): if len(result) < 20: log.fatal('test_clu_pwdhash: Encrypted password is too short') assert False - log.info('pwdhash generated: ' + result) log.info('test_clu_pwdhash: PASSED') +def test_clu_pwdhash_mod(topology_st): + """Test the pwdhash script output with -D configdir + + :id: 874ab5e2-207b-4a95-b4c0-22d97b8ab643 + + :setup: Standalone instance + + :steps: + 1. Set nsslapd-rootpwstoragescheme & passwordStorageScheme to SSHA256 & SSHA384 respectively + 2. Execute /usr/bin/pwdhash -D /etc/dirsrv/slapd-instance_name/ + 3. Check if there is any output + 4. Check if the command returns the hashed string using the algorithm set in nsslapd-rootpwstoragescheme + + :expectedresults: + 1. nsslapd-rootpwstoragescheme & passwordStorageScheme should set to SSHA256 & SSHA384 respectively + 2. Execution should PASS + 3. There should be an output from the command + 4. Command should return the hashed string using the algorithm set in nsslapd-rootpwstoragescheme + """ + + log.info('Running test_clu_pwdhash_mod...') + topology_st.standalone.config.set('nsslapd-rootpwstoragescheme','SSHA256') + topology_st.standalone.config.set('passwordStorageScheme','SSHA384') + reset ='{} restart dirsrv@standalone1.service'.format(os.path.join(topology_st.standalone.get_bin_dir(), 'systemctl')) + os.popen(reset) + time.sleep(10) + cmd = [os.path.join(topology_st.standalone.get_bin_dir(), 'pwdhash'), '-D', '/etc/dirsrv/slapd-standalone1', 'password'] + result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = result.communicate() + if not result: assert result, "Failed to run pwdhash" + if result: + assert 'SSHA256'.encode("utf-8") in stdout + log.info('returned the hashed string using the algorithm set in nsslapd-rootpwstoragescheme') + + + if __name__ == '__main__': # Run isolated # -s for DEBUG mode -- 1.8.3.1