Skip to content

Commit

Permalink
Merge pull request #91 from nicolapace/main
Browse files Browse the repository at this point in the history
fixed urlopen giving error 403 in tests by adding User-Agent
  • Loading branch information
AntonKueltz authored Oct 12, 2023
2 parents 44c86a7 + f2a35cb commit 46ea741
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fastecdsa/tests/test_rfc6979_ecdsa.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from hashlib import sha1, sha224, sha256, sha384, sha512
from re import findall, DOTALL
from urllib.request import urlopen
from urllib.request import urlopen, Request
from unittest import TestCase

from ..curve import P192, P224, P256, P384, P521
Expand All @@ -11,7 +11,7 @@
class TestRFC6979ECDSA(TestCase):
@classmethod
def setUpClass(cls):
cls.rfc6979_text = urlopen('https://tools.ietf.org/rfc/rfc6979.txt').read().decode()
cls.rfc6979_text = urlopen(Request('https://tools.ietf.org/rfc/rfc6979.txt', headers={'User-Agent': 'python'})).read().decode()
cls.hash_lookup = {
'1': sha1,
'224': sha224,
Expand Down
4 changes: 2 additions & 2 deletions fastecdsa/tests/test_whycheproof_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sys import version_info
from unittest import SkipTest, TestCase, skipIf
from urllib.error import URLError
from urllib.request import urlopen
from urllib.request import urlopen, Request

from fastecdsa.curve import (
P224, P256, P384, P521,
Expand All @@ -25,7 +25,7 @@ class TestWycheproofEcdsaVerify(TestCase):
@staticmethod
def _get_tests(url):
try:
test_raw = urlopen(url).read()
test_raw = urlopen(Request(url, headers={'User-Agent': 'python'})).read()
test_json = loads(test_raw)
return test_json["testGroups"]
except (JSONDecodeError, URLError) as error:
Expand Down

0 comments on commit 46ea741

Please sign in to comment.