11from fido2 .hid import CtapHidDevice , list_descriptors , open_connection , open_device
22from fido2 .cose import CoseKey
3+ from fido2 .hid import CAPABILITY
34from fido2 .ctap2 import Ctap2
45from fido2 .ctap2 .pin import ClientPin , PinProtocolV1 , PinProtocolV2
56from fido2 .ctap2 .credman import CredentialManagement
@@ -47,9 +48,10 @@ def __init__(self, printer, reader_name):
4748 self ._reader = None
4849 self ._dev = self ._select ()
4950
50- options = self .ctap2 .info .options
51- if options .get ("clientPin" ) or options .get ("uv" ):
52- pytest .exit ("Authenticator must be in a newly-reset state!" )
51+ if self .has_ctap2 ():
52+ options = Ctap2 (self .device ).info .options
53+ if options .get ("clientPin" ) or options .get ("uv" ):
54+ pytest .exit ("Authenticator must be in a newly-reset state!" )
5355
5456 self .setup ()
5557
@@ -145,9 +147,14 @@ def _connect():
145147 def device (self ):
146148 return self ._dev
147149
150+ def has_ctap2 (self ):
151+ return self .device .capabilities & CAPABILITY .CBOR
152+
148153 @property
149154 def ctap2 (self ):
150- return Ctap2 (self .device )
155+ if self .has_ctap2 ():
156+ return Ctap2 (self .device )
157+ pytest .skip ("Authenticator does not support CTAP 2" )
151158
152159 @property
153160 def info (self ):
@@ -217,7 +224,7 @@ def factory_reset(self, setup=False):
217224 self .setup ()
218225
219226 def setup (self ):
220- if ClientPin .is_supported (self .info ):
227+ if self . has_ctap2 () and ClientPin .is_supported (self .info ):
221228 ClientPin (self .ctap2 ).set_pin (TEST_PIN )
222229
223230
@@ -238,7 +245,8 @@ def dev_manager(pytestconfig, printer):
238245 yield manager
239246
240247 # after the test, reset the device
241- manager .factory_reset ()
248+ if manager .has_ctap2 ():
249+ manager .factory_reset ()
242250
243251
244252@pytest .fixture
0 commit comments