feat: add models for physical files, policies, and user management

- Implement PhysicalFile model to manage physical file references and reference counting.
- Create Policy model with associated options and group links for storage policies.
- Introduce Redeem and Report models for handling redeem codes and reports.
- Add Settings model for site configuration and user settings management.
- Develop Share model for sharing objects with unique codes and associated metadata.
- Implement SourceLink model for managing download links associated with objects.
- Create StoragePack model for managing user storage packages.
- Add Tag model for user-defined tags with manual and automatic types.
- Implement Task model for managing background tasks with status tracking.
- Develop User model with comprehensive user management features including authentication.
- Introduce UserAuthn model for managing WebAuthn credentials.
- Create WebDAV model for managing WebDAV accounts associated with users.
This commit is contained in:
2026-02-10 16:25:49 +08:00
parent 62c671e07b
commit 209cb24ab4
92 changed files with 3640 additions and 1444 deletions

View File

@@ -8,9 +8,9 @@ from uuid import UUID
from sqlmodel.ext.asyncio.session import AsyncSession
from models.user import User
from models.group import Group
from models.object import Object, ObjectType
from sqlmodels.user import User
from sqlmodels.group import Group
from sqlmodels.object import Object, ObjectType
from tests.fixtures import UserFactory, GroupFactory, ObjectFactory
@@ -24,13 +24,13 @@ async def test_user_factory(db_session: AsyncSession):
user = await UserFactory.create(
db_session,
group_id=group.id,
username="testuser",
email="testuser@test.local",
password="password123"
)
# 验证
assert user.id is not None
assert user.username == "testuser"
assert user.email == "testuser@test.local"
assert user.group_id == group.id
assert user.status is True
@@ -51,7 +51,7 @@ async def test_group_factory(db_session: AsyncSession):
async def test_object_factory(db_session: AsyncSession):
"""测试对象工厂的基本功能"""
# 准备依赖
from models.policy import Policy, PolicyType
from sqlmodels.policy import Policy, PolicyType
group = await GroupFactory.create(db_session)
user = await UserFactory.create(db_session, group_id=group.id)
@@ -102,7 +102,7 @@ async def test_conftest_fixtures(
"""测试 conftest.py 中的 fixtures"""
# 验证 test_user fixture
assert test_user["id"] is not None
assert test_user["username"] == "testuser"
assert test_user["email"] == "testuser@test.local"
assert test_user["token"] is not None
# 验证 auth_headers fixture
@@ -112,7 +112,7 @@ async def test_conftest_fixtures(
# 验证用户在数据库中存在
user = await User.get(db_session, User.id == test_user["id"])
assert user is not None
assert user.username == test_user["username"]
assert user.email == test_user["email"]
@pytest.mark.integration
@@ -145,7 +145,7 @@ async def test_test_directory_fixture(
@pytest.mark.integration
async def test_nested_structure_factory(db_session: AsyncSession):
"""测试嵌套结构工厂"""
from models.policy import Policy, PolicyType
from sqlmodels.policy import Policy, PolicyType
# 准备依赖
group = await GroupFactory.create(db_session)