File: test_credentials.py

package info (click to toggle)
python-fido2 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,456 kB
  • sloc: python: 11,423; javascript: 181; sh: 21; makefile: 9
file content (30 lines) | stat: -rw-r--r-- 933 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from fido2.server import Fido2Server


def test_make_assert(client, pin_protocol, algorithm):
    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)

    # Create a credential
    result = client.make_credential(
        {
            **create_options["publicKey"],
            "pubKeyCredParams": [algorithm],
        }
    )

    auth_data = server.register_complete(state, result)
    cred = auth_data.credential_data
    assert cred.public_key[3] == algorithm["alg"]
    credentials = [cred]

    # Get assertion
    request_options, state = server.authenticate_begin(credentials)

    # Authenticate the credential
    result = client.get_assertion(request_options.public_key).get_response(0)
    cred_data = server.authenticate_complete(state, credentials, result)
    assert cred_data == cred