17 lines
849 B
Python
17 lines
849 B
Python
"""One test for the client profile template (templates/client.ovpn.j2), tcp and udp."""
|
|||
|
|
import pytest
|
||
|
|
|
||
|
|
from services.generator import env
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("protocol", ["tcp", "udp"])
|
||
|
|
def test_client_template(protocol):
|
||
|
|
text = env.get_template("client.ovpn.j2").render(
|
||
|
|
protocol=protocol, remote_ip="203.0.113.1", port=1194, ca_cert="CA",
|
||
|
|
client_cert="CERT", client_key="KEY", tls_auth="TA", tun_mtu=None)
|
||
|
|
lines = [x.strip() for x in text.splitlines()]
|
||
|
|
assert f"proto {protocol}" in lines and "client" in lines
|
||
|
|
# directives that OpenVPN 2.7 rejects or that are redundant/harmful on user devices
|
||
|
|
for gone in ("windows-driver", "tls-client", "#tls-client", "user", "group"):
|
||
|
|
assert not any(x.split(" ")[0] == gone for x in lines)
|
||
|
|
assert ("explicit-exit-notify" in lines) == (protocol == "udp")
|