# 2026-04-20 @ Asia/Taipei
import hmac, hashlib
from aider_watch_client.api_client import sign_body


def test_sign_body_format():
    body = b'{"events":[]}'
    sig = sign_body(body, "secret")
    assert sig.startswith("sha256=")
    expected = "sha256=" + hmac.new(b"secret", body, hashlib.sha256).hexdigest()
    assert sig == expected


def test_sign_body_deterministic():
    assert sign_body(b"same", "secret") == sign_body(b"same", "secret")


def test_sign_body_different_secrets():
    assert sign_body(b"body", "sec1") != sign_body(b"body", "sec2")


def test_sign_body_different_bodies():
    assert sign_body(b"a", "s") != sign_body(b"b", "s")
