添加测试环境

This commit is contained in:
wcq 2023-02-10 09:35:05 +08:00
parent da221fd817
commit b5a14ba046
5 changed files with 9 additions and 6 deletions

View File

@ -9,7 +9,7 @@ from Utils.SqlAlchemyUtils import get_db
router = APIRouter(
tags=["应用管理"],
prefix="/api/app_manage",
# dependencies=[Depends(admin_auth_token_depend)]
dependencies=[Depends(admin_auth_token_depend)]
)

View File

@ -8,7 +8,7 @@ from Utils.SqlAlchemyUtils import get_db
router = APIRouter(
tags=["权限规则"],
prefix="/api/auth_rule",
# dependencies=[Depends(admin_auth_token_depend)]
dependencies=[Depends(admin_auth_token_depend)]
)

View File

@ -9,7 +9,7 @@ from Utils.SqlAlchemyUtils import get_db
router = APIRouter(
tags=["职务操作"],
prefix="/api/post",
# dependencies=[Depends(admin_auth_token_depend)]
dependencies=[Depends(admin_auth_token_depend)]
)

View File

@ -12,6 +12,7 @@ def create_token(data: dict, secret_key, algorithm, expires_delta: timedelta = t
to_encode_body = dict()
to_encode_body.update(data.copy())
# 设置过期时间
if timedelta:
expire = datetime.utcnow() + expires_delta
to_encode_body.update({"exp": expire})
# Token编码

View File

@ -2,15 +2,17 @@ import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from Router import UserRouter, UserRegisterRouter, DepartmentRouter, PostRouter, AppRouter, UserManageRouter, \
AppManageRouter,AuthRuleRouter
AppManageRouter, AuthRuleRouter
from Utils.ConfigUtils import init_common_config
from Utils.RedisUtils import init_redis_pool
from Utils.SqlAlchemyUtils import Base, init_database
from Context.common import ctx
from Utils.TestUtils import init_test_env
init_common_config()
init_database()
init_redis_pool()
init_test_env()
app = FastAPI(
title="用户模块",