Skip to content

Commit

Permalink
Fix xmlsec#244 - Fix failing test with libxmlsec-1.2.36, also make li…
Browse files Browse the repository at this point in the history
…bxmlsec version available from Python.
  • Loading branch information
tdivis committed Mar 22, 2023
1 parent 519feff commit b0f48a3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ static PyObject* PyXmlSec_PyShutdown(PyObject* self) {
Py_RETURN_NONE;
}

static char PyXmlSec_GetLibXmlSecVersion__doc__[] = \
"get_libxmlsec_version() -> tuple\n"
"Returns Version tuple of wrapped libxml library.";
static PyObject* PyXmlSec_GetLibXmlSecVersion() {
return Py_BuildValue("(iii)", XMLSEC_VERSION_MAJOR, XMLSEC_VERSION_MINOR, XMLSEC_VERSION_SUBMINOR);
}

static char PyXmlSec_PyEnableDebugOutput__doc__[] = \
"enable_debug_trace(enabled) -> None\n"
"Enables or disables calling LibXML2 callback from the default errors callback.\n\n"
Expand Down Expand Up @@ -386,6 +393,12 @@ static PyMethodDef PyXmlSec_MainMethods[] = {
METH_NOARGS,
PyXmlSec_PyShutdown__doc__
},
{
"get_libxmlsec_version",
(PyCFunction)PyXmlSec_GetLibXmlSecVersion,
METH_NOARGS,
PyXmlSec_GetLibXmlSecVersion__doc__
},
{
"enable_debug_trace",
(PyCFunction)PyXmlSec_PyEnableDebugOutput,
Expand Down
4 changes: 2 additions & 2 deletions tests/data/sign5-out.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ MA0GCSqGSIb3DQEBBAUAA4GBALU/mzIxSv8vhDuomxFcplzwdlLZbvSQrfoNkMGY
1UoS3YJrN+jZLWKSyWE3mIaPpElqXiXQGGkwD5iPQ1iJMbI7BeLvx6ZxX/f+c8Wn
ss0uc1NxfahMaBoyG15IL4+beqO182fosaKJTrJNG3mc//ANGU9OsQM9mfBEt4oL
NJ2D</X509Certificate>
<X509SubjectName>[email protected],CN=Aleksey Sanin,OU=Examples RSA Certificate,O=XML Security Library (http://www.aleksey.com/xmlsec),ST=California,C=US</X509SubjectName>
<X509SKI>JIQs8tRZIGKLLlyGkKOqMLonGpw=</X509SKI>
<X509SubjectName/>
<X509SKI/>
</X509Data>
</KeyInfo>
</Signature></Envelope>
6 changes: 5 additions & 1 deletion tests/test_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ def test_sign_case5(self):
self.assertEqual("rsakey.pem", ctx.key.name)

ctx.sign(sign)
self.assertEqual(self.load_xml("sign5-out.xml"), root)
if xmlsec.get_libxmlsec_version() >= (1, 2, 36):
expected_xml_file = 'sign5-out.xml'
else:
expected_xml_file = 'sign5-out-xmlsec_lt_1_2_36.xml'
self.assertEqual(self.load_xml(expected_xml_file), root)

def test_sign_binary_bad_args(self):
ctx = xmlsec.SignatureContext()
Expand Down

0 comments on commit b0f48a3

Please sign in to comment.