Exemplo n.º 1
0
    def hostname_test(self):
        good_tests = [
                '0',
                'a',
                'A',
                'hostname',
                'host-name',
                'host.name',
                'host.name.with.oneverylongsectionthatisexactly63characterslong-and-contains-se',
                '3numberstart',
                'numberend3',
                'first.3numberstart',
                'first.3numberend',
                'dot.end.'
                ]

        bad_tests = [
                '.',
                '..',
                'too..many.dots',
                '-hypenstart',
                'hyphenend-',
                'first.-hyphenstart',
                'first.hyphenend-',
                'bad,character',
                '.dot.start',
                'host.name.with.oneverylongsectionthatisexactly64characterslong-and-contains-sev',
                'únicode'
                ]

        hostname_re = re.compile('^' + HOSTNAME_PATTERN_WITHOUT_ANCHORS + '$')
        if not regex_match(hostname_re, good_tests, bad_tests):
            self.fail()
Exemplo n.º 2
0
    def iqnname_test(self):
        good_tests = [
                'iqn.2014-15.com.example',
                'iqn.2014-15.com.example:iscsi',
                'iqn.2014-15.c-om.example:iscsi',
                'iqn.2014-15.c.om.example:iscsi',
                'iqn.2014-15.com.example:...',
                'iqn.2014-15.com.example:iscsi_@nything_except_colon_after_colon!'
                ]

        bad_tests = [
                'iqn',
                'iqn.',
                'iqn.2014-15',
                'iqn.2014-15.',
                'iqn.2014-15..',
                'iqn.2014-15.com.example.',
                'iqn.2014-15.com.example...',
                'iqn.2014-15.com.example:',
                'iqn.2014-15.-com.example',
                'iqn.2014-15.com-.example',
                'iqn.2014-15.-.example',
                'iqn.2014-15.com.example-:iscsi',
                'abciqn.2014-15.com.example:iscsi',
                'iqn.2014-15.-.example:iscsi',
                'iqn.2014-15.com&com.example:iscsi',
                'iqn.2014-15.com.example:iscsi:doublecolon',
                'iqn.2014-15..om.example:iscsi',
                ]

        if not regex_match(ISCSI_IQN_NAME_REGEX, good_tests, bad_tests):
            self.fail()
Exemplo n.º 3
0
    def device_name_test(self):
        good_tests = [
                '0.0.0000',
                '0.0.abcd',
                '0.0.ABCD',
                '1.2.3456',
                '1.2.000a',
                '1.2.00a',
                '1.2.0a',
                '1.2.a',
                '.000a',
                '.00a',
                '.0a',
                '.a',
                '000a',
                '00a',
                '0a',
                'a',
                ]

        bad_tests = [
                'totalnonsens',
                'a.a.0000',
                '0.0.gggg',
                '0.000a',
                '0.0.',
                '01.01.abcd',
                '0.0.abcde',
                '',
                ]

        if not regex_match(DASD_DEVICE_NUMBER, good_tests, bad_tests):
            self.fail()
Exemplo n.º 4
0
    def grouplist_simple_test(self):
        good_tests = [
                '',
                'gburdell',
                ' gburdell',
                ' \tgburdell',
                'gburdell ',
                'gburdell \t',
                '  gburdell  ',
                'gburdell,wheel',
                'gburdell, wheel',
                '  gburdell,  wheel',
                'gburdell,  wheel  ',
                '  gburdell,  wheel  ',
                'gburdell,  wheel',
                'gburdell,wheel, mock'
                ]

        bad_tests = [
                ',',
                '-invalid',
                'gburdell, -invalid',
                'gburdell,',
                'gburdell, ',
                ',gburdell',
                '  ,gburdell',
                ',gburdell,'
                'gburdell, wheel,'
                ]

        if not regex_match(GROUPLIST_SIMPLE_VALID, good_tests, bad_tests):
            self.fail()
