@ripla/godd-mcp 0.1.3-canary.76 → 0.1.3-canary.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
|
|
5
5
|
from fastapi import APIRouter, Depends, HTTPException
|
|
6
|
+
from fastapi.encoders import jsonable_encoder
|
|
6
7
|
from pydantic import BaseModel
|
|
7
8
|
from sqlalchemy import select
|
|
8
9
|
from sqlalchemy.dialects.postgresql import insert
|
|
@@ -28,7 +29,7 @@ async def get_settings(db: AsyncSession = Depends(get_db)):
|
|
|
28
29
|
try:
|
|
29
30
|
result = await db.execute(select(NotesSetting))
|
|
30
31
|
rows = result.scalars().all()
|
|
31
|
-
return {row.key: row.value for row in rows}
|
|
32
|
+
return jsonable_encoder({row.key: row.value for row in rows})
|
|
32
33
|
except SQLAlchemyError:
|
|
33
34
|
logger.exception("Failed to load application settings")
|
|
34
35
|
raise HTTPException(
|
|
@@ -80,6 +80,8 @@ def make_mock_result(value=None):
|
|
|
80
80
|
def mock_db():
|
|
81
81
|
"""Provide an AsyncMock DB session and override the get_db dependency."""
|
|
82
82
|
session = AsyncMock()
|
|
83
|
+
# AsyncSession.add is synchronous; a default AsyncMock would return an un-awaited coroutine.
|
|
84
|
+
session.add = MagicMock()
|
|
83
85
|
|
|
84
86
|
async def override_get_db() -> AsyncGenerator:
|
|
85
87
|
yield session
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"""Tests for audit log service."""
|
|
2
2
|
|
|
3
3
|
import uuid
|
|
4
|
-
from unittest.mock import AsyncMock
|
|
4
|
+
from unittest.mock import AsyncMock, MagicMock
|
|
5
5
|
|
|
6
6
|
from app.services.audit import audit_log
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
def _async_db_session() -> AsyncMock:
|
|
10
|
+
"""AsyncSession stand-in: .add is sync; awaitable methods stay AsyncMock."""
|
|
10
11
|
db = AsyncMock()
|
|
12
|
+
db.add = MagicMock()
|
|
13
|
+
return db
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
async def test_audit_log_creates_entry():
|
|
17
|
+
db = _async_db_session()
|
|
11
18
|
user_id = uuid.uuid4()
|
|
12
19
|
|
|
13
20
|
await audit_log(db, user_id, "save", detail={"filePath": "docs/test.md"})
|
|
@@ -21,7 +28,7 @@ async def test_audit_log_creates_entry():
|
|
|
21
28
|
|
|
22
29
|
|
|
23
30
|
async def test_audit_log_with_ip_address():
|
|
24
|
-
db =
|
|
31
|
+
db = _async_db_session()
|
|
25
32
|
user_id = uuid.uuid4()
|
|
26
33
|
|
|
27
34
|
await audit_log(db, user_id, "login", ip_address="192.168.1.1")
|
|
@@ -31,7 +38,7 @@ async def test_audit_log_with_ip_address():
|
|
|
31
38
|
|
|
32
39
|
|
|
33
40
|
async def test_audit_log_nullable_user_id():
|
|
34
|
-
db =
|
|
41
|
+
db = _async_db_session()
|
|
35
42
|
|
|
36
43
|
await audit_log(db, None, "system_event")
|
|
37
44
|
|
|
@@ -74,6 +74,10 @@ class TestJWT:
|
|
|
74
74
|
"username": "x",
|
|
75
75
|
"exp": datetime.now(UTC) + timedelta(hours=1),
|
|
76
76
|
}
|
|
77
|
-
token = jwt.encode(
|
|
77
|
+
token = jwt.encode(
|
|
78
|
+
payload,
|
|
79
|
+
"wrong-secret-but-long-enough-for-jwt-hs256-recommendation",
|
|
80
|
+
algorithm="HS256",
|
|
81
|
+
)
|
|
78
82
|
with pytest.raises(Exception, match="Invalid or expired token"):
|
|
79
83
|
verify_access_token(token)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ripla/godd-mcp",
|
|
3
|
-
"version": "0.1.3-canary.
|
|
3
|
+
"version": "0.1.3-canary.78",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "GoDD (Governance-orchestrated Driven Development) MCP Server - Encrypted prompt distribution via Model Context Protocol",
|
|
6
6
|
"main": "dist/index.js",
|