forked from mpdavis/python-jose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_EC.py
More file actions
34 lines (24 loc) · 801 Bytes
/
Copy pathtest_EC.py
File metadata and controls
34 lines (24 loc) · 801 Bytes
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
31
32
33
34
from jose.jwk import ECKey
from jose.exceptions import JOSEError
import ecdsa
import pytest
@pytest.fixture
def alg():
return ECKey(ECKey.SHA256)
private_key = """-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIIAK499svJugZZfsTsgL2tc7kH/CpzQbkr4g55CEWQyPoAcGBSuBBAAK
oUQDQgAEsOnVqWVPfjte2nI0Ay3oTZVehCUtH66nJM8z6flUluHxhLG8ZTTCkJAZ
W6xQdXHfqGUy3Dx40NDhgTaM8xAdSw==
-----END EC PRIVATE KEY-----"""
class TestECAlgorithm:
def test_EC_key(self, alg):
key = ecdsa.SigningKey.from_pem(private_key)
alg.prepare_key(key)
def test_string_secret(self, alg):
key = 'secret'
with pytest.raises(JOSEError):
alg.prepare_key(key)
def test_object(self, alg):
key = object()
with pytest.raises(JOSEError):
alg.prepare_key(key)