This commit is contained in:
Jonas Bengtsson
2026-09-19 09:40:24 +02:00
parent ee4800993d
commit 19bccce083
13 changed files with 435 additions and 43 deletions
+31
View File
@@ -180,6 +180,37 @@ def test_listener_management_and_preview(admin_client):
assert delete.status_code == 204
def test_listener_update_and_preview(admin_client):
listener_id = admin_client.post(
"/api/v1/broker/listeners",
json={"name": "Production MQTT", "port": 1883, "protocol": "mqtt"},
).json()["id"]
updated = admin_client.put(
f"/api/v1/broker/listeners/{listener_id}",
json={
"name": "Production MQTT",
"port": 1884,
"bind_address": "127.0.0.1",
"protocol": "websockets",
"allow_anonymous": True,
},
)
assert updated.status_code == 200, updated.text
body = updated.json()
assert body["port"] == 1884
assert body["bind_address"] == "127.0.0.1"
assert body["protocol"] == "websockets"
assert body["allow_anonymous"] is True
config_text = admin_client.get("/api/v1/broker/config/preview").json()[
"config_text"
]
assert "listener 1884 127.0.0.1" in config_text
assert "protocol websockets" in config_text
assert "listener_allow_anonymous true" in config_text
def test_audit_events_recorded(admin_client, db_session):
from sqlalchemy import select
+6 -3
View File
@@ -46,9 +46,12 @@ def test_generate_includes_global_settings(session):
assert "max_packet_size 2000000" in result.config_text
def test_generate_refuses_without_listeners(session):
with pytest.raises(ValueError, match="no enabled listeners"):
generate_config(session)
def test_generate_with_empty_model_warns_instead_of_raising(session):
"""Fresh-platform state: preview must work, not 500 (config page fix)."""
result = generate_config(session)
assert "global_plugin /usr/lib/mosquitto_dynamic_security.so" in result.config_text
assert "persistence true" in result.config_text
assert any("No enabled listeners" in w for w in result.warnings)
def test_disabled_listeners_are_omitted(session):