Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lxml version restriction #323

Merged
merged 2 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Installation

* python 2.7 // python 3.6
* [xmlsec](https://pypi.python.org/pypi/xmlsec) Python bindings for the XML Security Library.
* [lxml](https://pypi.python.org/pypi/lxml) Python bindings for the libxml2 and libxslt libraries.
* [isodate](https://pypi.python.org/pypi/isodate) An ISO 8601 date/time/
duration parser and formatter

Expand Down Expand Up @@ -115,6 +116,14 @@ $ pip install python3-saml

If you want to know how a project can handle python packages review this [guide](https://packaging.python.org/en/latest/tutorial.html) and review this [sampleproject](https://github.com/pypa/sampleproject)

#### NOTE ####
To avoid ``libxml2`` library version incompatibilities between ``xmlsec`` and ``lxml`` it is recommended that ``lxml`` is not installed from binary.

This can be ensured by executing:
```
$ pip install --force-reinstall --no-binary lxml lxml
```

Security Warning
----------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
test_suite='tests',
install_requires=[
'lxml<4.7.1',
'lxml>=4.6.5',
'isodate>=0.6.1',
'xmlsec>=1.3.9'
],
Expand Down
24 changes: 24 additions & 0 deletions tests/src/OneLogin/saml2_tests/xml_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import json
import unittest
import xmlsec

from base64 import b64decode
from lxml import etree
Expand Down Expand Up @@ -32,6 +33,29 @@ def file_contents(self, filename):
f.close()
return content

def testLibxml2(self):
"""
Tests that libxml2 versions used by xmlsec and lxml are compatible

If this test fails, reinstall lxml without using binary to ensure it is
linked to same version of libxml2 as xmlsec:
pip install --force-reinstall --no-binary lxml lxml

See https://bugs.launchpad.net/lxml/+bug/1960668
"""
env = etree.fromstring('<xml></xml>')
sig = xmlsec.template.create(
env,
xmlsec.Transform.EXCL_C14N,
xmlsec.Transform.RSA_SHA256,
ns="ds"
)

ds = etree.QName(sig).namespace
cm = sig.find(".//{%s}CanonicalizationMethod" % ds)

self.assertIsNotNone(cm)

def testValidateXML(self):
"""
Tests the validate_xml method of the OneLogin_Saml2_XML
Expand Down