aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cleaner_tests/ipv6_test/ipv6_test.py
blob: 1334d92d8157460364164f87e1cfcd53b1a2c86e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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'
        )