"""Tests for StubOIDCProvider (U11 — interface placeholder).""" from __future__ import annotations import pytest from agentkit.server.auth.providers import StubOIDCProvider from agentkit.server.auth.providers.exceptions import ( AuthProviderError, ProviderNotImplemented, ) class TestStubAuthenticate: async def test_raises_provider_not_implemented(self): provider = StubOIDCProvider() with pytest.raises(ProviderNotImplemented): await provider.authenticate(username="alice", password="hunter2") async def test_error_message_mentions_oidc(self): """The error message must guide the operator to the right next step.""" provider = StubOIDCProvider() with pytest.raises(ProviderNotImplemented) as exc: await provider.authenticate(username="alice", password="x") msg = str(exc.value) assert "OIDC" in msg assert "not implemented" in msg.lower() class TestStubGetUserById: async def test_raises_provider_not_implemented(self): provider = StubOIDCProvider() with pytest.raises(ProviderNotImplemented): await provider.get_user_by_id("any-id") class TestStubSyncUserAttributes: async def test_raises_provider_not_implemented(self): provider = StubOIDCProvider() with pytest.raises(ProviderNotImplemented): await provider.sync_user_attributes("any-id") class TestStubRevokeUser: async def test_raises_provider_not_implemented(self): provider = StubOIDCProvider() with pytest.raises(ProviderNotImplemented): await provider.revoke_user("any-id") class TestAllErrorsAreAuthProviderError: """Every stub method's error should be catchable as AuthProviderError.""" @pytest.mark.parametrize( "method,call_args", [ ("authenticate", ()), ("get_user_by_id", ("id",)), ("sync_user_attributes", ("id",)), ("revoke_user", ("id",)), ], ) async def test_catchable_as_base(self, method: str, call_args: tuple): provider = StubOIDCProvider() with pytest.raises(AuthProviderError): if method == "authenticate": await provider.authenticate(username="u", password="p") else: await getattr(provider, method)(*call_args)