Harden production workflows and agent admission
This commit is contained in:
@@ -49,7 +49,28 @@ def make_heartbeat(agent_id: str = "agent-1") -> dict:
|
||||
return {
|
||||
"agent_id": agent_id,
|
||||
"observed_at": now_iso(),
|
||||
"hostname": "host-1",
|
||||
"hostname": agent_id,
|
||||
"features": {"push": True, "metrics": True},
|
||||
"labels": {},
|
||||
}
|
||||
|
||||
|
||||
def agent_token(agent_id: str = "agent-1") -> str:
|
||||
safe = "".join(ch if ch.isalnum() else "0" for ch in agent_id)
|
||||
return f"test-agent-key-{safe}-00000000000000000000000000000000"
|
||||
|
||||
|
||||
def agent_headers(agent_id: str = "agent-1") -> dict[str, str]:
|
||||
return {"Authorization": f"Bearer {agent_token(agent_id)}"}
|
||||
|
||||
|
||||
async def register_agent(
|
||||
client, ui_headers: dict[str, str], agent_id: str = "agent-1"
|
||||
) -> dict[str, str]:
|
||||
headers = agent_headers(agent_id)
|
||||
r = await client.post("/api/v1/heartbeat", json=make_heartbeat(agent_id), headers=headers)
|
||||
assert r.status_code == 202
|
||||
r = await client.post(f"/api/v1/agents/{agent_id}/accept", headers=ui_headers)
|
||||
assert r.status_code == 200
|
||||
assert r.json()["count"] == 1
|
||||
return headers
|
||||
|
||||
Reference in New Issue
Block a user