diff --git a/client/gefyra/api/connect.py b/client/gefyra/api/connect.py index ba9fd78a..82b726d8 100644 --- a/client/gefyra/api/connect.py +++ b/client/gefyra/api/connect.py @@ -97,7 +97,7 @@ def connect( # noqa: C901 cargo_endpoint_host=gclient_conf.gefyra_server.split(":")[0], cargo_endpoint_port=gclient_conf.gefyra_server.split(":")[1], cargo_container_name=f"gefyra-cargo-{connection_name}", - wireguard_mtu=gclient_conf.wiregard_mtu or mtu, + wireguard_mtu=gclient_conf.wireguard_mtu or mtu, ) gclient = handle_get_gefyraclient(config, gclient_conf.client_id) diff --git a/client/gefyra/types.py b/client/gefyra/types.py index 4ccfa9b9..bc5bde57 100644 --- a/client/gefyra/types.py +++ b/client/gefyra/types.py @@ -27,7 +27,7 @@ class GefyraClientConfig: ca_crt: str gefyra_server: str registry: Optional[str] - wiregard_mtu: Optional[str] + wireguard_mtu: Optional[str] @property def json(self): @@ -178,7 +178,7 @@ def get_client_config( ca_crt=self.service_account["ca.crt"], gefyra_server=gefyra_server, registry=registry, - wiregard_mtu=str(wireguard_mtu), + wireguard_mtu=str(wireguard_mtu), ) else: raise ClientConfigurationError( diff --git a/client/tests/unit/test_client_file_manipulations.py b/client/tests/unit/test_client_file_manipulations.py new file mode 100644 index 00000000..ce8e576f --- /dev/null +++ b/client/tests/unit/test_client_file_manipulations.py @@ -0,0 +1,94 @@ +import json +from gefyra.api.clients import write_client_file +from gefyra.types import GefyraClient +from pytest_kubernetes.providers import AClusterManager + + + +def test_a_write_client_file(operator: AClusterManager): + k3d = operator + from gefyra.api.clients import add_clients + + add_clients("client-a", kubeconfig=operator.kubeconfig) + client_a: GefyraClient = k3d.kubectl( + ["-n", "gefyra", "get", "gefyraclients.gefyra.dev", "client-a"] + ) + + assert client_a["state"] is not None + + k3d.wait( + "gefyraclients.gefyra.dev/client-a", + "jsonpath=.state=WAITING", + namespace="gefyra", + timeout=20, + ) + + # connect client + k3d.kubectl( + [ + "-n", + "gefyra", + "patch", + "gefyraclient", + "client-a", + "--type='merge'", + "--patch='" + + json.dumps({"providerParameter": {"subnet": "192.168.101.0/24"}}) + + "'", + ] + ) + + k3d.wait( + "gefyraclients.gefyra.dev/client-a", + "jsonpath=.state=ACTIVE", + namespace="gefyra", + timeout=20, + ) + + client_file_str = write_client_file( + client_id="client-a", + host="localhost", + port="31820", + kubeconfig=k3d.kubeconfig, + kubecontext=k3d.context + ) + + client_file_json = json.loads(client_file_str) + + print(client_file_json) + + assert client_file_json["wireguard_mtu"] == "1340" + + +def test_a_write_client_file_with_registry_and_mtu(operator: AClusterManager): + k3d = operator + + client_a: GefyraClient = k3d.kubectl( + ["-n", "gefyra", "get", "gefyraclients.gefyra.dev", "client-a"] + ) + + assert client_a["state"] is not None + + k3d.wait( + "gefyraclients.gefyra.dev/client-a", + "jsonpath=.state=ACTIVE", + namespace="gefyra", + timeout=20, + ) + + client_file_str = write_client_file( + client_id="client-a", + host="localhost", + port="31820", + kubeconfig=k3d.kubeconfig, + kubecontext=k3d.context, + registry="kuchen.io/gefyra", + wireguard_mtu=570 + ) + + client_file_json = json.loads(client_file_str) + + print(client_file_json) + + assert client_file_json["wireguard_mtu"] == "570" + assert client_file_json["registry"] == "kuchen.io/gefyra" \ No newline at end of file