feat: deploy StreamScope source bundle with MTR and rollback

This commit is contained in:
sascha 2026-08-08 18:23:17 +02:00
parent a364854586
commit dc349bc23d

View file

@ -324,16 +324,16 @@ def test_hetzner_token_refreshes_vault_cache_when_missing(monkeypatch):
assert calls[1] == "reload" assert calls[1] == "reload"
def test_speedtest_deploy_requires_strong_password_and_uses_git_compose(monkeypatch): def test_speedtest_deploy_requires_strong_secrets_and_uses_full_git_app(monkeypatch):
calls = [] calls = []
async def fake_fetch(repo, path): async def fake_fetch(repo, path):
calls.append(("fetch", repo, path)) calls.append(("fetch", repo, path))
return "services:\n speedtest:\n image: ghcr.io/librespeed/speedtest:latest\n" return f"content:{path}"
def fake_deploy(compose, password): def fake_deploy(files, password, session_secret):
calls.append(("deploy", compose, password)) calls.append(("deploy", files, password, session_secret))
return {"status": "deployed", "health": "ok"} return {"status": "deployed", "health": "ok", "application": "streamscope"}
monkeypatch.setattr(app, "_fetch_forgejo_text", fake_fetch) monkeypatch.setattr(app, "_fetch_forgejo_text", fake_fetch)
monkeypatch.setattr(app, "_deploy_speedtest_compose", fake_deploy) monkeypatch.setattr(app, "_deploy_speedtest_compose", fake_deploy)
@ -341,18 +341,24 @@ def test_speedtest_deploy_requires_strong_password_and_uses_git_compose(monkeypa
weak = client.post( weak = client.post(
"/vps/speedtest/deploy", "/vps/speedtest/deploy",
headers={"Authorization": "Bearer test-token"}, headers={"Authorization": "Bearer test-token"},
json={"stats_password": "short"}, json={"stats_password": "short", "session_secret": "long-session-secret-with-entropy"},
) )
response = client.post( response = client.post(
"/vps/speedtest/deploy", "/vps/speedtest/deploy",
headers={"Authorization": "Bearer test-token"}, headers={"Authorization": "Bearer test-token"},
json={"stats_password": "correct-horse-battery-staple"}, json={
"stats_password": "correct-horse-battery-staple",
"session_secret": "streamscope-session-secret-with-entropy",
},
) )
assert weak.status_code == 400 assert weak.status_code == 400
assert response.status_code == 200 assert response.status_code == 200
assert response.json()["status"] == "deployed" assert response.json()["application"] == "streamscope"
assert calls == [ assert ("fetch", "sascha/speedtest", "compose.yaml") in calls
("fetch", "sascha/speedtest", "compose.yaml"), assert ("fetch", "sascha/speedtest", "streamscope/static/assets/app.js") in calls
("deploy", "services:\n speedtest:\n image: ghcr.io/librespeed/speedtest:latest\n", "correct-horse-battery-staple"), deploy = calls[-1]
] assert deploy[0] == "deploy"
assert deploy[1]["compose.yaml"] == "content:compose.yaml"
assert deploy[2] == "correct-horse-battery-staple"
assert deploy[3] == "streamscope-session-secret-with-entropy"