"""Tests for pybyd._crypto.signing."""

from __future__ import annotations

from pybyd._crypto.signing import build_sign_string


class TestBuildSignString:
    def test_sorts_keys(self) -> None:
        result = build_sign_string({"b": "2", "a": "1"}, "pw")
        assert result == "a=1&b=2&password=pw"

    def test_empty_fields(self) -> None:
        result = build_sign_string({}, "pw")
        assert result == "&password=pw"

    def test_complex(self) -> None:
        fields = {
            "countryCode": "NL",
            "identifier": "user@test.com",
            "language": "en",
        }
        result = build_sign_string(fields, "PASSKEY")
        assert result == "countryCode=NL&identifier=user@test.com&language=en&password=PASSKEY"
