mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 10:08:46 +02:00
Log client details for API and agent requests
This commit is contained in:
@@ -28,6 +28,9 @@ def test_snapshot_completes_chat_run_with_tools_and_response(monkeypatch, engine
|
||||
agui_run_id="run-1",
|
||||
thread_id="main",
|
||||
messages=[{"role": "user", "content": "¿Cuál es mi saldo?"}],
|
||||
client_ip="203.0.113.7",
|
||||
user_agent="Mozilla/5.0 TestBrowser/1.0",
|
||||
browser="TestBrowser",
|
||||
)
|
||||
token = chat_audit.set_current_chat_run(run_id)
|
||||
try:
|
||||
@@ -65,6 +68,9 @@ def test_snapshot_completes_chat_run_with_tools_and_response(monkeypatch, engine
|
||||
assert row.agui_run_id == "run-1"
|
||||
assert row.response_thread_id == "resp_123"
|
||||
assert row.user_prompt == "¿Cuál es mi saldo?"
|
||||
assert row.client_ip == "203.0.113.7"
|
||||
assert row.user_agent == "Mozilla/5.0 TestBrowser/1.0"
|
||||
assert row.browser == "TestBrowser"
|
||||
assert row.assistant_response == "Tu saldo es ₡1."
|
||||
assert row.tool_calls == [
|
||||
{
|
||||
@@ -107,7 +113,10 @@ def test_api_access_log_never_contains_request_body(monkeypatch):
|
||||
"path": "/api/auth/login",
|
||||
"raw_path": b"/api/auth/login",
|
||||
"query_string": b"",
|
||||
"headers": [],
|
||||
"headers": [
|
||||
(b"x-real-ip", b"203.0.113.9"),
|
||||
(b"user-agent", b"Mozilla/5.0 Chrome/138.0.0.0 Safari/537.36"),
|
||||
],
|
||||
"scheme": "http",
|
||||
"server": ("testserver", 80),
|
||||
"client": ("testclient", 1234),
|
||||
@@ -123,5 +132,8 @@ def test_api_access_log_never_contains_request_body(monkeypatch):
|
||||
fields = logged[0][1]
|
||||
assert fields["path"] == "/api/auth/login"
|
||||
assert fields["status_code"] == 201
|
||||
assert fields["client_ip"] == "203.0.113.9"
|
||||
assert fields["browser"] == "Chrome"
|
||||
assert fields["user_agent"] == "Mozilla/5.0 Chrome/138.0.0.0 Safari/537.36"
|
||||
assert "password" not in fields
|
||||
assert "body" not in fields
|
||||
|
||||
Reference in New Issue
Block a user