diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2022-03-09 11:33:09 -0500 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2022-03-14 10:12:14 -0400 |
commit | 47465338a510b05a4104deb68e9b209391ea37bd (patch) | |
tree | 37aba396cc671e9fceac57849b83ab6bc9d7bcf8 /tests/unittests/cleaner_tests.py | |
parent | 950f84728976cda298d05bbc7bd9ff3fc78768f5 (diff) | |
download | sos-47465338a510b05a4104deb68e9b209391ea37bd.tar.gz |
[mac_parser] Match quoted mac addresses, fix duplication check
First, update the regexes to account for possible quotes wrapping the
mac address to match.
Second, fix an edge case with these quoted mac addresses in our check
for avoiding duplicating obfuscations of already obfuscated addresses by
checking the stripped mac address instead of the raw one.
Closes: #2873
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/unittests/cleaner_tests.py')
-rw-r--r-- | tests/unittests/cleaner_tests.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unittests/cleaner_tests.py b/tests/unittests/cleaner_tests.py index b59eade9..39f81a78 100644 --- a/tests/unittests/cleaner_tests.py +++ b/tests/unittests/cleaner_tests.py @@ -131,6 +131,30 @@ class CleanerParserTests(unittest.TestCase): _test = self.mac_parser.parse_line(line)[0] self.assertNotEqual(line, _test) + def test_mac_parser_with_quotes(self): + line = "foobar foo '12:34:56:78:90:AA' bar barfoo" + _test = self.mac_parser.parse_line(line)[0] + self.assertNotEqual(line, _test) + dline = 'foobar foo "aa:12:bb:34:cc:56" bar barfoo' + _dtest = self.mac_parser.parse_line(dline)[0] + self.assertNotEqual(dline, _dtest) + + def test_mac_parser_with_quotes_ipv6(self): + line = "foobar foo 'FF:EE:DD:FF:FE:CC:BB:AA' bar barfoo" + _test = self.mac_parser.parse_line(line)[0] + self.assertNotEqual(line, _test) + dline = 'foobar foo "DD:EE:FF:FF:FE:BB:CC:AA" bar barfoo' + _dtest = self.mac_parser.parse_line(dline)[0] + self.assertNotEqual(dline, _dtest) + + def test_mac_parser_with_quotes_ipv6_quad(self): + line = "foobar foo 'AABB:CCDD:EEFF:FFAA' bar barfoo" + _test = self.mac_parser.parse_line(line)[0] + self.assertNotEqual(line, _test) + dline = 'foobar foo "AAFF:FFEE:DDCC:BBAA" bar barfoo' + _dtest = self.mac_parser.parse_line(dline)[0] + self.assertNotEqual(dline, _dtest) + def test_hostname_load_hostname_string(self): fqdn = 'myhost.subnet.example.com' self.host_parser.load_hostname_into_map(fqdn) |