Skip to content

Commit 01a154c

Browse files
committed
Add test for libxml2 version compatibility
1 parent 960b3a1 commit 01a154c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/src/OneLogin/saml2_tests/xml_utils_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import json
55
import unittest
6+
import xmlsec
67

78
from base64 import b64decode
89
from lxml import etree
@@ -32,6 +33,29 @@ def file_contents(self, filename):
3233
f.close()
3334
return content
3435

36+
def testLibxml2(self):
37+
"""
38+
Tests that libxml2 versions used by xmlsec and lxml are compatible
39+
40+
If this test fails, reinstall lxml without using binary to ensure it is
41+
linked to same version of libxml2 as xmlsec:
42+
pip install --force-reinstall --no-binary lxml lxml
43+
44+
See https://bugs.launchpad.net/lxml/+bug/1960668
45+
"""
46+
env = etree.fromstring('<xml></xml>')
47+
sig = xmlsec.template.create(
48+
env,
49+
xmlsec.Transform.EXCL_C14N,
50+
xmlsec.Transform.RSA_SHA256,
51+
ns="ds"
52+
)
53+
54+
ds = etree.QName(sig).namespace
55+
cm = sig.find(".//{%s}CanonicalizationMethod" % ds)
56+
57+
self.assertIsNotNone(cm)
58+
3559
def testValidateXML(self):
3660
"""
3761
Tests the validate_xml method of the OneLogin_Saml2_XML

0 commit comments

Comments
 (0)