diff --git a/src/fastapi_startkit_auth/__init__.py b/src/fastapi_startkit_auth/__init__.py index 99dd51c..6c3cb2c 100644 --- a/src/fastapi_startkit_auth/__init__.py +++ b/src/fastapi_startkit_auth/__init__.py @@ -18,7 +18,9 @@ ApiTokenConfig, AuthConfig, OAuth2Config, + OAuthClientConfig, OAuthClientsConfig, + OAuthTokenConfig, OAuthTokensConfig, SessionConfig, ) @@ -68,7 +70,9 @@ "AuthConfig", "SessionConfig", "OAuth2Config", + "OAuthClientConfig", "OAuthClientsConfig", + "OAuthTokenConfig", "OAuthTokensConfig", "ApiTokenConfig", "AuthProvider", diff --git a/src/fastapi_startkit_auth/config/__init__.py b/src/fastapi_startkit_auth/config/__init__.py index 0dad9ae..a1514fc 100644 --- a/src/fastapi_startkit_auth/config/__init__.py +++ b/src/fastapi_startkit_auth/config/__init__.py @@ -6,7 +6,9 @@ AuthConfig, OAuth2Config, OAuth2Guard, + OAuthClientConfig, OAuthClientsConfig, + OAuthTokenConfig, OAuthTokensConfig, SessionConfig, SessionGuard, @@ -19,7 +21,9 @@ "AuthConfig", "SessionConfig", "OAuth2Config", + "OAuthClientConfig", "OAuthClientsConfig", + "OAuthTokenConfig", "OAuthTokensConfig", "ApiTokenConfig", "SessionGuard", diff --git a/src/fastapi_startkit_auth/config/auth.py b/src/fastapi_startkit_auth/config/auth.py index 75c61f1..49a236d 100644 --- a/src/fastapi_startkit_auth/config/auth.py +++ b/src/fastapi_startkit_auth/config/auth.py @@ -8,14 +8,14 @@ ConfigT = TypeVar("ConfigT") -def _canonical_store(store: str, section: str) -> str: - if store == "orm": +def _canonical_driver(driver: str, section: str) -> str: + if driver == "orm": # stacklevel 4: this helper, __post_init__, the dataclass __init__, then the caller. warnings.warn( - f'{section}(store="orm") is deprecated; use store="database".', DeprecationWarning, stacklevel=4 + f'{section}(driver="orm") is deprecated; use driver="database".', DeprecationWarning, stacklevel=4 ) return "database" - return store + return driver @dataclass @@ -41,11 +41,11 @@ class ApiTokenGuard: class SessionConfig: """Cookie sessions, enabled by ``AuthSessionProvider``. - ``store`` is "memory", "database" (the ORM ``sessions`` table; "orm" is a + ``driver`` is "memory", "database" (the ORM ``sessions`` table; "orm" is a deprecated alias) or "instance" (a ready-made store under ``instance``). """ - store: str = "memory" + driver: str = "memory" connection: str | None = None instance: Any = None cookie: str = "startkit_session" @@ -63,7 +63,7 @@ class SessionConfig: csrf_exempt_paths: list[str] = field(default_factory=list) def __post_init__(self) -> None: - self.store = _canonical_store(self.store, "SessionConfig") + self.driver = _canonical_driver(self.driver, "SessionConfig") @dataclass @@ -74,7 +74,7 @@ class ApiTokenConfig: accept the ``session_guard`` cookie session from those origins. """ - store: str = "memory" + driver: str = "memory" connection: str | None = None instance: Any = None header: str = "Authorization" @@ -84,7 +84,7 @@ class ApiTokenConfig: session_guard: str = "web" def __post_init__(self) -> None: - self.store = _canonical_store(self.store, "ApiTokenConfig") + self.driver = _canonical_driver(self.driver, "ApiTokenConfig") @property def stateful(self) -> bool: @@ -92,25 +92,42 @@ def stateful(self) -> bool: @dataclass -class OAuthClientsConfig: +class OAuthClientConfig: """Where OAuth clients live: "database" (the ORM ``oauth_clients`` table), "memory" or "instance".""" - store: str = "database" + driver: str = "database" connection: str | None = None instance: Any = None def __post_init__(self) -> None: - self.store = _canonical_store(self.store, "OAuthClientsConfig") + self.driver = _canonical_driver(self.driver, "OAuthClientConfig") @dataclass -class OAuthTokensConfig: - store: str = "memory" +class OAuthTokenConfig: + driver: str = "memory" connection: str | None = None instance: Any = None def __post_init__(self) -> None: - self.store = _canonical_store(self.store, "OAuthTokensConfig") + self.driver = _canonical_driver(self.driver, "OAuthTokenConfig") + + +def _deprecated_alias(config_type: type[ConfigT], old_name: str) -> type[ConfigT]: + class Alias(config_type): + def __init__(self, *args: Any, **kwargs: Any) -> None: + warnings.warn( + f"{old_name} is deprecated; use {config_type.__name__}.", DeprecationWarning, stacklevel=2 + ) + super().__init__(*args, **kwargs) + + Alias.__name__ = old_name + Alias.__qualname__ = old_name + return Alias + + +OAuthClientsConfig = _deprecated_alias(OAuthClientConfig, "OAuthClientsConfig") +OAuthTokensConfig = _deprecated_alias(OAuthTokenConfig, "OAuthTokensConfig") DEFAULT_GRANT_TYPES = ("authorization_code", "client_credentials", "refresh_token") @@ -145,12 +162,12 @@ class OAuth2Config: require_redirect_uri: bool = True grant_types: list[str] = field(default_factory=lambda: list(DEFAULT_GRANT_TYPES)) authorization_guard: str | None = None - tokens: OAuthTokensConfig = field(default_factory=OAuthTokensConfig) - clients: OAuthClientsConfig = field(default_factory=OAuthClientsConfig) + tokens: OAuthTokenConfig = field(default_factory=OAuthTokenConfig) + clients: OAuthClientConfig = field(default_factory=OAuthClientConfig) def __post_init__(self) -> None: - self.tokens = resolve_config(self.tokens, OAuthTokensConfig) - self.clients = resolve_config(self.clients, OAuthClientsConfig) + self.tokens = resolve_config(self.tokens, OAuthTokenConfig) + self.clients = resolve_config(self.clients, OAuthClientConfig) # v0.6 AuthConfig attributes that moved to OAuth2Config; still read, with a warning. diff --git a/src/fastapi_startkit_auth/manager.py b/src/fastapi_startkit_auth/manager.py index d99683f..10c0a36 100644 --- a/src/fastapi_startkit_auth/manager.py +++ b/src/fastapi_startkit_auth/manager.py @@ -52,10 +52,10 @@ _REMOVED_STORES = ("sql", "async_sql") -def _reject_removed_store(kind: str, section: str) -> None: +def _reject_removed_driver(kind: str, section: str) -> None: if kind in _REMOVED_STORES: raise ValueError( - f'{section} store "{kind}" was removed: use store "database" (optional ORM ' + f'{section} store "{kind}" was removed: use driver "database" (optional ORM ' '"connection" name) after running the published migrations.' ) @@ -330,16 +330,16 @@ def session_store(self) -> SessionStore: def _build_session_store(self) -> SessionStore: config = self.session_config - if config.store == "memory": + if config.driver == "memory": return InMemorySessionStore(idle_ttl=config.idle_ttl) - if config.store == "database": + if config.driver == "database": from .sessions.orm import OrmSessionStore return OrmSessionStore(config.connection, idle_ttl=config.idle_ttl, purge_interval=config.purge_interval) - _reject_removed_store(config.store, "SessionConfig") - if config.store == "instance": + _reject_removed_driver(config.driver, "SessionConfig") + if config.driver == "instance": return config.instance - raise ValueError(f"Unknown session store: {config.store!r}") + raise ValueError(f"Unknown session store: {config.driver!r}") @property def api_tokens(self) -> ApiTokenManager | AsyncApiTokenManager: @@ -353,41 +353,41 @@ def api_tokens(self) -> ApiTokenManager | AsyncApiTokenManager: return self._api_tokens def _build_api_token_repository(self, config: ApiTokenConfig) -> ApiTokenRepository: - if config.store == "memory": + if config.driver == "memory": return InMemoryApiTokenRepository() - if config.store == "database": + if config.driver == "database": from .apitokens.orm import OrmApiTokenRepository return OrmApiTokenRepository(config.connection) - _reject_removed_store(config.store, "ApiTokenConfig") - if config.store == "instance": + _reject_removed_driver(config.driver, "ApiTokenConfig") + if config.driver == "instance": return config.instance - raise ValueError(f"Unknown API token store: {config.store!r}") + raise ValueError(f"Unknown API token store: {config.driver!r}") def _build_token_repository(self, config: OAuth2Config) -> Any: tokens = config.tokens - if tokens.store == "memory": + if tokens.driver == "memory": return InMemoryTokenRepository() - if tokens.store == "database": + if tokens.driver == "database": from .tokens.orm import OrmTokenRepository return OrmTokenRepository(tokens.connection) - _reject_removed_store(tokens.store, "OAuth2Config.tokens") - if tokens.store == "instance": + _reject_removed_driver(tokens.driver, "OAuth2Config.tokens") + if tokens.driver == "instance": return tokens.instance - raise ValueError(f"Unknown OAuth token store: {tokens.store!r}") + raise ValueError(f"Unknown OAuth token store: {tokens.driver!r}") def _build_client_repository(self, config: OAuth2Config) -> Any: clients = config.clients - if clients.store == "memory": + if clients.driver == "memory": return InMemoryClientRepository(hasher=self.hasher) - if clients.store == "database": + if clients.driver == "database": from .clients.orm import OrmClientRepository return OrmClientRepository(clients.connection, hasher=self.hasher) - if clients.store == "instance": + if clients.driver == "instance": return clients.instance - raise ValueError(f"Unknown OAuth client store: {clients.store!r}") + raise ValueError(f"Unknown OAuth client store: {clients.driver!r}") # --- providers and brokers ----------------------------------------- def _build_provider(self, spec: dict[str, Any]) -> UserProvider: diff --git a/tests/conftest.py b/tests/conftest.py index bb9c44a..ad84a00 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -27,7 +27,7 @@ AuthProvider, AuthSessionProvider, OAuth2Config, - OAuthClientsConfig, + OAuthClientConfig, current_user, require_scopes, ) @@ -113,7 +113,7 @@ def delete(self, client_id): def oauth2_config(**overrides): overrides.setdefault("key", TEST_OAUTH_KEY) - overrides.setdefault("clients", OAuthClientsConfig(store="instance", instance=SyncClientRepository())) + overrides.setdefault("clients", OAuthClientConfig(driver="instance", instance=SyncClientRepository())) return OAuth2Config(**overrides) diff --git a/tests/test_api_tokens.py b/tests/test_api_tokens.py index 2effc52..93a04bf 100644 --- a/tests/test_api_tokens.py +++ b/tests/test_api_tokens.py @@ -431,12 +431,12 @@ def test_token_guard_coexists_with_passport_guard(): def test_unknown_api_token_store_raises(): with pytest.raises(ValueError, match="Unknown API token store"): - auth_manager(token_config(), api_tokens={"store": "redis"}).api_tokens + auth_manager(token_config(), api_tokens={"driver": "redis"}).api_tokens def test_instance_store_is_used_verbatim(): repository = InMemoryApiTokenRepository() - manager = auth_manager(token_config(), api_tokens={"store": "instance", "instance": repository}) + manager = auth_manager(token_config(), api_tokens={"driver": "instance", "instance": repository}) assert manager.api_tokens.repository is repository diff --git a/tests/test_async_auth.py b/tests/test_async_auth.py index e714f3f..83c8c02 100644 --- a/tests/test_async_auth.py +++ b/tests/test_async_auth.py @@ -132,7 +132,7 @@ def sync_facade(auth: Auth = Depends(Auth.scoped)): async def build(connection, **kwargs): api = FastAPI() - store = {"store": "database", "connection": connection} + store = {"driver": "database", "connection": connection} manager = register_auth( api, make_config(connection, **kwargs), @@ -188,9 +188,9 @@ class Config(AuthConfig): providers = {"users": {"driver": "memory", "users": []}} features = { - "session": {"session": {"store": removed}}, - "api_tokens": {"api_tokens": {"store": removed}}, - "tokens": {"oauth2": oauth2_config(tokens={"store": removed})}, + "session": {"session": {"driver": removed}}, + "api_tokens": {"api_tokens": {"driver": removed}}, + "tokens": {"oauth2": oauth2_config(tokens={"driver": removed})}, }[section] attribute = {"session": "session_store", "api_tokens": "api_tokens", "tokens": "token_repository"}[section] with pytest.raises(ValueError, match='"database"'): diff --git a/tests/test_async_safety.py b/tests/test_async_safety.py index 05e781c..2412002 100644 --- a/tests/test_async_safety.py +++ b/tests/test_async_safety.py @@ -98,7 +98,7 @@ class Config(AuthConfig): def install(api, connection=None, *, session=None, clients=None, **kwargs): - stores = {"store": "database", "connection": connection} if connection is not None else {"store": "memory"} + stores = {"driver": "database", "connection": connection} if connection is not None else {"driver": "memory"} return register_auth( api, make_config(**kwargs), @@ -307,7 +307,7 @@ def test_sync_refresh_grant_denied_when_owner_is_gone(how): users = [{"id": 1, "email": "ada@example.com", "password": HASHER.make("secret"), "active": True}] provider = {"driver": "memory", "users": users, "is_active": "active"} api = FastAPI() - sync_clients = {"store": "instance", "instance": SyncClientRepository()} + sync_clients = {"driver": "instance", "instance": SyncClientRepository()} manager = install(api, provider=provider, clients=sync_clients) assert isinstance(manager.refresh_grant(), RefreshTokenGrant) client = TestClient(api) @@ -385,7 +385,7 @@ async def test_sync_provider_and_session_store_never_run_on_the_loop(orm_databas client, _ = await build( orm_database, provider={"driver": "instance", "instance": provider}, - session={"store": "instance", "instance": sessions}, + session={"driver": "instance", "instance": sessions}, ) async with client: LOOP_CALLS.clear() diff --git a/tests/test_class_config.py b/tests/test_class_config.py index 05b1d33..cf99370 100644 --- a/tests/test_class_config.py +++ b/tests/test_class_config.py @@ -8,7 +8,7 @@ OAuth2Config, SessionConfig, ) -from fastapi_startkit_auth.config import OAuth2Guard, OAuthClientsConfig, SessionGuard, resolve_config +from fastapi_startkit_auth.config import OAuth2Guard, OAuthClientConfig, SessionGuard, resolve_config from fastapi_startkit_auth.guards.guard import PassportGuard from fastapi_startkit_auth.guards.session import SessionGuard as RuntimeSessionGuard from fastapi_startkit_auth.security.jwt import JWTEncoder @@ -112,7 +112,7 @@ def test_oauth_settings_configure_signing_and_token_lifetimes(): key="nested-oauth-signing-key", access_token_ttl=120, authorization_code_ttl=30, - clients=OAuthClientsConfig(store="memory"), + clients=OAuthClientConfig(driver="memory"), ) ) @@ -125,4 +125,4 @@ def test_oauth_settings_configure_signing_and_token_lifetimes(): def test_missing_oauth_key_warns_and_generates_an_ephemeral_key(): with pytest.warns(UserWarning, match="OAuth2Config.key is not set"): - AuthManager(Config).use_oauth2(OAuth2Config(clients=OAuthClientsConfig(store="memory"))) + AuthManager(Config).use_oauth2(OAuth2Config(clients=OAuthClientConfig(driver="memory"))) diff --git a/tests/test_multi_provider.py b/tests/test_multi_provider.py index 78ebee4..ab9abc6 100644 --- a/tests/test_multi_provider.py +++ b/tests/test_multi_provider.py @@ -72,7 +72,7 @@ class Config(AuthConfig): def install(api, providers, connection=None): - stores = {"store": "database", "connection": connection} if connection is not None else {"store": "memory"} + stores = {"driver": "database", "connection": connection} if connection is not None else {"driver": "memory"} oauth2 = oauth2_config(key=KEY, grant_types=list(PASSWORD_GRANTS), tokens=stores) return register_auth(api, make_config(providers), oauth2=oauth2) diff --git a/tests/test_oauth2_client_command.py b/tests/test_oauth2_client_command.py index 3f09d33..6b72224 100644 --- a/tests/test_oauth2_client_command.py +++ b/tests/test_oauth2_client_command.py @@ -6,7 +6,7 @@ from fastapi.testclient import TestClient from fastapi_startkit_auth import AuthConfig, AuthManager, AuthOAuth2Provider, AuthProvider -from fastapi_startkit_auth.config import OAuth2Config, OAuthClientsConfig +from fastapi_startkit_auth.config import OAuth2Config, OAuthClientConfig from conftest import MIGRATIONS_DIR, ORM_CONNECTION @@ -41,7 +41,7 @@ async def migrate(): OAUTH2 = OAuth2Config( key="command-test-key-with-at-least-32-bytes", - clients=OAuthClientsConfig(store="database", connection=ORM_CONNECTION), + clients=OAuthClientConfig(driver="database", connection=ORM_CONNECTION), ) @@ -136,7 +136,7 @@ def test_scopes_outside_the_catalog_create_no_client(client_database): OAuth2Config( key="command-test-key-with-at-least-32-bytes", scopes={"read": "Read"}, - clients=OAuthClientsConfig(store="database", connection=ORM_CONNECTION), + clients=OAuthClientConfig(driver="database", connection=ORM_CONNECTION), ) ) command = OAuth2ClientCommand() diff --git a/tests/test_oauth_config_aliases.py b/tests/test_oauth_config_aliases.py new file mode 100644 index 0000000..24faf51 --- /dev/null +++ b/tests/test_oauth_config_aliases.py @@ -0,0 +1,29 @@ +import warnings + +import pytest + +from fastapi_startkit_auth import OAuth2Config, OAuthClientConfig, OAuthClientsConfig, OAuthTokenConfig, OAuthTokensConfig + + +def test_singular_names_do_not_warn(): + with warnings.catch_warnings(): + warnings.simplefilter("error") + OAuthTokenConfig(driver="memory") + OAuthClientConfig(driver="memory") + + +@pytest.mark.parametrize( + ("old", "new"), + [(OAuthTokensConfig, OAuthTokenConfig), (OAuthClientsConfig, OAuthClientConfig)], +) +def test_plural_alias_warns_and_builds_the_singular_config(old, new): + with pytest.warns(DeprecationWarning, match=old.__name__): + config = old(driver="memory") + assert isinstance(config, new) + assert config.driver == "memory" + + +def test_oauth2_config_accepts_plural_alias_as_field_value(): + with pytest.warns(DeprecationWarning): + oauth2 = OAuth2Config(tokens=OAuthTokensConfig(driver="memory")) + assert oauth2.tokens.driver == "memory" diff --git a/tests/test_oauth_hardening.py b/tests/test_oauth_hardening.py index ada923c..9663e24 100644 --- a/tests/test_oauth_hardening.py +++ b/tests/test_oauth_hardening.py @@ -368,7 +368,7 @@ class KeyConfig(AuthConfig): key = TEST_OAUTH_KEY with pytest.warns(DeprecationWarning, match="AuthConfig.key"): - manager = AuthManager(KeyConfig).use_oauth2({"clients": {"store": "memory"}}) + manager = AuthManager(KeyConfig).use_oauth2({"clients": {"driver": "memory"}}) assert manager.oauth2_config.key == TEST_OAUTH_KEY diff --git a/tests/test_session_auth.py b/tests/test_session_auth.py index 21d6e93..701c3b6 100644 --- a/tests/test_session_auth.py +++ b/tests/test_session_auth.py @@ -278,12 +278,12 @@ class Config(AuthConfig): def test_session_store_config_selects_implementation(): assert isinstance(_manager().session_store, InMemorySessionStore) custom = InMemorySessionStore() - manager = _manager(session={"store": "instance", "instance": custom}) + manager = _manager(session={"driver": "instance", "instance": custom}) assert manager.session_store is custom with pytest.raises(ValueError, match="Unknown session store"): - _manager(session={"store": "redis"}).session_store + _manager(session={"driver": "redis"}).session_store with pytest.raises(ValueError, match='"database"'): - _manager(session={"store": "sql"}).session_store + _manager(session={"driver": "sql"}).session_store # --- facade unit behaviour -------------------------------------------- diff --git a/tests/test_startkit_provider.py b/tests/test_startkit_provider.py index d61134c..228a5be 100644 --- a/tests/test_startkit_provider.py +++ b/tests/test_startkit_provider.py @@ -28,7 +28,7 @@ CORS_STUB = PUBLISHABLE / "cors.py" MIGRATIONS = PUBLISHABLE / "migrations" SECRET = "framework-test-secret-with-32-bytes-min!" -MEMORY_CLIENTS = {"store": "memory"} +MEMORY_CLIENTS = {"driver": "memory"} class FakeConfig: @@ -178,14 +178,14 @@ def find_spec(self, fullname, path=None, target=None): from fastapi import FastAPI from fastapi.testclient import TestClient -from fastapi_startkit_auth import AuthConfig, AuthOAuth2Provider, AuthProvider, OAuth2Config, OAuthClientsConfig +from fastapi_startkit_auth import AuthConfig, AuthOAuth2Provider, AuthProvider, OAuth2Config, OAuthClientConfig class Config(AuthConfig): guards = {} app = FastAPI() AuthProvider(Config).register(app) -AuthOAuth2Provider(OAuth2Config(key="standalone-test-key-with-32-bytes-min!", clients=OAuthClientsConfig(store="memory"))).register(app) +AuthOAuth2Provider(OAuth2Config(key="standalone-test-key-with-32-bytes-min!", clients=OAuthClientConfig(driver="memory"))).register(app) assert TestClient(app).post("/oauth/token", data={"grant_type": "unsupported"}).status_code == 400 assert "fastapi_startkit" not in sys.modules """ diff --git a/tests/test_store_names.py b/tests/test_store_names.py index 4169e51..a72cdde 100644 --- a/tests/test_store_names.py +++ b/tests/test_store_names.py @@ -5,14 +5,14 @@ from fastapi_startkit_auth import AuthConfig, AuthManager from fastapi_startkit_auth.config import ( ApiTokenConfig, - OAuthClientsConfig, - OAuthTokensConfig, + OAuthClientConfig, + OAuthTokenConfig, SessionConfig, ) from conftest import oauth2_config -STORE_CONFIGS = [SessionConfig, ApiTokenConfig, OAuthClientsConfig, OAuthTokensConfig] +STORE_CONFIGS = [SessionConfig, ApiTokenConfig, OAuthClientConfig, OAuthTokenConfig] class Config(AuthConfig): @@ -20,7 +20,7 @@ class Config(AuthConfig): def test_oauth_clients_default_to_the_database_store(): - assert OAuthClientsConfig().store == "database" + assert OAuthClientConfig().driver == "database" def test_the_database_default_resolves_to_the_orm_client_store(): @@ -29,15 +29,15 @@ def test_the_database_default_resolves_to_the_orm_client_store(): with warnings.catch_warnings(): warnings.simplefilter("error", DeprecationWarning) - manager = AuthManager(Config).use_oauth2(oauth2_config(clients=OAuthClientsConfig())) + manager = AuthManager(Config).use_oauth2(oauth2_config(clients=OAuthClientConfig())) assert isinstance(manager.client_repository, OrmClientRepository) @pytest.mark.parametrize("config_type", STORE_CONFIGS) def test_orm_is_a_deprecated_alias_of_database(config_type): - with pytest.warns(DeprecationWarning, match=f'{config_type.__name__}\\(store="orm"\\) is deprecated'): - config = config_type(store="orm") - assert config.store == "database" + with pytest.warns(DeprecationWarning, match=f'{config_type.__name__}\\(driver="orm"\\) is deprecated'): + config = config_type(driver="orm") + assert config.driver == "database" def test_the_deprecated_alias_still_resolves_to_the_orm_client_store(): @@ -45,5 +45,5 @@ def test_the_deprecated_alias_still_resolves_to_the_orm_client_store(): from fastapi_startkit_auth.clients.orm import OrmClientRepository with pytest.warns(DeprecationWarning): - manager = AuthManager(Config).use_oauth2(oauth2_config(clients={"store": "orm"})) + manager = AuthManager(Config).use_oauth2(oauth2_config(clients={"driver": "orm"})) assert isinstance(manager.client_repository, OrmClientRepository) diff --git a/tests/test_sync_regression.py b/tests/test_sync_regression.py index eee2886..51a69e1 100644 --- a/tests/test_sync_regression.py +++ b/tests/test_sync_regression.py @@ -14,7 +14,7 @@ SessionGuard, InMemoryApiTokenRepository, InMemorySessionStore, - OAuthClientsConfig, + OAuthClientConfig, TokenGuard, TokenService, current_user, @@ -99,7 +99,7 @@ def build(default_guard="api", sent=None): api, sync_config(default_guard, sent), session={}, - oauth2=oauth2_config(grant_types=list(PASSWORD_GRANTS), tokens={"store": "memory"}), + oauth2=oauth2_config(grant_types=list(PASSWORD_GRANTS), tokens={"driver": "memory"}), api_tokens={}, ) @@ -145,18 +145,18 @@ def test_manager_builds_the_sync_classes(): def _manager_with_clients(clients): - return auth_manager(sync_config(), oauth2=oauth2_config(tokens={"store": "memory"}, clients=clients)) + return auth_manager(sync_config(), oauth2=oauth2_config(tokens={"driver": "memory"}, clients=clients)) def test_async_memory_client_store_selects_the_async_owner_grants(): - manager = _manager_with_clients(OAuthClientsConfig(store="memory")) + manager = _manager_with_clients(OAuthClientConfig(driver="memory")) assert type(manager.token_service) is TokenService assert type(manager.refresh_grant()) is AsyncRefreshTokenGrant assert type(manager.authorization_code_grant()) is AsyncAuthorizationCodeGrant def test_sync_instance_client_store_keeps_the_sync_owner_grants(): - manager = _manager_with_clients(OAuthClientsConfig(store="instance", instance=SyncClientRepository())) + manager = _manager_with_clients(OAuthClientConfig(driver="instance", instance=SyncClientRepository())) assert type(manager.refresh_grant()) is RefreshTokenGrant assert type(manager.authorization_code_grant()) is AuthorizationCodeGrant