from __future__ import annotations

from ebay_client.notification.webhook import WebhookChallengeHandler, WebhookSignatureParser


def test_challenge_handler_builds_sha256_response() -> None:
    response = WebhookChallengeHandler.build_challenge_response(
        challenge_code="challenge",
        verification_token="verification",
        endpoint="https://example.test/webhook",
    )

    assert len(response) == 64


def test_signature_parser_extracts_known_fields() -> None:
    parser = WebhookSignatureParser()

    parsed = parser.parse("kid=public-key-1,alg=ECDSA,digest=SHA256,sig=Zm9v")

    assert parsed.key_id == "public-key-1"
    assert parsed.algorithm == "ECDSA"
    assert parsed.digest == "SHA256"
    assert parsed.signature == b"foo"