diff options
author | Miroslav Hradilek <mhradile@redhat.com> | 2023-01-20 17:27:40 +0100 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2023-01-27 12:18:21 -0500 |
commit | 59a755f3e72fcc6cd5fc8e584c98d7974fec01e3 (patch) | |
tree | c7d645f663a2fd26bbfe98e109b1207bc915b535 /tests/cleaner_tests | |
parent | d19e8e6ed0b8e28fdf231c8c40127d93386e7921 (diff) | |
download | sos-59a755f3e72fcc6cd5fc8e584c98d7974fec01e3.tar.gz |
[test] Add stage 2 test for ipv6 obfuscation
Relates: #3060
Signed-off-by: Miroslav Hradilek <mhradile@redhat.com>
Diffstat (limited to 'tests/cleaner_tests')
-rw-r--r-- | tests/cleaner_tests/ipv6_test/default_mapping | 0 | ||||
-rw-r--r-- | tests/cleaner_tests/ipv6_test/ipv6.py | 23 | ||||
-rw-r--r-- | tests/cleaner_tests/ipv6_test/ipv6_test.py | 38 | ||||
-rw-r--r-- | tests/cleaner_tests/ipv6_test/sos-test-ipv6.txt | 7 |
4 files changed, 68 insertions, 0 deletions
diff --git a/tests/cleaner_tests/ipv6_test/default_mapping b/tests/cleaner_tests/ipv6_test/default_mapping new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/cleaner_tests/ipv6_test/default_mapping diff --git a/tests/cleaner_tests/ipv6_test/ipv6.py b/tests/cleaner_tests/ipv6_test/ipv6.py new file mode 100644 index 00000000..32ec3aa4 --- /dev/null +++ b/tests/cleaner_tests/ipv6_test/ipv6.py @@ -0,0 +1,23 @@ +# This file is part of the sos project: https://github.com/sosreport/sos +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# version 2 of the GNU General Public License. +# +# See the LICENSE file in the source distribution for further information. + +from sos.report.plugins import Plugin, IndependentPlugin + + +class IPv6(Plugin, IndependentPlugin): + """Collect arbitrary file containing crafted ipv6 adresses to test ipv6 + obfuscation. + """ + + plugin_name = 'ipv6' + short_desc = 'fake plugin to test ipv6 obfuscation' + + def setup(self): + self.add_copy_spec([ + '/tmp/sos-test-ipv6.txt', + ]) diff --git a/tests/cleaner_tests/ipv6_test/ipv6_test.py b/tests/cleaner_tests/ipv6_test/ipv6_test.py new file mode 100644 index 00000000..851b7678 --- /dev/null +++ b/tests/cleaner_tests/ipv6_test/ipv6_test.py @@ -0,0 +1,38 @@ +# This file is part of the sos project: https://github.com/sosreport/sos +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# version 2 of the GNU General Public License. +# +# See the LICENSE file in the source distribution for further information. + +from sos_tests import StageTwoReportTest + +MOCK_FILE = '/tmp/sos-test-ipv6.txt' + +class IPv6Test(StageTwoReportTest): + """Place artificial plugin collecting crafted text file with ipv6 adresses + to make sure ipv6 obfuscation works when calling 'sos clean' like a user + would. + + :avocado: tags=stagetwo + """ + + install_plugins = ['ipv6'] + sos_cmd = '-v --clean -o ipv6' + sos_timeout = 600 + # replace default mapping to avoid being influenced by previous runs + # place mock file with crafted address used by mocked plugin + files = [ + ('default_mapping', '/etc/sos/cleaner/default_mapping'), + ('sos-test-ipv6.txt', MOCK_FILE) + ] + + def test_valid_ipv6(self): + self.assertFileCollected(MOCK_FILE) + self.assertFileHasContent(MOCK_FILE, 'GOOD_IP=') + self.assertFileNotHasContent(MOCK_FILE, 'GOOD_IP=3000:505f:505f:505f:505f:505f:505f:505f') + + def test_bad_ipv6(self): + self.assertFileHasContent(MOCK_FILE, 'BAD_IP=') + self.assertFileNotHasContent(MOCK_FILE, 'BAD_IP=505f:505f:505f:505f:505f:505f:505f:505f') diff --git a/tests/cleaner_tests/ipv6_test/sos-test-ipv6.txt b/tests/cleaner_tests/ipv6_test/sos-test-ipv6.txt new file mode 100644 index 00000000..6ce7e315 --- /dev/null +++ b/tests/cleaner_tests/ipv6_test/sos-test-ipv6.txt @@ -0,0 +1,7 @@ +This is a test file for ipv6 address obfuscation. + +This address should be obfuscated +GOOD_IP=3000:505f:505f:505f:505f:505f:505f:505f + +This address should not get sos stuck +BAD_IP=505f:505f:505f:505f:505f:505f:505f:505f |