aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cleaner_tests/existing_archive.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cleaner_tests/existing_archive.py')
-rw-r--r--tests/cleaner_tests/existing_archive.py63
1 files changed, 45 insertions, 18 deletions
diff --git a/tests/cleaner_tests/existing_archive.py b/tests/cleaner_tests/existing_archive.py
index 7f31f88e..57bae713 100644
--- a/tests/cleaner_tests/existing_archive.py
+++ b/tests/cleaner_tests/existing_archive.py
@@ -13,6 +13,7 @@ from sos_tests import StageTwoReportTest
ARCHIVE = 'sosreport-cleanertest-2021-08-03-qpkxdid'
+
class ExistingArchiveCleanTest(StageTwoReportTest):
"""Ensure that we can extract an already created archive and clean it the
same as we would an in-line run of `report --clean`.
@@ -26,34 +27,52 @@ class ExistingArchiveCleanTest(StageTwoReportTest):
sos_component = 'clean'
def test_obfuscation_log_created(self):
- self.assertFileExists(os.path.join(self.tmpdir, '%s-obfuscation.log' % ARCHIVE))
+ self.assertFileExists(
+ os.path.join(self.tmpdir, f'{ARCHIVE}-obfuscation.log')
+ )
def test_archive_type_correct(self):
- with open(os.path.join(self.tmpdir, '%s-obfuscation.log' % ARCHIVE), 'r') as log:
+ with open(os.path.join(
+ self.tmpdir,
+ f'{ARCHIVE}-obfuscation.log'), 'r') as log:
for line in log:
if "Loaded %s" % ARCHIVE in line:
- assert 'as type sos report archive' in line, "Incorrect archive type detected: %s" % line
+ assert \
+ 'as type sos report archive' in line, \
+ f"Incorrect archive type detected: {line}"
break
def test_from_cmdline_logged(self):
- with open(os.path.join(self.tmpdir, '%s-obfuscation.log' % ARCHIVE), 'r') as log:
+ with open(os.path.join(
+ self.tmpdir,
+ f'{ARCHIVE}-obfuscation.log'), 'r') as log:
for line in log:
if 'From cmdline' in line:
- assert 'From cmdline: True' in line, "Did not properly log cmdline run"
+ assert \
+ 'From cmdline: True' in line, \
+ "Did not properly log cmdline run"
break
def test_extraction_completed_successfully(self):
- with open(os.path.join(self.tmpdir, '%s-obfuscation.log' % ARCHIVE), 'r') as log:
+ with open(os.path.join(
+ self.tmpdir,
+ f'{ARCHIVE}-obfuscation.log'), 'r') as log:
for line in log:
if 'Extracted path is' in line:
path = line.split('Extracted path is')[-1].strip()
- assert path.startswith(self.tmpdir), "Extracted path appears wrong: %s (tmpdir: %s)" % (path, self.tmpdir)
+ assert \
+ path.startswith(self.tmpdir), \
+ (f"Extracted path appears wrong: {path} "
+ f"(tmpdir: {self.tmpdir})")
return
self.fail("Extracted path not logged")
def test_private_map_was_generated(self):
- self.assertOutputContains('A mapping of obfuscated elements is available at')
- map_file = re.findall('/.*sosreport-.*-private_map', self.cmd_output.stdout)[-1]
+ self.assertOutputContains(
+ 'A mapping of obfuscated elements is available at'
+ )
+ map_file = re.findall(
+ '/.*sosreport-.*-private_map', self.cmd_output.stdout)[-1]
self.assertFileExists(map_file)
def test_tarball_named_obfuscated(self):
@@ -70,7 +89,9 @@ class ExistingArchiveCleanTest(StageTwoReportTest):
def test_no_empty_obfuscations(self):
# get the private map file name
- map_file = re.findall('/.*sosreport-.*-private_map', self.cmd_output.stdout)[-1]
+ map_file = re.findall(
+ '/.*sosreport-.*-private_map', self.cmd_output.stdout
+ )[-1]
with open(map_file, 'r') as mf:
map_json = json.load(mf)
for mapping in map_json:
@@ -83,12 +104,17 @@ class ExistingArchiveCleanTest(StageTwoReportTest):
if not content:
assert True
else:
- self.fail("IP appears in files: %s" % "\n".join(f for f in content))
+ new_content = "\n".join(f for f in content)
+ self.fail(f'IP appears in files: {new_content}')
def test_user_is_obfuscated(self):
"""Ensure that the 'testuser1' user created at install is obfuscated
"""
- self.assertFileNotHasContent('var/log/anaconda/journal.log', 'testuser1')
+ self.assertFileNotHasContent(
+ 'var/log/anaconda/journal.log',
+ 'testuser1'
+ )
+
class ExistingArchiveCleanTmpTest(StageTwoReportTest):
"""Continuation of above tests which requires cleaning var / tmp keywords
@@ -98,13 +124,14 @@ class ExistingArchiveCleanTmpTest(StageTwoReportTest):
:avocado: tags=stagetwo
"""
- sos_cmd = '-v --keywords var,tmp,avocado --disable-parsers ip,ipv6,mac,username \
- --no-update tests/test_data/%s.tar.xz' % ARCHIVE
+ sos_cmd = f'-v --keywords var,tmp,avocado --disable-parsers \
+ ip,ipv6,mac,username --no-update tests/test_data/{ARCHIVE}.tar.xz'
sos_component = 'clean'
def test_sys_tmp_not_obfuscated(self):
- """ Ensure that keywords var, tmp and avocado remains in the final archive
- path despite they are parts of the --tmp-dir
+ """ Ensure that keywords var, tmp and avocado remains in the final
+ archive path despite they are parts of the --tmp-dir
"""
- self.assertTrue(self.archive.startswith(os.getenv('AVOCADO_TESTS_COMMON_TMPDIR')))
-
+ self.assertTrue(
+ self.archive.startswith(os.getenv('AVOCADO_TESTS_COMMON_TMPDIR'))
+ )