安全:增加测试批次上下文硬校验
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from module_admin.entity.vo.user_vo import CurrentUserModel, UserInfoModel
|
||||
from module_business.domain.enums import TestBatchStatus
|
||||
from module_business.domain.test_batch_scope import TestBatchScope
|
||||
|
||||
|
||||
def make_current_user(
|
||||
user_id: int = 7,
|
||||
permissions: list[str] | None = None,
|
||||
*,
|
||||
admin: bool = False,
|
||||
) -> CurrentUserModel:
|
||||
return CurrentUserModel(
|
||||
permissions=permissions or [],
|
||||
roles=[],
|
||||
user=UserInfoModel(
|
||||
userId=user_id,
|
||||
userName='admin' if user_id == 1 else f'user-{user_id}',
|
||||
admin=admin,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def make_admin() -> CurrentUserModel:
|
||||
return make_current_user(1, ['*:*:*'], admin=True)
|
||||
|
||||
|
||||
def make_test_scope(batch_id: int, status: str = 'ACTIVE', writable: bool = True) -> TestBatchScope:
|
||||
return TestBatchScope(batch_id=batch_id, mode='TEST', status=TestBatchStatus(status), writable=writable)
|
||||
Reference in New Issue
Block a user