Skip to content

Commit 533e33e

Browse files
committed
Use threadpool in algorithms test case
1 parent dfdd4a1 commit 533e33e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import unittest
88
from base64 import b64decode, b64encode
9+
from concurrent.futures import ThreadPoolExecutor
910
from dataclasses import replace
1011
from glob import glob
1112
from xml.etree import ElementTree as stdlibElementTree
@@ -113,7 +114,7 @@ def test_basic_signxml_statements(self):
113114
self.assertEqual(SignatureMethod.RSA_SHA256.value, "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")
114115
self.assertEqual(SignatureConstructionMethod.enveloped, methods.enveloped)
115116
with self.assertRaisesRegex(InvalidInput, "Unknown signature construction method"):
116-
signer = XMLSignerWithSHA1(method=None)
117+
XMLSignerWithSHA1(method=None)
117118

118119
with self.assertRaisesRegex(InvalidInput, "must be an XML element"):
119120
XMLSigner(signature_algorithm="hmac-sha256").sign("x", key=b"abc")
@@ -125,8 +126,8 @@ def test_basic_signxml_statements(self):
125126
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments",
126127
}
127128

128-
all_methods = itertools.product(digest_algs, sig_algs, methods, c14n_algs)
129-
for digest_alg, sig_alg, method, c14n_alg in all_methods:
129+
def test_case(case):
130+
digest_alg, sig_alg, method, c14n_alg = case
130131
data = [etree.parse(f).getroot() for f in self.example_xml_files]
131132
# FIXME: data.extend(stdlibElementTree.parse(f).getroot() for f in (self.example_xml_files)
132133
data.append(stdlibElementTree.parse(self.example_xml_files[0]).getroot())
@@ -214,6 +215,10 @@ def resolver(uri):
214215
verify_kwargs["hmac_key"] = b"SECRET"
215216
XMLVerifier().verify(signed_data, **verify_kwargs)
216217

218+
executor = ThreadPoolExecutor()
219+
for _ in executor.map(test_case, itertools.product(digest_algs, sig_algs, methods, c14n_algs)):
220+
pass
221+
217222
def test_x509_certs(self):
218223
from OpenSSL.crypto import FILETYPE_PEM
219224
from OpenSSL.crypto import Error as OpenSSLCryptoError

0 commit comments

Comments
 (0)