50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
"""End-to-end test using mocked transport to verify full API surface."""
|
|
import struct
|
|
import asyncio
|
|
from unittest.mock import AsyncMock, MagicMock
|
|
from pm3py import Proxmark3, Cmd
|
|
|
|
|
|
def test_full_api_surface():
|
|
"""Verify all nested attributes exist."""
|
|
pm3 = Proxmark3("/dev/null")
|
|
|
|
assert hasattr(pm3, "hw")
|
|
assert hasattr(pm3, "lf")
|
|
assert hasattr(pm3, "hf")
|
|
assert hasattr(pm3.lf, "t55")
|
|
assert hasattr(pm3.hf, "a14")
|
|
assert hasattr(pm3.hf, "iso15")
|
|
assert hasattr(pm3.hf, "mf")
|
|
assert hasattr(pm3, "send_ng")
|
|
assert hasattr(pm3, "send_mix")
|
|
|
|
|
|
def test_hw_ping_roundtrip():
|
|
"""Test ping returns structured dict."""
|
|
pm3 = Proxmark3("/dev/null")
|
|
mock_transport = AsyncMock()
|
|
from pm3py.transport import PM3Response
|
|
ping_data = bytes(range(32))
|
|
mock_transport.send_ng.return_value = PM3Response(
|
|
cmd=Cmd.PING, status=0, reason=0, ng=True, data=ping_data)
|
|
pm3.hw._t = mock_transport
|
|
result = asyncio.get_event_loop().run_until_complete(pm3.hw.ping(32))
|
|
assert isinstance(result, dict)
|
|
assert result["success"] is True
|
|
|
|
|
|
def test_mf_rdbl_returns_hex():
|
|
"""Verify MIFARE read returns hex string data."""
|
|
pm3 = Proxmark3("/dev/null")
|
|
mock_transport = AsyncMock()
|
|
from pm3py.transport import PM3Response
|
|
block = bytes(range(16))
|
|
mock_transport.send_ng.return_value = PM3Response(
|
|
cmd=Cmd.HF_MIFARE_READBL, status=0, reason=0, ng=True, data=block)
|
|
pm3.hf.mf._t = mock_transport
|
|
result = asyncio.get_event_loop().run_until_complete(
|
|
pm3.hf.mf.rdbl(block=4, key="FFFFFFFFFFFF"))
|
|
assert result["data"] == "000102030405060708090a0b0c0d0e0f"
|
|
assert result["raw"] == block
|