fix: validate cron expression before writing to crontab

This commit is contained in:
2026-06-18 16:47:56 +02:00
parent 1a8e4e2186
commit 748a3be4b8
3 changed files with 26 additions and 1 deletions
+16
View File
@@ -164,6 +164,22 @@ def test_set_alarm_rejects_custom_command():
assert "command" in str(res.json()["errors"])
def test_set_alarm_rejects_invalid_cron_expression():
"""Invalid cron expressions must be rejected at the API boundary."""
headers = {"X-API-Key": "test-secret"}
mutation = """
mutation {
setAlarm(cronExpression: "definitely not valid") {
id
}
}
"""
res = client.post("/graphql", json={"query": mutation}, headers=headers)
assert res.status_code == 200
assert "errors" in res.json()
assert "Invalid cron expression" in str(res.json()["errors"])
def test_graphql_workflow():
headers = {"X-API-Key": "test-secret"}