diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2024-02-16 22:27:49 +0100 |
---|---|---|
committer | Jake Hunsaker <jacob.r.hunsaker@gmail.com> | 2024-02-17 11:31:05 -0500 |
commit | 5f95f2d30c1c900ee65102cd002135258599749a (patch) | |
tree | d0cb28ac2cbbaea56a63ae234f1c6b5c302283fd /tests/unittests | |
parent | 76a7366928d8fcb6cb8b93bd8602228dcc6b9bbe (diff) | |
download | sos-5f95f2d30c1c900ee65102cd002135258599749a.tar.gz |
[cleaner] add tests for short strings and incomplete words
Some parsers should skip strings <=3 length and some mappings should
obfuscate just full words.
Relevant: #3403
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/cleaner_tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unittests/cleaner_tests.py b/tests/unittests/cleaner_tests.py index ca5231a7..eec84e9c 100644 --- a/tests/unittests/cleaner_tests.py +++ b/tests/unittests/cleaner_tests.py @@ -164,6 +164,7 @@ class CleanerParserTests(unittest.TestCase): self.kw_parser.generate_item_regexes() self.uname_parser = SoSUsernameParser(config={}) self.uname_parser.mapping.add('DOMAIN\myusername') + self.uname_parser.mapping.add('foo') def test_ip_parser_valid_ipv4_line(self): line = 'foobar foo 10.0.0.1/24 barfoo bar' @@ -246,6 +247,11 @@ class CleanerParserTests(unittest.TestCase): _test = self.kw_parser.parse_line(line)[0] self.assertNotEqual(line, _test) + def test_keyword_parser_fullword_only(self): + line = 'notfoobar and foobars line' + _test = self.kw_parser.parse_line(line)[0] + self.assertEqual(line, _test) + def test_keyword_parser_no_change_by_default(self): line = 'this is my foobar test line' _test = self.kw_parser_none.parse_line(line)[0] @@ -280,6 +286,11 @@ class CleanerParserTests(unittest.TestCase): _test = self.uname_parser.parse_line(line)[0] self.assertNotEqual(line, _test) + def test_too_short_username(self): + line = "but foo is too short username" + _test = self.uname_parser.parse_line(line)[0] + self.assertEqual(line, _test) + class PrepperTests(unittest.TestCase): """ |