commit
c783a1442a
@ -19,7 +19,9 @@ from tests import Tester, FIDO2Tests, U2FTests, HIDTests, SoloTests
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print("Usage: %s [sim] <[u2f]|[fido2]|[rk]|[hid]|[ping]>")
|
print("Usage: %s [sim] [nfc] <[u2f]|[fido2]|[rk]|[hid]|[ping]>")
|
||||||
|
print(" sim - test via UDP simulation backend only")
|
||||||
|
print(" nfc - test via NFC interface only")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
t = Tester()
|
t = Tester()
|
||||||
@ -31,7 +33,11 @@ if __name__ == "__main__":
|
|||||||
t.set_sim(True)
|
t.set_sim(True)
|
||||||
t.set_user_count(10)
|
t.set_user_count(10)
|
||||||
|
|
||||||
t.find_device()
|
nfcOnly = False
|
||||||
|
if "nfc" in sys.argv:
|
||||||
|
nfcOnly = True
|
||||||
|
|
||||||
|
t.find_device(nfcOnly)
|
||||||
|
|
||||||
if "solo" in sys.argv:
|
if "solo" in sys.argv:
|
||||||
SoloTests(t).run()
|
SoloTests(t).run()
|
||||||
|
@ -78,7 +78,7 @@ def TestCborKeysSorted(cbor_obj):
|
|||||||
# https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#ctap2-canonical-cbor-encoding-form
|
# https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#ctap2-canonical-cbor-encoding-form
|
||||||
|
|
||||||
if isinstance(cbor_obj, bytes):
|
if isinstance(cbor_obj, bytes):
|
||||||
cbor_obj = cbor.loads(cbor_obj)[0]
|
cbor_obj = cbor.decode_from(cbor_obj)[0]
|
||||||
|
|
||||||
if isinstance(cbor_obj, dict):
|
if isinstance(cbor_obj, dict):
|
||||||
l = [x for x in cbor_obj]
|
l = [x for x in cbor_obj]
|
||||||
@ -341,8 +341,8 @@ class FIDO2Tests(Tester):
|
|||||||
def test_get_info(self,):
|
def test_get_info(self,):
|
||||||
with Test("Get info"):
|
with Test("Get info"):
|
||||||
info = self.ctap.get_info()
|
info = self.ctap.get_info()
|
||||||
print(bytes(info))
|
print("data:", bytes(info))
|
||||||
print(cbor.loads(bytes(info)))
|
print("decoded:", cbor.decode_from(bytes(info)))
|
||||||
|
|
||||||
with Test("Check FIDO2 string is in VERSIONS field"):
|
with Test("Check FIDO2 string is in VERSIONS field"):
|
||||||
assert "FIDO_2_0" in info.versions
|
assert "FIDO_2_0" in info.versions
|
||||||
|
@ -62,9 +62,22 @@ class Tester:
|
|||||||
self.ctap1 = tester.ctap1
|
self.ctap1 = tester.ctap1
|
||||||
self.client = tester.client
|
self.client = tester.client
|
||||||
|
|
||||||
def find_device(self,):
|
def find_device(self, nfcInterfaceOnly=False):
|
||||||
|
dev = None
|
||||||
|
if not nfcInterfaceOnly:
|
||||||
|
print("--- HID ---")
|
||||||
print(list(CtapHidDevice.list_devices()))
|
print(list(CtapHidDevice.list_devices()))
|
||||||
dev = next(CtapHidDevice.list_devices(), None)
|
dev = next(CtapHidDevice.list_devices(), None)
|
||||||
|
|
||||||
|
if not dev:
|
||||||
|
try:
|
||||||
|
from fido2.pcsc import CtapPcscDevice
|
||||||
|
|
||||||
|
print("--- NFC ---")
|
||||||
|
print(list(CtapPcscDevice.list_devices()))
|
||||||
|
dev = next(CtapPcscDevice.list_devices(), None)
|
||||||
|
except (ModuleNotFoundError, ImportError):
|
||||||
|
print("One of NFC library is not installed properly.")
|
||||||
if not dev:
|
if not dev:
|
||||||
raise RuntimeError("No FIDO device found")
|
raise RuntimeError("No FIDO device found")
|
||||||
self.dev = dev
|
self.dev = dev
|
||||||
|
Loading…
x
Reference in New Issue
Block a user