Skip to content

Commit

Permalink
Extend log_command_verification cases
Browse files Browse the repository at this point in the history
* verify that the username and organization get obfuscated in log file
  and bredcrumbs

Signed-off-by: Daniel Diblik <[email protected]>
  • Loading branch information
danmyway authored and bocekm committed Feb 21, 2023
1 parent 710f0e5 commit 4dba67a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
3 changes: 1 addition & 2 deletions convert2rhel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 20 additions & 6 deletions tests/integration/tier0/log-command/test_log_command.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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)
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4dba67a

Please sign in to comment.