c17f41aaf8
- Introduced new tables for audit events and runtime state snapshots in the database schema. - Created data classes for AuditRecord and RuntimeStateRecord to represent the new entities. - Implemented AuditRepository and RuntimeStateRepository for inserting and retrieving records. - Enhanced the dashboard to include an audit trail section, displaying recent audit events. - Added tests for the new audit repository and runtime lifecycle functionalities. - Updated settings validation to ensure proper configuration for alerting features. - Integrated alert notifications across various components, including execution sequencer and loss limits.
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from arbitrade.config.settings import Settings
|
|
|
|
|
|
def test_dashboard_auth_requires_both_fields() -> None:
|
|
with pytest.raises(ValidationError):
|
|
Settings(_env_file=None, DASHBOARD_AUTH_USERNAME="admin")
|
|
|
|
|
|
def test_kraken_api_auth_requires_key_and_secret() -> None:
|
|
with pytest.raises(ValidationError):
|
|
Settings(_env_file=None, KRAKEN_API_KEY="key-only")
|
|
|
|
|
|
def test_kraken_permissions_require_query_and_trade() -> None:
|
|
with pytest.raises(ValidationError):
|
|
Settings(
|
|
_env_file=None,
|
|
KRAKEN_API_KEY="k",
|
|
KRAKEN_API_SECRET="s",
|
|
KRAKEN_API_KEY_PERMISSIONS="query",
|
|
)
|
|
|
|
|
|
def test_kraken_permissions_forbid_withdrawal_scope() -> None:
|
|
with pytest.raises(ValidationError):
|
|
Settings(
|
|
_env_file=None,
|
|
KRAKEN_API_KEY="k",
|
|
KRAKEN_API_SECRET="s",
|
|
KRAKEN_API_KEY_PERMISSIONS="query,trade,withdraw",
|
|
)
|
|
|
|
|
|
def test_alert_min_severity_is_validated() -> None:
|
|
with pytest.raises(ValidationError):
|
|
Settings(_env_file=None, ALERT_MIN_SEVERITY="nope")
|
|
|
|
|
|
def test_valid_security_configuration_passes() -> None:
|
|
settings = Settings(
|
|
_env_file=None,
|
|
KRAKEN_API_KEY="k",
|
|
KRAKEN_API_SECRET="s",
|
|
KRAKEN_API_KEY_PERMISSIONS="query,trade",
|
|
ALERT_MIN_SEVERITY="warning",
|
|
)
|
|
|
|
assert settings.kraken_api_key_permissions == "query,trade"
|