Ejemplo n.º 1
0
    def test_append_hostlist(self):
        expected = textwrap.dedent('''\
        Host myhost.com
            PreferredAuthentications publickey
            User myuser
            ForwardAgent no

        Host myhost.net myhost.org
            User bob
            Port 23
        ''')

        config = textwrap.dedent('''\
        Host myhost.com
            PreferredAuthentications publickey
            User myuser
            ForwardAgent no''')

        ssh_config = loads(config)
        ssh_config.append(
            HostBlock(
                HostList(["myhost.net", "myhost.org"]),
                KeywordSet([
                    ("User", "bob"),
                    ("Port", "23"),
                ]),
            ))
        self.assertEqual(expected, dumps(ssh_config))
Ejemplo n.º 2
0
 def test_empty_host(self):
     self.assertFalse(HostList(['*']).match(''))
Ejemplo n.º 3
0
 def test_empty_list(self):
     self.assertFalse(HostList([]).match('myhost'))
Ejemplo n.º 4
0
 def test_match_all(self):
     self.assertTrue(HostList(['*']).match('myhost'))
Ejemplo n.º 5
0
 def test_no_match(self):
     self.assertFalse(HostList(['onehost', 'somehost']).match('myhost'))
Ejemplo n.º 6
0
 def test_negative_match_over_positive_match(self):
     self.assertFalse(HostList(['*host', '!*host']).match('myhost'))
Ejemplo n.º 7
0
 def test_positive_match_pattern(self):
     self.assertTrue(HostList(['onehost', '*host']).match('myhost'))