From 4169545c28de89c4f13542bfc691316159ce0b63 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 26 Jun 2017 17:44:53 +0100 Subject: [PATCH 1/2] server-restart: add failing test "wormhole-server restart" was broken by the addition of --disallow-list, because the Click parser wasn't update to include the argument. This test should exercise that a basic no-argv invocation of both "start" and "restart" can at least build the Service object successfully. refs #151 --- src/wormhole/test/test_cli.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/wormhole/test/test_cli.py b/src/wormhole/test/test_cli.py index 70a16ec..2cabb37 100644 --- a/src/wormhole/test/test_cli.py +++ b/src/wormhole/test/test_cli.py @@ -1195,3 +1195,18 @@ class Server(unittest.TestCase): plugin = MyPlugin(cfg) relay = plugin.makeService(None) self.assertEqual(False, relay._allow_list) + + @mock.patch("wormhole.server.cmd_server.start_server") + def test_start_no_args(self, fake_start_server): + result = self.runner.invoke(server, ['start']) + self.assertEqual(0, result.exit_code) + cfg = fake_start_server.mock_calls[0][1][0] + MyPlugin(cfg).makeService(None) + + @mock.patch("wormhole.server.cmd_server.restart_server") + def test_restart_no_args(self, fake_start_reserver): + result = self.runner.invoke(server, ['restart']) + self.assertEqual(0, result.exit_code) + cfg = fake_start_reserver.mock_calls[0][1][0] + MyPlugin(cfg).makeService(None) + From 900c3f8c29704ec5d96a3f3da914abd377d2a599 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 26 Jun 2017 14:13:38 +0100 Subject: [PATCH 2/2] server: make 'restart' accept --disallow-list too I should really move all the start/restart common arguments into a separate place, to make it easier to avoid this problem in the future. --- src/wormhole/server/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wormhole/server/cli.py b/src/wormhole/server/cli.py index 3377af3..b86984f 100644 --- a/src/wormhole/server/cli.py +++ b/src/wormhole/server/cli.py @@ -98,9 +98,13 @@ def start(cfg, signal_error, no_daemon, blur_usage, advertise_version, "--signal-error", is_flag=True, help="force all clients to fail with a message", ) +@click.option( + "--disallow-list", is_flag=True, + help="never send list of allocated nameplates", +) @click.pass_obj def restart(cfg, signal_error, no_daemon, blur_usage, advertise_version, - transit, rendezvous): + transit, rendezvous, disallow_list): """ Re-start a relay server """ @@ -111,6 +115,7 @@ def restart(cfg, signal_error, no_daemon, blur_usage, advertise_version, cfg.transit = str(transit) cfg.rendezvous = str(rendezvous) cfg.signal_error = signal_error + cfg.allow_list = not disallow_list restart_server(cfg)