Some checks failed
CI / lint (pull_request) Failing after 44s
CI / test (3.10) (pull_request) Failing after 30s
CI / test (3.11) (pull_request) Failing after 33s
CI / test (3.12) (pull_request) Successful in 1m26s
CI / migrations (pull_request) Successful in 24s
CI / helm (pull_request) Successful in 20s
CI / docker (pull_request) Has been skipped
Frontend wiring: - Wire useMarkdownWorker into Markdown component (worker-first, sync fallback) - Wire useIndexedDB as primary storage in useChatHistory (500 msg cap, localStorage fallback) Backend depth: - Persistent audit store (SQLite, thread-safe, WAL mode) with record/query/filter - Wire audit store into session routes (session.create, prompt.submit events) - Wire audit store into audit export routes (persistent-first, telemetry fallback) - CSRF double-submit cookie pattern (token generation, cookie set, header validation) Production: - Helm chart CI: helm lint + helm template validation - Database migration CI: verify step in pipeline - Prometheus alerting rules (error rate, latency, pod restarts, memory, CPU, queue, health) - Rate limiting per API key (3x IP limit, sliding window, advisory) - WebSocket SSE fallback (auto-downgrade after MAX_RETRIES WS failures) Tests: 605 Python + 56 frontend = 661 total, 0 ruff errors Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
29 lines
789 B
Python
29 lines
789 B
Python
"""Tests for CSRF token generation and double-submit cookie pattern."""
|
|
|
|
from fusionagi.api.security import (
|
|
CSRF_COOKIE_NAME,
|
|
CSRF_HEADER_NAME,
|
|
CSRF_TOKEN_LENGTH,
|
|
generate_csrf_token,
|
|
)
|
|
|
|
|
|
def test_generate_csrf_token_length():
|
|
"""Token should be URL-safe and reasonable length."""
|
|
token = generate_csrf_token()
|
|
assert len(token) > 20
|
|
assert all(c.isalnum() or c in "-_" for c in token)
|
|
|
|
|
|
def test_generate_csrf_token_uniqueness():
|
|
"""Each token should be unique."""
|
|
tokens = {generate_csrf_token() for _ in range(100)}
|
|
assert len(tokens) == 100
|
|
|
|
|
|
def test_csrf_constants():
|
|
"""CSRF constants should be set."""
|
|
assert CSRF_COOKIE_NAME == "fusionagi_csrf"
|
|
assert CSRF_HEADER_NAME == "x-csrf-token"
|
|
assert CSRF_TOKEN_LENGTH == 32
|