[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
3b446b6d24
commit
cc3259d425
3 changed files with 12 additions and 14 deletions
|
|
@ -44,9 +44,7 @@ _REFUSAL_MESSAGES = {
|
|||
"The confirmation is missing or unrecognized. Re-check for the update and "
|
||||
"confirm again before it runs."
|
||||
),
|
||||
"expired_token": (
|
||||
"The confirmation expired. Re-check for the update and confirm again."
|
||||
),
|
||||
"expired_token": ("The confirmation expired. Re-check for the update and confirm again."),
|
||||
"stale_target": (
|
||||
"The available build changed since you confirmed. Re-check for the update "
|
||||
"and confirm the new build before it runs."
|
||||
|
|
@ -284,7 +282,9 @@ async def llama_update(
|
|||
return LlamaUpdateActionResponse(
|
||||
started = False,
|
||||
reason = refuse_reason,
|
||||
message = _REFUSAL_MESSAGES.get(refuse_reason, _REFUSAL_MESSAGES["confirmation_required"]),
|
||||
message = _REFUSAL_MESSAGES.get(
|
||||
refuse_reason, _REFUSAL_MESSAGES["confirmation_required"]
|
||||
),
|
||||
machine = machine,
|
||||
installed_tag = installed_tag,
|
||||
latest_tag = target_tag,
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ def _track_start(monkeypatch):
|
|||
# update_confirm token unit tests
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
|
||||
def test_token_roundtrip_single_use():
|
||||
tok, exp = _uc.mint_confirm_token("b9909")
|
||||
assert isinstance(tok, str) and tok
|
||||
|
|
@ -193,6 +194,7 @@ def test_token_missing_refused():
|
|||
# Handler-level: the swap only runs with an explicit confirmation
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
|
||||
def test_apply_without_confirmation_is_refused_and_never_swaps(monkeypatch):
|
||||
calls = _track_start(monkeypatch)
|
||||
out = asyncio.run(rl.llama_update(request = None, current_subject = "operator"))
|
||||
|
|
@ -210,8 +212,8 @@ def test_apply_with_confirmed_true_proceeds(monkeypatch):
|
|||
body = rl.LlamaUpdateRequest(confirmed = True)
|
||||
out = asyncio.run(rl.llama_update(request = body, current_subject = "operator"))
|
||||
assert out.started is True
|
||||
assert out.machine.hostname # which machine
|
||||
assert out.latest_tag == "b9909" # which version
|
||||
assert out.machine.hostname # which machine
|
||||
assert out.latest_tag == "b9909" # which version
|
||||
assert calls["n"] == 1
|
||||
|
||||
|
||||
|
|
@ -273,9 +275,7 @@ def test_confirm_endpoint_up_to_date_offers_no_token(monkeypatch):
|
|||
|
||||
|
||||
def test_status_reports_machine():
|
||||
out = asyncio.run(
|
||||
rl.llama_update_status(force_refresh = False, current_subject = "operator")
|
||||
)
|
||||
out = asyncio.run(rl.llama_update_status(force_refresh = False, current_subject = "operator"))
|
||||
assert out.machine.hostname
|
||||
assert out.machine.platform
|
||||
assert out.latest_tag == "b9909"
|
||||
|
|
@ -285,6 +285,7 @@ def test_status_reports_machine():
|
|||
# HTTP-level: auth gate + wiring + backwards-compatible bodyless POST
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
|
||||
def _client():
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
|
|
|||
|
|
@ -47,9 +47,7 @@ def _purge_expired_locked(now: float) -> None:
|
|||
|
||||
|
||||
def mint_confirm_token(
|
||||
target_tag: str,
|
||||
*,
|
||||
ttl_seconds: int = CONFIRM_TOKEN_TTL_SECONDS,
|
||||
target_tag: str, *, ttl_seconds: int = CONFIRM_TOKEN_TTL_SECONDS
|
||||
) -> Tuple[str, str]:
|
||||
"""Mint a single-use token bound to ``target_tag``.
|
||||
|
||||
|
|
@ -70,8 +68,7 @@ def mint_confirm_token(
|
|||
|
||||
|
||||
def consume_confirm_token(
|
||||
token: Optional[str],
|
||||
current_target_tag: str,
|
||||
token: Optional[str], current_target_tag: str
|
||||
) -> Tuple[bool, Optional[str]]:
|
||||
"""Validate and consume a token for a swap to ``current_target_tag``.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue