- Implement tests for `EbayOAuthClient` to verify authorization URL generation with configured scopes and token reuse logic. - Add tests for `WebhookChallengeHandler` to ensure correct SHA256 response generation and for `WebhookSignatureParser` to validate extraction of known fields from signature strings.
24 lines
No EOL
759 B
Python
24 lines
No EOL
759 B
Python
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" |