mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-11-02 12:21:53 +08:00
Native model and generic ID (#971)
* Use a generic Protocol model for User instead of Pydantic
* Remove UserDB Pydantic schema
* Harmonize schema variable naming to avoid confusions
* Revamp OAuth account model management
* Revamp AccessToken DB strategy to adopt generic model approach
* Make ID a generic instead of forcing UUIDs
* Improve generic typing
* Improve Strategy typing
* Tweak base DB typing
* Don't set Pydantic schemas on FastAPIUsers class: pass it directly on router creation
* Add IntegerIdMixin and export related classes
* Start to revamp doc for V10
* Revamp OAuth documentation
* Fix code highlights
* Write the 9.x.x ➡️ 10.x.x migration doc
* Fix pyproject.toml
This commit is contained in:
@ -3,19 +3,12 @@ import pytest
|
||||
from fastapi import FastAPI, status
|
||||
|
||||
from fastapi_users.fastapi_users import FastAPIUsers
|
||||
from tests.conftest import User, UserCreate, UserDB, UserUpdate
|
||||
from tests.conftest import IDType, User, UserCreate, UserModel, UserUpdate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fastapi_users(get_user_manager, mock_authentication) -> FastAPIUsers:
|
||||
return FastAPIUsers[User, UserCreate, UserUpdate, UserDB](
|
||||
get_user_manager,
|
||||
[mock_authentication],
|
||||
User,
|
||||
UserCreate,
|
||||
UserUpdate,
|
||||
UserDB,
|
||||
)
|
||||
return FastAPIUsers[UserModel, IDType](get_user_manager, [mock_authentication])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -23,14 +16,14 @@ def test_app(
|
||||
fastapi_users: FastAPIUsers, secret, mock_authentication, oauth_client
|
||||
) -> FastAPI:
|
||||
app = FastAPI()
|
||||
app.include_router(fastapi_users.get_register_router())
|
||||
app.include_router(fastapi_users.get_register_router(User, UserCreate))
|
||||
app.include_router(fastapi_users.get_reset_password_router())
|
||||
app.include_router(fastapi_users.get_auth_router(mock_authentication))
|
||||
app.include_router(
|
||||
fastapi_users.get_oauth_router(oauth_client, mock_authentication, secret)
|
||||
)
|
||||
app.include_router(fastapi_users.get_users_router())
|
||||
app.include_router(fastapi_users.get_verify_router())
|
||||
app.include_router(fastapi_users.get_users_router(User, UserUpdate))
|
||||
app.include_router(fastapi_users.get_verify_router(User))
|
||||
|
||||
return app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user