File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from fido2 .ctap2 .blob import LargeBlobs
44from fido2 .server import Fido2Server
55from fido2 .utils import websafe_encode , websafe_decode
6+ from fido2 import cbor
67from . import TEST_PIN
78
89import os
@@ -49,6 +50,27 @@ def test_read_write(ctap2, pin_protocol):
4950 assert len (lb .read_blob_array ()) == 0
5051
5152
53+ def test_size_bounds (ctap2 , pin_protocol ):
54+ lb = get_lb (ctap2 , pin_protocol )
55+ assert len (lb .read_blob_array ()) == 0
56+
57+ size = ctap2 .info .max_large_blob
58+
59+ # Create data which when cbor-encoded is exactly size bytes
60+ array = [{1 : os .urandom (size - 8 )}]
61+ array .extend ([0 ] * (size - len (cbor .encode (array ))))
62+
63+ lb .write_blob_array (array )
64+
65+ # Ensure writing larger data fails:
66+ array .append (1 )
67+ with pytest .raises (CtapError , match = "LARGE_BLOB_STORAGE_FULL" ):
68+ lb .write_blob_array (array )
69+
70+ # Clear the data
71+ lb .write_blob_array ([])
72+
73+
5274def test_missing_permissions (ctap2 , pin_protocol ):
5375 key = os .urandom (32 )
5476 data = b"test data"
You can’t perform that action at this time.
0 commit comments