Exemplo n.º 5
0
    def username_test(self):
        """Test a list of possible username values."""
        good_tests = [
                'gburdell',
                'GBurdell',
                'gburdell$',
                'g_burdell',
                '_burdell',
                'gggggggggggggggggggggggggburdell', # 32 characters
                'ggggggggggggggggggggggggburdell$',
                '_',
                'r',
                'ro',
                'roo',
                'roota',
                ]

        bad_tests = [
                '',
                '-gburdell',    # can't start with a hyphen
                'gburdełl',     # invalid character
                'g:burdell',
                'g burdell',
                'g,burdell',
                'ggggggggggggggggggggggggggburdell', # 33 characters
                'gggggggggggggggggggggggggburdell$',
                ' gburdell',
                ':gburdell',
                '$',
                '-'
                ]

        # The group name checks for the same thing as the user name
        if not regex_match(NAME_VALID, good_tests, bad_tests):
            self.fail()
Exemplo n.º 6
0
    def wwpn_name_test(self):
        good_tests = [
            '0x0000000000000000',
            '0x0123456789abcdef',
            '0x0123456789ABCDEF',
            '0000000000000000',
            '0123456789abcdef',
            '0123456789ABCDEF',
        ]

        bad_tests = [
            'totalnonsens',
            '0x00000000000000000',
            '0x000000000000000g',
            '0y0000000000000000',
            '0x000000000000000',
            '00000000000000000',
            '000000000000000g',
            '000000000000000',
            '0x0123456789abcde',
            '0x0123456789ABCDE',
            '0123456789abcde',
            '0123456789ABCDE',
            '0',
            '',
        ]

        if not regex_match(ZFCP_WWPN_NUMBER, good_tests, bad_tests):
            self.fail()
Exemplo n.º 7
0
    def lun_name_test(self):
        good_tests = [
                '0x0000000000000000',
                '0x0123456789abcdef',
                '0x0123456789ABCDEF',
                '0x01234567',
                '0x0123',
                '0x0',
                '0000000000000000',
                '0123456789abcdef',
                '0123456789ABCDEF',
                '01234567',
                '0123',
                '0',
                ]

        bad_tests = [
                'totalnonsens',
                '0x00000000000000000',
                '0xabcdefg',
                '1x0',
                '0y0',
                '',
                ]

        if not regex_match(ZFCP_LUN_NUMBER, good_tests, bad_tests):
            self.fail()
Exemplo n.º 8
0
    def gecos_test(self):
        """Test a list of possible Full Name values."""
        # These are valid full names
        good_tests = [
                '',
                'George',
                'George Burdell',
                'George P. Burdell',
                'Ğeorgé P. Burdełl',
                'Burdell, George',
                'g/p/b'
                ]

        # These are invalid full names
        bad_tests = ['George:Burdell']

        if not regex_match(GECOS_VALID, good_tests, bad_tests):
            self.fail()
Exemplo n.º 9
0
    def euiname_test(self):
        good_tests = [
                'eui.ABCDEF0123456789',
                'eui.abcdef0123456789',
                'eui.0123456789ABCDEF'
                ]

        bad_tests = [
                'eui',
                'eui.',
                'eui.2014-',
                'eui.exampleeui789abc'
                'eui.AAAABBBBCCC2345',
                'eui.AAAABBBBCCCCD4567'
                ]

        if not regex_match(ISCSI_EUI_NAME_REGEX, good_tests, bad_tests):
            self.fail()
Exemplo n.º 10
0
    def ipv4_test(self):
        good_tests = [
                '1.2.3.4',
                '0.0.0.0',
                '10.20.30.40',
                '255.255.255.255',
                '249.249.249.249'
                ]

        bad_tests = [
                '1.2.3.',
                '1.2.3',
                '256.2.3.4',
                'a.b.c.d',
                '1.2.3.400'
                '....',
                '1..2.3'
                ]

        ipv4_re = re.compile('^(' + IPV4_PATTERN_WITHOUT_ANCHORS + ')$')
        if not regex_match(ipv4_re, good_tests, bad_tests):
            self.fail()
Exemplo n.º 11
0
    def reponame_test(self):
        good_tests = [
                'reponame',
                'repoName',
                'repo-name',
                'repo.name',
                'repo_name',
                'repo:name',
                'rep0Name',
                '0repoName',
                'repoName0'
                ]

        bad_tests = [
                'repo name',
                'répo name',
                '@repo name',
                '[reponame]'
                ]

        if not regex_match(REPO_NAME_VALID, good_tests, bad_tests):
            self.fail()
