Skip to content

Commit

Permalink
satisfy pylint (and isort)
Browse files Browse the repository at this point in the history
  • Loading branch information
YSaxon committed May 17, 2023
1 parent 5f49c44 commit f114202
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
15 changes: 5 additions & 10 deletions tests/example_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@
Navigate to https://localhost:5000 in a supported web browser.
"""
from fido2.webauthn import (
CollectedClientData,
PublicKeyCredentialRpEntity,
AttestationObject,
AuthenticatorData,
)
from fido2.server import Fido2Server
from fido2 import cbor
from flask import Flask, session, request, redirect, abort

import os

from fido2 import cbor
from fido2.server import Fido2Server
from fido2.webauthn import (AttestationObject, AuthenticatorData,
CollectedClientData, PublicKeyCredentialRpEntity)
from flask import Flask, abort, redirect, request, session

app = Flask(__name__, static_url_path="")
app.secret_key = os.urandom(32) # Used for session.
Expand Down
7 changes: 5 additions & 2 deletions tests/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import pytest
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from fido2.webauthn import AttestedCredentialData
from fido2.utils import sha256
from fido2.webauthn import AttestedCredentialData

from soft_webauthn import SoftWebauthnDevice


# PublicKeyCredentialCreationOptions
PKCCO = {
'publicKey': {
Expand Down Expand Up @@ -86,6 +85,10 @@ def test_get():
device = SoftWebauthnDevice()
device.cred_init(PKCRO['publicKey']['rpId'], b'randomhandle')

_device_assertions(device)


def _device_assertions(device):
assertion = device.get(PKCRO, 'https://example.org')

assert assertion
Expand Down
3 changes: 2 additions & 1 deletion tests/test_interop.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""SoftWebauthnDevice class tests"""

from fido2.server import Fido2Server
from fido2.webauthn import AttestationObject, AuthenticatorData, CollectedClientData, PublicKeyCredentialRpEntity
from fido2.webauthn import (AttestationObject, AuthenticatorData,
CollectedClientData, PublicKeyCredentialRpEntity)

from soft_webauthn import SoftWebauthnDevice

Expand Down
15 changes: 3 additions & 12 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""SoftWebauthnDevice serialization tests, mostly adapted from test_class.py"""

import pytest
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from fido2.utils import sha256

from soft_webauthn import SoftWebauthnDevice
from .test_class import PKCCO, PKCRO

from .test_class import PKCCO, PKCRO, _device_assertions


def test_create_and_serialize_without_password():
Expand Down Expand Up @@ -58,11 +56,4 @@ def test_get_after_deserialize():
serialized = device.to_bytes()
deserialized = SoftWebauthnDevice.from_bytes(serialized)

assertion = deserialized.get(PKCRO, 'https://example.org')

assert assertion
device.private_key.public_key().verify(
assertion['response']['signature'],
assertion['response']['authenticatorData'] + sha256(assertion['response']['clientDataJSON']),
ec.ECDSA(hashes.SHA256())
)
_device_assertions(deserialized)

0 comments on commit f114202

Please sign in to comment.