capture errors from libxml2

fixes #4
This commit is contained in:
Ross Kinder
2015-12-23 17:17:48 -05:00
parent c095422255
commit dc37ddb368
6 changed files with 48 additions and 25 deletions

View File

@@ -95,7 +95,7 @@ func (testSuite *XmlencRealWorldTest) TestInvalid(c *C) {
c.Assert(err, IsNil)
_, err = Decrypt(testSuite.Key, []byte("<invalid xml"))
c.Assert(err, ErrorMatches, "malformed XML")
c.Assert(err, ErrorMatches, ".*Couldn't find end of Start Tag.*")
_, err = Decrypt(testSuite.Key, []byte("<invalid></invalid>"))
c.Assert(err, ErrorMatches, "xmlSecFindNode cannot find EncryptedData node")
@@ -105,7 +105,7 @@ func (testSuite *XmlencRealWorldTest) TestInvalid(c *C) {
docStr := []byte(`<?xml version="1.0" encoding="UTF-8"?><saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" Destination="https://15661444.ngrok.io/saml2/acs" ID="_59c2431b4916af2018984213940ee675" InResponseTo="id-3d21faf29a101222d740735fa512f161" IssueInstant="2015-11-29T21:29:09.991Z" Version="2.0"><saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://idp.testshib.org/idp/shibboleth</saml2:Issuer><saml2p:Status><saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/></saml2p:Status><saml2:EncryptedAssertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"><xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="_62d64ca491a287a346272669fbe93191" Type="http://www.w3.org/2001/04/xmlenc#Element">invalid<`)
_, err = Decrypt(testSuite.Key, docStr)
c.Assert(err, ErrorMatches, "malformed XML")
c.Assert(err, ErrorMatches, ".*Premature end of data in tag.*")
docStr = []byte(`<?xml version="1.0" encoding="UTF-8"?>
<X>