mirror of https://github.com/nucypher/pyUmbral.git
Fix test_config
parent
41cb180fe1
commit
5a4984fd4e
|
@ -1,9 +1,10 @@
|
|||
from umbral.config import _CONFIG
|
||||
import pytest
|
||||
import importlib
|
||||
from cryptography.hazmat.primitives.asymmetric import ec
|
||||
import pytest
|
||||
import warnings
|
||||
|
||||
from umbral.config import _CONFIG
|
||||
from umbral.curve import SECP256K1, SECP256R1
|
||||
|
||||
|
||||
def _copy_config_for_testing():
|
||||
"""
|
||||
|
@ -33,7 +34,7 @@ def test_try_to_use_curve_with_no_default_curve():
|
|||
assert caught_warnings[0].category == RuntimeWarning
|
||||
|
||||
# Now, a default curve has been set.
|
||||
assert config._CONFIG._CONFIG__curve == ec.SECP256K1
|
||||
assert config._CONFIG._CONFIG__curve == SECP256K1()
|
||||
|
||||
|
||||
def test_try_to_use_default_params_with_no_default_curve():
|
||||
|
@ -51,18 +52,18 @@ def test_try_to_use_default_params_with_no_default_curve():
|
|||
assert caught_warnings[0].category == RuntimeWarning
|
||||
|
||||
# Now, a default curve has been set.
|
||||
assert config._CONFIG._CONFIG__curve == ec.SECP256K1
|
||||
assert config._CONFIG._CONFIG__curve == SECP256K1()
|
||||
|
||||
|
||||
def test_cannot_set_default_curve_twice():
|
||||
config = _copy_config_for_testing()
|
||||
|
||||
# pyumbral even supports untrustworthy curves!
|
||||
config.set_default_curve(ec.SECP256R1)
|
||||
# pyumbral even supports NIST curves!
|
||||
config.set_default_curve(SECP256R1())
|
||||
|
||||
# Our default curve has been set...
|
||||
assert config.default_curve() == ec.SECP256R1
|
||||
assert config.default_curve() == SECP256R1()
|
||||
|
||||
# ...but once set, you can't set the default curve again, even if you've found a better one.
|
||||
with pytest.raises(config._CONFIG.UmbralConfigurationError):
|
||||
config.set_default_curve(ec.SECP256K1)
|
||||
config.set_default_curve(SECP256K1())
|
||||
|
|
|
@ -43,6 +43,7 @@ class Signature:
|
|||
"""
|
||||
cryptography_pub_key = verifying_key.to_cryptography_pubkey()
|
||||
|
||||
# TODO: Raise error instead of returning boolean
|
||||
try:
|
||||
cryptography_pub_key.verify(
|
||||
self._der_encoded_bytes(),
|
||||
|
|
Loading…
Reference in New Issue