From 6d4261e3f9de17720c07239d0370f14a6fed36a9 Mon Sep 17 00:00:00 2001 From: Scott Kuhl Date: Sat, 26 Dec 2020 15:25:33 -0500 Subject: Refactor automatic method selection. Add an "is_supported()" function to the different methods so that each method can include whatever logic they wish to indicate if they are supported on a particular machine. Previously, methods/__init__.py contained all of the logic for selecting individual methods. Now, it iterates through a list of possible options and stops on the first method that it finds that is_supported(). Currently, the decision is made based on the presence of programs in the PATH. In the future, things such as the platform sshuttle is running on could be considered. --- tests/client/test_firewall.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/client/test_firewall.py b/tests/client/test_firewall.py index d19839b..71f1940 100644 --- a/tests/client/test_firewall.py +++ b/tests/client/test_firewall.py @@ -116,6 +116,8 @@ def test_main(mock_get_method, mock_setup_daemon, mock_rewrite_etc_hosts): assert mock_setup_daemon.mock_calls == [call()] assert mock_get_method.mock_calls == [ call('not_auto'), + call().is_supported(), + call().is_supported().__bool__(), call().setup_firewall( 1024, 1026, [(AF_INET6, u'2404:6800:4004:80c::33')], -- cgit v1.2.3