"""Verify the :class:`WebhookVerifier` Protocol's structural contract.

The Protocol is what the Clerk webhook route calls. These tests pin it
so adding a new method (or changing a signature) trips the suite,
forcing a deliberate update to consumers (the production
:class:`ClerkWebhookVerifier` and the test :class:`MockWebhookVerifier`).
"""

from __future__ import annotations

import inspect

from mgf.auth import MockWebhookVerifier, WebhookVerifier


def test_protocol_advertises_one_method() -> None:
    methods = {
        name
        for name, _ in inspect.getmembers(WebhookVerifier, predicate=inspect.isfunction)
        if not name.startswith("_")
    }
    assert methods == {"verify_webhook"}


def test_mock_satisfies_protocol_at_runtime() -> None:
    verifier: WebhookVerifier = MockWebhookVerifier()
    assert isinstance(verifier, WebhookVerifier)


def test_verify_webhook_parameters() -> None:
    sig = inspect.signature(WebhookVerifier.verify_webhook)
    params = sig.parameters
    assert list(params) == ["self", "headers", "body"]
    assert params["body"].annotation == "bytes"
    assert sig.return_annotation == "WebhookEvent"
