🚧 WIP
This commit is contained in:
@@ -130,6 +130,70 @@ def test_client_id_binding(admin_client):
|
||||
assert refused.status_code == 400
|
||||
|
||||
|
||||
# --- System: broker restart + restart-required flag (spec 28, 29) -------------
|
||||
|
||||
|
||||
def test_deploy_sets_restart_required_on_listener_change(admin_client):
|
||||
"""Adding a listener definition vs the bootstrap config must flag a
|
||||
pending restart (reload cannot add listeners, spec section 28)."""
|
||||
# No deployed revision yet -> compared against the bootstrap config
|
||||
# (listener 1883 0.0.0.0). A listener on 8883 differs from that.
|
||||
admin_client.post(
|
||||
"/api/v1/broker/listeners",
|
||||
json={"name": "New TLS", "port": 8883, "protocol": "mqtt"},
|
||||
)
|
||||
deploy = admin_client.post(
|
||||
"/api/v1/broker/config/deploy", json={"comment": "listener added"}
|
||||
)
|
||||
assert deploy.status_code == 200
|
||||
body = deploy.json()
|
||||
assert body["restart_required"] is True
|
||||
|
||||
# The status endpoint reflects the same flag (drives the glow).
|
||||
status = admin_client.get("/api/v1/system/status").json()
|
||||
assert status["restart_required"] is True
|
||||
assert status["broker_alive"] is True
|
||||
|
||||
|
||||
def test_deploy_without_listener_change_needs_no_restart(admin_client):
|
||||
"""Deploying a config whose listener lines match the previous deployed
|
||||
revision must NOT set the flag (everything else is reload-safe)."""
|
||||
admin_client.post(
|
||||
"/api/v1/broker/listeners",
|
||||
json={"name": "Baseline", "port": 1883, "protocol": "mqtt"},
|
||||
)
|
||||
first = admin_client.post(
|
||||
"/api/v1/broker/config/deploy", json={"comment": "baseline"}
|
||||
).json()
|
||||
# 1883 matches the bootstrap signature on the FIRST deploy; the flag
|
||||
# may or may not be set then. The SECOND deploy (identical listener
|
||||
# lines) must clear it.
|
||||
second = admin_client.post(
|
||||
"/api/v1/broker/config/deploy", json={"comment": "no change"}
|
||||
).json()
|
||||
assert second["restart_required"] is False
|
||||
|
||||
|
||||
def test_restart_clears_the_flag(admin_client):
|
||||
admin_client.post(
|
||||
"/api/v1/broker/config/deploy", json={"comment": "flag set"}
|
||||
)
|
||||
restarted = admin_client.post("/api/v1/system/broker/restart")
|
||||
assert restarted.status_code == 200
|
||||
assert restarted.json()["status"] == "restarting"
|
||||
|
||||
status = admin_client.get("/api/v1/system/status").json()
|
||||
assert status["restart_required"] is False
|
||||
|
||||
|
||||
def test_system_endpoints_rbac(auditor_client):
|
||||
"""Status is read-only (auditor may read); restart is privileged."""
|
||||
assert auditor_client.get("/api/v1/system/status").status_code == 200
|
||||
assert (
|
||||
auditor_client.post("/api/v1/system/broker/restart").status_code == 403
|
||||
)
|
||||
|
||||
|
||||
def test_role_acl_lifecycle(admin_client):
|
||||
admin_client.post("/api/v1/mqtt/roles", json={"rolename": "telemetry"})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user