From 44228839178f0354a4e065f6ef33c0c79b0236f1 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 3 Nov 2026 12:39:18 +0100 Subject: Refuse to start on a listen statement that does not parse --- tests/integration/test_config.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index 1a84fa7..2f6bdc4 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -1,7 +1,9 @@ """Settings the tracker has to accept, and still work with. -An unrecognised key makes opentracker refuse to start, so a test that it -comes up at all is a test that the key was understood. +An unrecognised key only warns, so coming up proves nothing on its own and a +test that cares has to look at what the tracker said. A key that is +recognised but cannot be parsed is another matter, and for the listen +statements it stops the tracker. """ import unittest @@ -14,6 +16,7 @@ class TcpWorkers(TrackerTestCase): def test_the_tracker_serves_with_tcp_workers_asked_for(self): self.assertEqual(self.tracker.announce(self.hash_for("tcpworkers"))[b"complete"], 1) + self.assertNotIn("Unhandled line", self.tracker.output()) class WorkersOnAListenStatement(unittest.TestCase): @@ -27,3 +30,22 @@ class WorkersOnAListenStatement(unittest.TestCase): self.assertEqual(complaints, [], "the tracker reported:\n" + "\n".join(complaints)) finally: tracker._cleanup() + + +class AListenLineThatDoesNotParse(unittest.TestCase): + """Warning and carrying on left a tracker that had been told where to + listen coming up on its default instead, which is every interface.""" + + def refuses(self, line): + with self.assertRaises(AssertionError) as caught: + Tracker(line) + return str(caught.exception) + + def test_an_address_that_is_not_one_stops_the_tracker(self): + self.assertIn("want an address", self.refuses("listen.tcp 10.0.0.300:7999\n")) + + def test_so_does_a_port_out_of_range(self): + self.assertIn("want an address", self.refuses("listen.udp 127.0.0.1:99999\n")) + + def test_so_does_an_option_it_does_not_know(self): + self.assertIn("want an address", self.refuses("listen.tcp 127.0.0.1:7999 wokers=2\n")) -- cgit v1.3