Skip to content

Commit

Permalink
Add tests for credblob
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Jan 15, 2025
1 parent 4e8f758 commit b496de8
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/device/test_credblob.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from fido2.server import Fido2Server

import os
import pytest


@pytest.fixture(autouse=True, scope="module")
def preconditions(dev_manager):
if "credBlob" not in dev_manager.info.extensions:
pytest.skip("CredBlob not supported by authenticator")


def test_read_write(client):
rp = {"id": "example.com", "name": "Example RP"}
server = Fido2Server(rp)
user = {"id": b"user_id", "name": "A. User"}

create_options, state = server.register_begin(
user,
resident_key_requirement="required",
user_verification="required",
)

# Create a credential
blob = os.urandom(32)
result = client.make_credential(
{
**create_options["publicKey"],
"extensions": {"credBlob": blob},
}
)
auth_data = server.register_complete(state, result)
credentials = [auth_data.credential_data]

assert auth_data.extensions["credBlob"] is True

request_options, state = server.authenticate_begin(
credentials, user_verification="required"
)

selection = client.get_assertion(
{
**request_options["publicKey"],
"extensions": {"getCredBlob": True},
}
)
result = selection.get_response(0)

assert result.response.authenticator_data.extensions.get("credBlob") == blob

0 comments on commit b496de8

Please sign in to comment.