-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e8f758
commit b496de8
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |