One universal Windows Agent package per version (agent_releases: version/ platform/architecture/sha256/status DRAFT|PUBLISHED|REVOKED; the binary lives on a local release-storage volume, never in PostgreSQL). An operator creates a pending installation (agent_enrollments) from Agents / Servidores -> + Nova instalação, then either downloads it directly or generates a one-time HTTPS link (short TTL, single use). Either path streams the package plus a freshly minted enrollment.json whose token is never written to storage in plaintext, only its SHA-256 hash. On the client host, gti-agent.ps1 install-auto verifies the bundle's SHA-256, refuses a non- HTTPS Hub, enrolls via POST /v1/agents/enroll (deleting the enrollment token immediately after, success or failure), writes an ACL-restricted .env with the newly issued permanent Agent token, and registers the Windows Service without starting it (Firebird stays unconfigured on purpose). Idempotent, replay-proof, rate-limited per IP, fully audited, never logs a secret. Migration 0022_agent_releases_enrollment (verified fresh-DB == upgrade-from-0021 by pg_dump diff). GTI_FISCAL_VERSION/AGENT_VERSION bumped to 1.1.0 as the single source of truth across code, packages, the release manifest and every published AgentRelease row. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
from central.app.main import create_app
|
|
|
|
|
|
def test_health_reports_database_dependency():
|
|
client = TestClient(create_app(database_probe=lambda: True))
|
|
|
|
assert client.get("/health").json() == {"status": "ok"}
|
|
|
|
|
|
def test_health_is_unavailable_when_database_is_down():
|
|
client = TestClient(create_app(database_probe=lambda: False))
|
|
|
|
assert client.get("/health").status_code == 503
|
|
|
|
|
|
def test_version_endpoint_reports_release_and_fiscal_versions():
|
|
body = TestClient(create_app(database_probe=lambda: True)).get("/version").json()
|
|
assert body["version"] == "1.1.0" and body["api_compat"] == "1.0" and body["engine_version"] and body["decision_version"]
|
|
|
|
|
|
def test_production_refuses_the_dev_token(monkeypatch):
|
|
import pytest
|
|
from central.app import main as main_module
|
|
monkeypatch.setattr(main_module.settings.__class__, "environment", "production", raising=False) if False else None
|
|
monkeypatch.setattr(main_module, "settings", type("S", (), {"environment": "production", "agent_dev_token": "dev", "log_level": "INFO"})())
|
|
with pytest.raises(RuntimeError):
|
|
create_app(database_probe=lambda: True)
|