|
18 | 18 |
|
19 | 19 | from base_vyostest_shim import VyOSUnitTestSHIM
|
20 | 20 |
|
| 21 | +from vyos.configsession import ConfigSessionError |
21 | 22 | from vyos.utils.file import read_file
|
22 | 23 | from vyos.utils.process import cmd
|
23 | 24 | from vyos.utils.process import process_named_running
|
|
28 | 29 |
|
29 | 30 | base_path = ['system', 'syslog']
|
30 | 31 |
|
| 32 | +dummy_interface = 'dum372874' |
| 33 | + |
31 | 34 | def get_config(string=''):
|
32 | 35 | """
|
33 | 36 | Retrieve current "running configuration" from FRR
|
@@ -127,6 +130,7 @@ def test_basic(self):
|
127 | 130 | self.assertNotIn('module(load="immark"', config)
|
128 | 131 |
|
129 | 132 | def test_remote(self):
|
| 133 | + dummy_if_path = ['interfaces', 'dummy', dummy_interface] |
130 | 134 | rhosts = {
|
131 | 135 | '169.254.0.1': {
|
132 | 136 | 'facility': {'auth' : {'level': 'info'}},
|
@@ -175,6 +179,15 @@ def test_remote(self):
|
175 | 179 | protocol = remote_options['protocol']
|
176 | 180 | self.cli_set(remote_base + ['protocol'], value=protocol)
|
177 | 181 |
|
| 182 | + if 'source_address' in remote_options: |
| 183 | + source_address = remote_options['source_address'] |
| 184 | + self.cli_set(remote_base + ['source-address', source_address]) |
| 185 | + |
| 186 | + # check validate() - source address does not exist |
| 187 | + with self.assertRaises(ConfigSessionError): |
| 188 | + self.cli_commit() |
| 189 | + self.cli_set(dummy_if_path + ['address', f'{source_address}/32']) |
| 190 | + |
178 | 191 | self.cli_commit()
|
179 | 192 |
|
180 | 193 | config = read_file(RSYSLOG_CONF)
|
@@ -217,6 +230,9 @@ def test_remote(self):
|
217 | 230 | else:
|
218 | 231 | self.assertIn( ' TCP_Framing="traditional"', config)
|
219 | 232 |
|
| 233 | + # cleanup dummy interface |
| 234 | + self.cli_delete(dummy_if_path) |
| 235 | + |
220 | 236 | def test_vrf_source_address(self):
|
221 | 237 | rhosts = {
|
222 | 238 | '169.254.0.10': { },
|
@@ -258,7 +274,6 @@ def test_vrf_source_address(self):
|
258 | 274 | value=vrf)
|
259 | 275 |
|
260 | 276 | self.cli_commit()
|
261 |
| - config = read_file(RSYSLOG_CONF) |
262 | 277 |
|
263 | 278 | for remote, remote_options in rhosts.items():
|
264 | 279 | config = get_config(f'# Remote syslog to {remote}')
|
|
0 commit comments