mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
* Added a failing test for the multi-oauth-router issue * Fixed the #823 regression. Using a regex for the backend name validation instead of an enum. * Fixed formatting errors * Moved the `AuthenticationBackendName` enum to `Authenticator` This prevents an issue with OpenAPI schema generation caused by two endpoints accepting a parameter with a duplicate name.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from httpx_oauth.clients.facebook import FacebookOAuth2
|
||||
from httpx_oauth.clients.google import GoogleOAuth2
|
||||
|
||||
import fastapi_users.authentication
|
||||
@@ -134,3 +135,21 @@ class TestOAuth2:
|
||||
def test_google_callback_status_codes(self, get_openapi_dict):
|
||||
route = get_openapi_dict["paths"]["/callback"]["get"]
|
||||
assert list(route["responses"].keys()) == ["200", "400", "422"]
|
||||
|
||||
def test_two_oauth_routers(self):
|
||||
a = FastAPI()
|
||||
a.include_router(
|
||||
users.get_oauth_router(
|
||||
GoogleOAuth2(client_id="1234", client_secret="4321"),
|
||||
state_secret="secret",
|
||||
),
|
||||
prefix="/google",
|
||||
)
|
||||
a.include_router(
|
||||
users.get_oauth_router(
|
||||
FacebookOAuth2(client_id="1234", client_secret="4321"),
|
||||
state_secret="secret",
|
||||
),
|
||||
prefix="/facebook",
|
||||
)
|
||||
assert TestClient(a).get("/openapi.json").status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user