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))
def test_empty_host(self): self.assertFalse(HostList(['*']).match(''))
def test_empty_list(self): self.assertFalse(HostList([]).match('myhost'))
def test_match_all(self): self.assertTrue(HostList(['*']).match('myhost'))
def test_no_match(self): self.assertFalse(HostList(['onehost', 'somehost']).match('myhost'))
def test_negative_match_over_positive_match(self): self.assertFalse(HostList(['*host', '!*host']).match('myhost'))
def test_positive_match_pattern(self): self.assertTrue(HostList(['onehost', '*host']).match('myhost'))