Restore MQTT bridge card metadata
This commit is contained in:
parent
bfeda9114e
commit
6b80ff507b
|
|
@ -10,6 +10,26 @@ SPEC.loader.exec_module(provider)
|
||||||
|
|
||||||
|
|
||||||
class ReverseTunnelBootstrapTest(unittest.TestCase):
|
class ReverseTunnelBootstrapTest(unittest.TestCase):
|
||||||
|
def test_mqtt_bridge_card_keeps_remote_port_without_network_probe(self):
|
||||||
|
unit = {
|
||||||
|
"active": True,
|
||||||
|
"active_state": "active",
|
||||||
|
"result": "success",
|
||||||
|
"exec_main_status": "0",
|
||||||
|
"raw_error": "",
|
||||||
|
}
|
||||||
|
context = {
|
||||||
|
"read_env_file": lambda _path: {"ENABLE_BRIDGE": "1", "REMOTE_HOST": "mqtt.example", "REMOTE_PORT": "8883"},
|
||||||
|
"file_exists": lambda _path: True,
|
||||||
|
"any_exists": lambda _paths: True,
|
||||||
|
"systemd_unit": lambda _name: dict(unit),
|
||||||
|
}
|
||||||
|
|
||||||
|
card = provider.mqtt_bridge_card(context)
|
||||||
|
|
||||||
|
self.assertTrue(card["active"])
|
||||||
|
self.assertIn({"label": "Remote port", "value": "8883"}, card["details"])
|
||||||
|
|
||||||
def test_bootstrap_generation_never_calls_external_network(self):
|
def test_bootstrap_generation_never_calls_external_network(self):
|
||||||
files = {
|
files = {
|
||||||
"/etc/hostname": "g-box-12345678\n",
|
"/etc/hostname": "g-box-12345678\n",
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,7 @@ def mqtt_bridge_card(ctx):
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
remote_host = str(env.get("REMOTE_HOST", "")).strip()
|
remote_host = str(env.get("REMOTE_HOST", "")).strip()
|
||||||
|
remote_port = str(env.get("REMOTE_PORT", "1883")).strip() or "1883"
|
||||||
mosquitto = ctx["systemd_unit"]("mosquitto.service")
|
mosquitto = ctx["systemd_unit"]("mosquitto.service")
|
||||||
health_timer = ctx["systemd_unit"]("iomatex-mqtt-health.timer")
|
health_timer = ctx["systemd_unit"]("iomatex-mqtt-health.timer")
|
||||||
active = bool(enabled and remote_host and bridge_conf_exists and mosquitto["active"])
|
active = bool(enabled and remote_host and bridge_conf_exists and mosquitto["active"])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue