add jwt check
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import pytest
|
||||
from sqlalchemy import NullPool
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy import NullPool, insert
|
||||
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
|
||||
|
||||
from src.core.auth_manager import AuthManager
|
||||
from src.core.database import Base
|
||||
from src.models import * # noqa: F403
|
||||
|
||||
@@ -10,6 +11,14 @@ engine_null_pool = create_async_engine('sqlite+aiosqlite:///tests/test_db.db', p
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
async def setup_database():
|
||||
hashed_pass = AuthManager.get_password_hash("admin")
|
||||
user_admin = {"username": "admin", "hashed_password": hashed_pass, "is_superuser": True}
|
||||
async with engine_null_pool.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.drop_all)
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
async with async_sessionmaker(engine_null_pool, expire_on_commit=False)() as conn:
|
||||
result = await conn.execute(insert(UsersORM).values(user_admin).returning(UsersORM)) # noqa: F405
|
||||
await conn.commit()
|
||||
admin = result.scalar_one()
|
||||
assert admin.is_superuser is True
|
||||
|
||||
Reference in New Issue
Block a user