Exemplo n.º 12
0
    def initramfs_connection_test(self):
        good_tests = [
            '12:24:56:78:ab:cd',
            '12:24:56:78:AB:cd',
            '12:24:56:78:AB:CD',
        ]

        bad_tests = [
            '',
            '12:24:56:789:ab:cd',
            '12:24:56:78:AB:cg',
            '12:24:56:78:ab:cd:ef',
            '12-24-56-78-ab-cd',
            '12-24-56-78-AB-CD',
            '12:24:56:78-ab-cd',
            '12:24:56:78-AB-CD',
            '12:24:56:78:ab',
            # Infiniband MAC address
            '80:00:02:00:fe:80:00:00:00:00:00:00:f4:52:14:03:00:7b:cb:a3',
        ]

        self.assertTrue(regex_match(NM_MAC_INITRAMFS_CONNECTION, good_tests, bad_tests))
Exemplo n.º 13
0
    def ipv6_test(self):
        good_tests = [
                '0000:0000:0000:0000:0000:0000:0000:0000',
                '0000:0000:0000:0000:0000:0000:1.2.3.4',
                '::a:b:c:d:e:f:1',
                '::a:b:c:d:e:255.255.255.255',
                '1::a:b:c:d:e:f',
                '1::a:b:c:d:255.255.255.255',
                '1:12::a:b:c:d:e',
                '1:12::a:b:c:10.20.30.40',
                '12::a:b:c:d:e',
                '12::a:b:c:10.20.30.40',
                '1:12:123::a:b:c:d',
                '1:12:123::a:b:100.200.250.249',
                '12:123::a:b:c:d',
                '12:123::a:b:100.200.250.249',
                '123::a:b:c:d',
                '123::a:b:100.200.250.249',
                '::a:b:c:d',
                '::a:b:100.200.250.249',
                '1:12:123:1234::a:b:c',
                '1:12:123:1234::a:1.20.30.99',
                '12:123:1234::a:b:c',
                '12:123:1234::a:1.20.30.99',
                '123:1234::a:b:c',
                '123:1234::a:1.20.30.99',
                '1234::a:b:c',
                '1234::a:1.20.30.99',
                '::a:b:c',
                '::a:1.20.30.99',
                '1:12:123:1234:abcd::a:b',
                '1:12:123:1234:abcd::0.0.0.0',
                '12:123:1234:abcd::a:b',
                '12:123:1234:abcd::0.0.0.0',
                '123:1234:abcd::a:b',
                '123:1234:abcd::0.0.0.0',
                '1234:abcd::a:b',
                '1234:abcd::0.0.0.0',
                'abcd::a:b',
                'abcd::0.0.0.0',
                '::a:b',
                '::0.0.0.0',
                '1:12:123:1234:dead:beef::aaaa',
                '12:123:1234:dead:beef::aaaa',
                '123:1234:dead:beef::aaaa',
                '1234:dead:beef::aaaa',
                'dead:beef::aaaa',
                'beef::aaaa',
                '::aaaa',
                '::'
                ]

        bad_tests = [
                # Too many bits
                '0000:0000:0000:0000:0000:0000:0000:0000:0000'
                '0000:0000:0000:0000:0000:0000:0000:1.2.3.4',
                '0000:0000:0000:0000:0000:0000:1.2.3.4.5',
                # Not enough bits
                '0000:0000:0000:0000:0000:0000:0000',
                '0000:0000:0000:0000:0000:1.2.3.4',
                # zero-length contractions
                '0000::0000:0000:0000:0000:0000:1.2.3.4',
                '0000:0000::0000:0000:0000:0000:1.2.3.4',
                '0000:0000:0000::0000:0000:0000:1.2.3.4',
                '0000:0000:0000:0000::0000:0000:1.2.3.4',
                '0000:0000:0000:0000:0000::0000:1.2.3.4',
                '0000:0000:0000:0000:0000:0000::1.2.3.4',
                '123::4567:89:a:bcde:f0f0:aaaa:8',
                '123:4567::89:a:bcde:f0f0:aaaa:8',
                '123:4567:89::a:bcde:f0f0:aaaa:8',
                '123:4567:89:a:bcde::f0f0:aaaa:8',
                '123:4567:89:a:bcde:f0f0::aaaa:8',
                '123:4567:89:a:bcde:f0f0:aaaa::8',
                # too many contractions
                'a::b::c',
                '::a::b',
                'a::b::',
                # invalid numbers
                '00000::0000',
                'defg::',
                '12345::abcd',
                'ffff::0x1e'
                ]

        ipv6_re = re.compile('^(' + IPV6_PATTERN_WITHOUT_ANCHORS + ')$')
        if not regex_match(ipv6_re, good_tests, bad_tests):
            self.fail()
