Verified Commit 1fc4012a authored by Štěpán Henek's avatar Štěpán Henek 🐻 Committed by Martin Matějek
Browse files

Fix 'proto' option in client config

parent da9c8b16
...@@ -512,6 +512,9 @@ verb 3 ...@@ -512,6 +512,9 @@ verb 3
tls_auth_section = "" tls_auth_section = ""
compress = "compress %s" % compress if compress else "" compress = "compress %s" % compress if compress else ""
# convert proto
proto = proto[:3] + ("-client" if "server" in proto else "")
return self.CONFIG_TEMPLATE % dict( return self.CONFIG_TEMPLATE % dict(
dev=dev, dev=dev,
proto=proto.replace("server", "client"), proto=proto.replace("server", "client"),
......
...@@ -968,22 +968,22 @@ def test_get_client_config_mock(infrastructure, hostname): ...@@ -968,22 +968,22 @@ def test_get_client_config_mock(infrastructure, hostname):
check_hostname(hostname) check_hostname(hostname)
AVAILABLE_PROTOCOLS = [ PROTOCOLS_MAP = [
"tcp", ("tcp", "tcp"),
"udp", ("udp", "udp"),
"tcp-server", ("tcp-server", "tcp-client"),
"tcp4", ("tcp4", "tcp"),
"udp4", ("udp4", "udp"),
"tcp4-server", ("tcp4-server", "tcp-client"),
"tcp6", ("tcp6", "tcp"),
"udp6", ("udp6", "udp"),
"tcp6-server", ("tcp6-server", "tcp-client"),
] ]
@pytest.mark.only_backends(["openwrt"]) @pytest.mark.only_backends(["openwrt"])
@pytest.mark.parametrize("hostname", ["", "10.30.50.70"]) @pytest.mark.parametrize("hostname", ["", "10.30.50.70"])
@pytest.mark.parametrize("proto", AVAILABLE_PROTOCOLS) @pytest.mark.parametrize("proto,client_proto", PROTOCOLS_MAP)
def test_get_client_config_openwrt( def test_get_client_config_openwrt(
ready_certs, ready_certs,
uci_configs_init, uci_configs_init,
...@@ -992,6 +992,7 @@ def test_get_client_config_openwrt( ...@@ -992,6 +992,7 @@ def test_get_client_config_openwrt(
hostname, hostname,
file_root_init, file_root_init,
proto, proto,
client_proto,
): ):
uci = get_uci_module(infrastructure.name) uci = get_uci_module(infrastructure.name)
...@@ -1035,10 +1036,7 @@ def test_get_client_config_openwrt( ...@@ -1035,10 +1036,7 @@ def test_get_client_config_openwrt(
if hostname: if hostname:
assert hostname in res["data"]["config"] assert hostname in res["data"]["config"]
assert "dev tun_turris" in res["data"]["config"] assert "dev tun_turris" in res["data"]["config"]
if proto in ["tcp-server", "tcp4-server", "tcp6-server"]: assert f"proto {client_proto}\n" in res["data"]["config"]
assert "proto %s" % proto.replace("server", "client") in res["data"]["config"]
else:
assert "proto %s" % proto in res["data"]["config"]
assert "<ca>" in res["data"]["config"] assert "<ca>" in res["data"]["config"]
assert "</ca>" in res["data"]["config"] assert "</ca>" in res["data"]["config"]
assert "<cert>" in res["data"]["config"] assert "<cert>" in res["data"]["config"]
...@@ -1059,9 +1057,9 @@ def test_get_client_config_openwrt( ...@@ -1059,9 +1057,9 @@ def test_get_client_config_openwrt(
@pytest.mark.only_backends(["openwrt"]) @pytest.mark.only_backends(["openwrt"])
@pytest.mark.parametrize("proto", AVAILABLE_PROTOCOLS) @pytest.mark.parametrize("proto,client_proto", PROTOCOLS_MAP)
def test_available_protocols( def test_available_protocols(
uci_configs_init, init_script_result, infrastructure, proto uci_configs_init, init_script_result, infrastructure, proto, client_proto,
): ):
uci = get_uci_module(infrastructure.name) uci = get_uci_module(infrastructure.name)
with uci.UciBackend(UCI_CONFIG_DIR_PATH) as backend: with uci.UciBackend(UCI_CONFIG_DIR_PATH) as backend:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment