blob: bbfd521ec9240847df408a2238c9bd77d780b72e (
plain)
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
|
from cloudinit.config.cc_syslog import (
parse_remotes_line, SyslogRemotesLine, remotes_to_rsyslog_cfg)
from cloudinit import util
from .. import helpers as t_help
class TestParseRemotesLine(t_help.TestCase):
def test_valid_port(self):
r = parse_remotes_line("foo:9")
self.assertEqual(9, r.port)
def test_invalid_port(self):
with self.assertRaises(ValueError):
parse_remotes_line("*.* foo:abc")
def test_valid_ipv6(self):
r = parse_remotes_line("*.* [::1]")
self.assertEqual("*.* [::1]", str(r))
def test_valid_ipv6_with_port(self):
r = parse_remotes_line("*.* [::1]:100")
self.assertEqual(r.port, 100)
self.assertEqual(r.addr, "::1")
self.assertEqual("*.* [::1]:100", str(r))
def test_invalid_multiple_colon(self):
with self.assertRaises(ValueError):
parse_remotes_line("*.* ::1:100")
def test_name_in_string(self):
r = parse_remotes_line("syslog.host", name="foobar")
self.assertEqual("*.* syslog.host # foobar", str(r))
|