aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cleaner_tests/basic_function_tests/report_with_mask.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cleaner_tests/basic_function_tests/report_with_mask.py')
-rw-r--r--tests/cleaner_tests/basic_function_tests/report_with_mask.py55
1 files changed, 37 insertions, 18 deletions
diff --git a/tests/cleaner_tests/basic_function_tests/report_with_mask.py b/tests/cleaner_tests/basic_function_tests/report_with_mask.py
index bb72cdde..2b694554 100644
--- a/tests/cleaner_tests/basic_function_tests/report_with_mask.py
+++ b/tests/cleaner_tests/basic_function_tests/report_with_mask.py
@@ -25,7 +25,8 @@ class ReportWithMask(StageOneReportTest):
# obfuscate a random word from /etc/hosts and ensure the updated
# sanitised file has same permissions (a+r)
try:
- self.hosts_obfuscated = open('/etc/hosts').read().strip('#\n').split()[-1]
+ self.hosts_obfuscated = open(
+ '/etc/hosts').read().strip('#\n').split()[-1]
except (FileNotFoundError, IndexError) as e:
self.warning(f"Unable to process /etc/hosts: {e}")
if self.hosts_obfuscated:
@@ -36,8 +37,10 @@ class ReportWithMask(StageOneReportTest):
self.assertOutputContains('Obfuscation completed')
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):
@@ -53,40 +56,53 @@ class ReportWithMask(StageOneReportTest):
# Note: do not test for starting with the 100.* block here, as test
# machines may have /32 addresses. Instead, test that the actual
# IP address is not present
- self.assertFileNotHasContent('ip_addr', self.sysinfo['pre']['networking']['ip_addr'])
+ self.assertFileNotHasContent(
+ 'ip_addr',
+ self.sysinfo['pre']['networking']['ip_addr']
+ )
def test_loopback_was_not_obfuscated(self):
self.assertFileHasContent('ip_addr', '127.0.0.1/8')
def test_mac_addrs_were_obfuscated(self):
- content = self.get_file_content('sos_commands/networking/ip_maddr_show')
+ content = self.get_file_content(
+ 'sos_commands/networking/ip_maddr_show'
+ )
for line in content.splitlines():
if line.strip().startswith('link'):
mac = line.strip().split()[1]
- assert mac.startswith('53:4f:53'), "Found unobfuscated mac addr %s" % mac
+ assert \
+ mac.startswith('53:4f:53'), \
+ f"Found unobfuscated mac addr {mac}"
def test_perms_unchanged_on_modified_file(self):
if self.hosts_obfuscated:
imode_orig = stat('/etc/hosts').st_mode
- imode_obfuscated = stat(self.get_name_in_archive('etc/hosts')).st_mode
+ imode_obfuscated = stat(
+ self.get_name_in_archive('etc/hosts')).st_mode
self.assertEqual(imode_orig, imode_obfuscated)
class ReportWithUserCustomisations(StageOneReportTest):
- """Testing for 1) obfuscated keywords provided by the user (--keywords option),
- and 2) skipping to clean specific files (--skip-cleaning-files option)
+ """Testing for 1) obfuscated keywords provided by the user (--keywords
+ option), and 2) skipping to clean specific files (--skip-cleaning-files
+ option)
:avocado: tags=stageone
"""
- sos_cmd = '--clean -o filesys,kernel --keywords=fstab,Linux,tmp,BOOT_IMAGE,fs.dentry-state \
- --skip-cleaning-files proc/cmdline,sos_commands/*/sysctl* --no-update'
+ sos_cmd = ('--clean -o filesys,kernel --keywords=fstab,Linux,tmp,'
+ 'BOOT_IMAGE,fs.dentry-state --skip-cleaning-files '
+ 'proc/cmdline,sos_commands/*/sysctl* --no-update')
- # Will the 'tmp' be properly treated in path to working dir without raising an error?
- # To make this test effective, we assume the test runs on a system / with Policy
- # returning '/var/tmp' as temp.dir
+ # Will the 'tmp' be properly treated in path to working dir without
+ # raising an error?
+ # To make this test effective, we assume the test runs on a system / with
+ # Policy returning '/var/tmp' as temp.dir
def test_keyword_in_tempdir_path(self):
- self.assertOutputContains('Your sosreport has been generated and saved in:')
+ self.assertOutputContains(
+ 'Your sosreport has been generated and saved in:'
+ )
self.assertTrue('tmp/' in self.archive)
# Ok, sort of cheesy here but this does actually test filename changes on
@@ -102,7 +118,10 @@ class ReportWithUserCustomisations(StageOneReportTest):
self.assertFileHasContent('proc/cmdline', 'BOOT_IMAGE')
def test_skip_cleaning_glob_file(self):
- self.assertFileHasContent('sos_commands/kernel/sysctl_-a', 'fs.dentry-state')
+ self.assertFileHasContent(
+ 'sos_commands/kernel/sysctl_-a',
+ 'fs.dentry-state'
+ )
class DefaultRemoveBinaryFilesTest(StageTwoReportTest):
@@ -134,8 +153,8 @@ class KeepBinaryFilesTest(StageTwoReportTest):
def test_warning_message_shown(self):
self.assertOutputContains(
- 'WARNING: binary files that potentially contain sensitive information '
- 'will NOT be removed from the final archive'
+ 'WARNING: binary files that potentially contain sensitive '
+ 'information will NOT be removed from the final archive'
)
def test_binary_is_in_archive(self):