Exemplo n.º 14
0
    def ipv6_test(self):
        good_tests = [
                '0000:0000:0000:0000:0000:0000:0000:0000',
                '0000:0000:0000:0000:0000:0000:1.2.3.4',
                '::a:b:c:d:e:f:1',
                '::a:b:c:d:e:255.255.255.255',
                '1::a:b:c:d:e:f',
                '1::a:b:c:d:255.255.255.255',
                '1:12::a:b:c:d:e',
                '1:12::a:b:c:10.20.30.40',
                '12::a:b:c:d:e',
                '12::a:b:c:10.20.30.40',
                '1:12:123::a:b:c:d',
                '1:12:123::a:b:100.200.250.249',
                '12:123::a:b:c:d',
                '12:123::a:b:100.200.250.249',
                '123::a:b:c:d',
                '123::a:b:100.200.250.249',
                '::a:b:c:d',
                '::a:b:100.200.250.249',
                '1:12:123:1234::a:b:c',
                '1:12:123:1234::a:1.20.30.99',
                '12:123:1234::a:b:c',
                '12:123:1234::a:1.20.30.99',
                '123:1234::a:b:c',
                '123:1234::a:1.20.30.99',
                '1234::a:b:c',
                '1234::a:1.20.30.99',
                '::a:b:c',
                '::a:1.20.30.99',
                '1:12:123:1234:abcd::a:b',
                '1:12:123:1234:abcd::0.0.0.0',
                '12:123:1234:abcd::a:b',
                '12:123:1234:abcd::0.0.0.0',
                '123:1234:abcd::a:b',
                '123:1234:abcd::0.0.0.0',
                '1234:abcd::a:b',
                '1234:abcd::0.0.0.0',
                'abcd::a:b',
                'abcd::0.0.0.0',
                '::a:b',
                '::0.0.0.0',
                '1:12:123:1234:dead:beef::aaaa',
                '12:123:1234:dead:beef::aaaa',
                '123:1234:dead:beef::aaaa',
                '1234:dead:beef::aaaa',
                'dead:beef::aaaa',
                'beef::aaaa',
                '::aaaa',
                '::'
                ]

        bad_tests = [
                # Too many bits
                '0000:0000:0000:0000:0000:0000:0000:0000:0000'
                '0000:0000:0000:0000:0000:0000:0000:1.2.3.4',
                '0000:0000:0000:0000:0000:0000:1.2.3.4.5',
                # Not enough bits
                '0000:0000:0000:0000:0000:0000:0000',
                '0000:0000:0000:0000:0000:1.2.3.4',
                # zero-length contractions
                '0000::0000:0000:0000:0000:0000:1.2.3.4',
                '0000:0000::0000:0000:0000:0000:1.2.3.4',
                '0000:0000:0000::0000:0000:0000:1.2.3.4',
                '0000:0000:0000:0000::0000:0000:1.2.3.4',
                '0000:0000:0000:0000:0000::0000:1.2.3.4',
                '0000:0000:0000:0000:0000:0000::1.2.3.4',
                '123::4567:89:a:bcde:f0f0:aaaa:8',
                '123:4567::89:a:bcde:f0f0:aaaa:8',
                '123:4567:89::a:bcde:f0f0:aaaa:8',
                '123:4567:89:a:bcde::f0f0:aaaa:8',
                '123:4567:89:a:bcde:f0f0::aaaa:8',
                '123:4567:89:a:bcde:f0f0:aaaa::8',
                # too many contractions
                'a::b::c',
                '::a::b',
                'a::b::',
                # invalid numbers
                '00000::0000',
                'defg::',
                '12345::abcd',
                'ffff::0x1e'
                ]

        ipv6_re = re.compile('^(' + IPV6_PATTERN_WITHOUT_ANCHORS + ')$')
        self.assertTrue(regex_match(ipv6_re, good_tests, bad_tests))