From 4dba67a426638b8238b56ecb346a087cc600dc27 Mon Sep 17 00:00:00 2001 From: Daniel Diblik Date: Wed, 15 Feb 2023 20:05:52 +0100 Subject: [PATCH] Extend log_command_verification cases * verify that the username and organization get obfuscated in log file and bredcrumbs Signed-off-by: Daniel Diblik --- convert2rhel/utils.py | 3 +-- .../tier0/log-command/test_log_command.py | 26 ++++++++++++++----- .../test_check_rollback_handling.py | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/convert2rhel/utils.py b/convert2rhel/utils.py index 426e9ae52b..f8205790e1 100644 --- a/convert2rhel/utils.py +++ b/convert2rhel/utils.py @@ -748,8 +748,7 @@ def hide_secrets( if hide_next: loggerinst.debug( - "Passed arguments had an option, '{0}', without an expected" - " secret parameter".format(sanitized_list[-1]) # lgtm[py/clear-text-logging-sensitive-data] + "Passed arguments had an option, '{0}', without an expected secret parameter".format(sanitized_list[-1]) ) return sanitized_list diff --git a/tests/integration/tier0/log-command/test_log_command.py b/tests/integration/tier0/log-command/test_log_command.py index 1c23764735..f018b82a75 100644 --- a/tests/integration/tier0/log-command/test_log_command.py +++ b/tests/integration/tier0/log-command/test_log_command.py @@ -1,4 +1,8 @@ +import json + + C2R_LOG = "/var/log/convert2rhel/convert2rhel.log" +C2R_FACTS = "/etc/rhsm/facts/convert2rhel.facts" def test_verify_logfile_starts_with_command(shell): @@ -10,14 +14,13 @@ def test_verify_logfile_starts_with_command(shell): username = "jdoe" password = "foobar" activationkey = "a-map-of-a-key" + organization = "SoMe_NumberS-8_a_lettER" - command_long = ( - "convert2rhel --debug --no-rpm-va --serverurl {} --username {} --password {} --activationkey {}".format( - serverurl, username, password, activationkey - ) + command_long = "convert2rhel --debug --no-rpm-va --serverurl {} --username {} --password {} --activationkey {} --org {}".format( + serverurl, username, password, activationkey, organization ) - command_short = "convert2rhel --debug --no-rpm-va --serverurl {} -u {} -p {} -k {}".format( - serverurl, username, password, activationkey + command_short = "convert2rhel --debug --no-rpm-va --serverurl {} -u {} -p {} -k {} -o {}".format( + serverurl, username, password, activationkey, organization ) command_verification = "convert2rhel --debug --no-rpm-va --serverurl {}".format(serverurl) @@ -41,3 +44,14 @@ def test_verify_logfile_starts_with_command(shell): assert command_verification in command_line assert password not in command_line assert activationkey not in command_line + assert username not in command_line + assert organization not in command_line + + with open(C2R_FACTS, "r") as breadcrumbs: + data = json.load(breadcrumbs) + command = data.get("conversions.executed") + + assert password not in command + assert activationkey not in command + assert username not in command + assert organization not in command diff --git a/tests/integration/tier0/test-check-rollback-handling/test_check_rollback_handling.py b/tests/integration/tier0/test-check-rollback-handling/test_check_rollback_handling.py index 91b2a3339c..e4c12a8cd2 100644 --- a/tests/integration/tier0/test-check-rollback-handling/test_check_rollback_handling.py +++ b/tests/integration/tier0/test-check-rollback-handling/test_check_rollback_handling.py @@ -78,7 +78,7 @@ def terminate_and_assert_good_rollback(c2r): # Verify the last step of the rollback is present in the log file with open("/var/log/convert2rhel/convert2rhel.log", "r") as logfile: for line in logfile: - assert "Rollback: Removing installed RHSM certificate" not in line + assert "Rollback: Remove installed RHSM certificate" not in line def test_proper_rhsm_clean_up(shell, convert2rhel):