aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2024-02-16 22:27:49 +0100
committerJake Hunsaker <jacob.r.hunsaker@gmail.com>2024-02-17 11:31:05 -0500
commit5f95f2d30c1c900ee65102cd002135258599749a (patch)
treed0cb28ac2cbbaea56a63ae234f1c6b5c302283fd
parent76a7366928d8fcb6cb8b93bd8602228dcc6b9bbe (diff)
downloadsos-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>
-rw-r--r--tests/unittests/cleaner_tests.py11
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):
"""