mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Starting a Controller script writes its env file every time and rejects unknown parameters
The upgrade service reads BRANCH from /tmp/wrolpi-upgrade.env, which upgrade.sh removes when it finishes. The
Controller wrote that file only when a request had parameters, so starting an upgrade without a branch (the simple UI
sends no body when the field is empty) left the service unable to start, while the API answered success. A request
like {"branch": "master"} was accepted with the key ignored, the same way.
Now the env file is always written, and a missing branch is the current one, as upgrade.sh chooses; a file left by an
interrupted run no longer chooses it. Unknown parameters and unknown request keys are errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
eb82489426
commit
3e54731534
4 changed files with 74 additions and 8 deletions
|
|
@ -101,6 +101,16 @@ class TestScriptsStartEndpoint:
|
|||
assert response.status_code == 400
|
||||
assert "already running" in response.json()["detail"].lower()
|
||||
|
||||
def test_scripts_start_rejects_unknown_body_keys(self, test_client):
|
||||
"""Parameters go in `params`; a body like {"branch": ...} is an error, not an upgrade of some other
|
||||
branch."""
|
||||
with mock.patch("controller.lib.scripts.is_docker_mode", return_value=False), \
|
||||
mock.patch("controller.lib.scripts.get_script_status", return_value={"running": False}), \
|
||||
mock.patch("subprocess.Popen") as popen:
|
||||
response = test_client.post("/api/scripts/upgrade/start", json={"branch": "master"})
|
||||
assert response.status_code == 422
|
||||
popen.assert_not_called()
|
||||
|
||||
|
||||
class TestScriptsOutputEndpoint:
|
||||
"""Tests for /api/scripts/{name}/output endpoint."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue