Skip to content

Commit d45c72b

Browse files
authored
Merge pull request #82 from DMTF/Fix81-Pass-Chng-Req-New-Handling
Modified 'password change required' testing to PATCH a user's password
2 parents 2d74470 + 1e40f12 commit d45c72b

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

redfish_use_case_checkers/account_management.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def use_cases(sut: SystemUnderTest):
9393
test_username = acc_test_user_count(sut)
9494
user_added, test_password = acc_test_add_user(sut, test_username)
9595
acc_test_enable_user(sut, user_added, test_username)
96-
acc_test_dis_pass_chng_req(sut, user_added, test_username)
96+
test_password = acc_test_dis_pass_chng_req(sut, user_added, test_username, test_password)
9797
acc_test_credential_check(sut, user_added, test_username, test_password)
9898
acc_test_change_role(sut, user_added, test_username)
9999
acc_test_delete_user(sut, user_added, test_username)
@@ -190,10 +190,9 @@ def acc_test_add_user(sut: SystemUnderTest, username: str):
190190
last_error = ""
191191
operation = "Creating new user '{}' as 'Administrator'".format(username)
192192
logger.logger.info(operation)
193-
for x in range(3):
193+
for test_password in test_passwords:
194194
# Try different passwords in case there are password requirements that we cannot detect
195195
try:
196-
test_password = test_passwords[x]
197196
redfish_utilities.add_user(sut.session, username, test_password, "Administrator")
198197
user_added = True
199198
break
@@ -273,18 +272,24 @@ def acc_test_enable_user(sut: SystemUnderTest, user_added: bool, username: str):
273272
logger.log_use_case_test_footer(CAT_NAME, test_name)
274273

275274

276-
def acc_test_dis_pass_chng_req(sut: SystemUnderTest, user_added: bool, username: str):
275+
def acc_test_dis_pass_chng_req(sut: SystemUnderTest, user_added: bool, username: str, password: str):
277276
"""
278277
Performs the disable password change required test
279278
280279
Args:
281280
sut: The system under test
282281
user_added: Indicates if the test user was added
283282
username: The username for testing
283+
password: The current password for testing
284+
285+
Returns:
286+
The new password for testing
284287
"""
285288

286289
test_name = TEST_DIS_PASS_CHNG_REQ[0]
287290
logger.log_use_case_test_header(CAT_NAME, test_name)
291+
test_passwords = ["lUBga9Z9", "8jBl6zq.kd0Fcl", "q9Rjev7*n0opvcS!m0kmMGH69!"]
292+
user_modified = False
288293

289294
# Skip the test if the test user was not added
290295
if not user_added:
@@ -296,14 +301,31 @@ def acc_test_dis_pass_chng_req(sut: SystemUnderTest, user_added: bool, username:
296301
"Failure of the '{}' test prevents performing this test.".format(TEST_ADD_USER[0]),
297302
)
298303
logger.log_use_case_test_footer(CAT_NAME, test_name)
299-
return
304+
return password
300305

301306
# Check if password change required needs to be disabled
302-
operation = "Disabling password change required for user '{}'".format(username)
307+
operation = "Disabling password change required for user '{}' by modifying their password".format(username)
303308
logger.logger.info(operation)
304309
try:
305310
if verify_user(sut.session, username, pass_chng_req=True):
306-
redfish_utilities.modify_user(sut.session, username, new_pass_chng_req=False)
311+
last_error = ""
312+
for test_password in test_passwords:
313+
# Try different passwords in case there are password requirements that we cannot detect
314+
try:
315+
redfish_utilities.modify_user(sut.session, username, new_password=test_password)
316+
user_modified = True
317+
password = test_password
318+
break
319+
except Exception as err:
320+
last_error = err
321+
if not user_modified:
322+
sut.add_test_result(
323+
CAT_NAME,
324+
test_name,
325+
operation,
326+
"FAIL",
327+
"Failed to modify the password for user '{}' ({}).".format(username, last_error),
328+
)
307329
if verify_user(sut.session, username, pass_chng_req=False):
308330
sut.add_test_result(CAT_NAME, test_name, operation, "PASS")
309331
else:
@@ -328,6 +350,7 @@ def acc_test_dis_pass_chng_req(sut: SystemUnderTest, user_added: bool, username:
328350
)
329351

330352
logger.log_use_case_test_footer(CAT_NAME, test_name)
353+
return password
331354

332355

333356
def acc_test_credential_check(sut: SystemUnderTest, user_added: bool, username: str, password: str):

0 commit comments

Comments
 (0)