chore: fix all ruff lint errors + format — 0 errors, 306 tests pass
This commit is contained in:
+13
-10
@@ -3,20 +3,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
from sqlalchemy.ext.asyncio import AsyncEngine, async_sessionmaker, AsyncSession
|
||||
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
|
||||
|
||||
from app.core.db import reset_engine_for_testing, close_engine
|
||||
from app.core.db import close_engine, reset_engine_for_testing
|
||||
from app.core.service_container import get_container
|
||||
from app.main import create_app
|
||||
from app.plugins.registry import reset_registry_for_testing
|
||||
from app.plugins.builtins.permissions import PermissionsPlugin
|
||||
from app.plugins.registry import reset_registry_for_testing
|
||||
from app.services.plugin_service import reset_plugin_service_for_testing
|
||||
from tests.conftest import seed_tenant_and_users, login_client, ORIGIN_HEADER
|
||||
from tests.conftest import ORIGIN_HEADER, login_client, seed_tenant_and_users
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
@@ -182,7 +182,7 @@ async def test_expired_share_link(authed_client: AsyncClient):
|
||||
file_id = str(uuid.uuid4())
|
||||
|
||||
# Create link with expiry in the past
|
||||
past = datetime.now(timezone.utc) - timedelta(hours=1)
|
||||
past = datetime.now(UTC) - timedelta(hours=1)
|
||||
resp = await client.post(
|
||||
f"/api/v1/dms/files/{file_id}/share-link",
|
||||
json={"expires_at": past.isoformat(), "access_level": "download"},
|
||||
@@ -235,21 +235,23 @@ async def test_revoke_share_link(authed_client: AsyncClient):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_permission_403_for_unauthorized_user(plugin_client: AsyncClient, db_session: AsyncSession):
|
||||
async def test_permission_403_for_unauthorized_user(
|
||||
plugin_client: AsyncClient, db_session: AsyncSession
|
||||
):
|
||||
"""AC14: Folder permissions enforced: user without read → 403.
|
||||
|
||||
The permissions plugin does not intercept file access (no DMS file system yet).
|
||||
We test the permission check helper directly: a user with no permission record
|
||||
gets denied (False), which translates to 403 at the route layer.
|
||||
"""
|
||||
from app.plugins.builtins.permissions.routes import check_user_file_permission
|
||||
from app.core.db import get_session_factory
|
||||
from app.plugins.builtins.permissions.routes import check_user_file_permission
|
||||
|
||||
seed = await seed_tenant_and_users(db_session)
|
||||
await login_client(plugin_client, "admin@tenanta.com")
|
||||
|
||||
# Install + activate permissions plugin
|
||||
registry = reset_registry_for_testing()
|
||||
reset_registry_for_testing()
|
||||
# We need to set up the registry properly
|
||||
# Since plugin_client fixture wasn't used, manually install
|
||||
resp = await plugin_client.post("/api/v1/plugins/permissions/install", headers=ORIGIN_HEADER)
|
||||
@@ -270,6 +272,7 @@ async def test_permission_403_for_unauthorized_user(plugin_client: AsyncClient,
|
||||
|
||||
# Grant read to admin
|
||||
from app.plugins.builtins.permissions.models import Permission
|
||||
|
||||
perm = Permission(
|
||||
tenant_id=tenant_id,
|
||||
file_id=file_id,
|
||||
@@ -422,7 +425,7 @@ async def test_public_access_post_expired(authed_client: AsyncClient):
|
||||
"""POST /api/public/share/{token} with expired link → 410."""
|
||||
client, seed = authed_client
|
||||
file_id = str(uuid.uuid4())
|
||||
past = datetime.now(timezone.utc) - timedelta(hours=1)
|
||||
past = datetime.now(UTC) - timedelta(hours=1)
|
||||
resp = await client.post(
|
||||
f"/api/v1/dms/files/{file_id}/share-link",
|
||||
json={"expires_at": past.isoformat(), "access_level": "download"},
|
||||
|
||||
Reference in New Issue
Block a user