Fixes xmlsec output line parsing on CRLF platforms (e.g. Windows).

This commit is contained in:
Jeff Kyllo
2016-08-01 13:27:16 +01:00
parent 96170033ec
commit cc048286a1
2 changed files with 14 additions and 1 deletions

View File

@@ -586,7 +586,7 @@ def parse_xmlsec_output(output):
:param output: The output from Popen
:return: A boolean; True if the command was a success otherwise False
"""
for line in output.split("\n"):
for line in output.splitlines():
if line == "OK":
return True
elif line == "FAIL":

View File

@@ -540,6 +540,19 @@ def test_sha256_signing():
assert s
def test_xmlsec_output_line_parsing():
output1 = "prefix\nOK\npostfix"
assert sigver.parse_xmlsec_output(output1)
output2 = "prefix\nFAIL\npostfix"
raises(sigver.XmlsecError, sigver.parse_xmlsec_output, output2)
output3 = "prefix\r\nOK\r\npostfix"
assert sigver.parse_xmlsec_output(output3)
output4 = "prefix\r\nFAIL\r\npostfix"
raises(sigver.XmlsecError, sigver.parse_xmlsec_output, output4)
if __name__ == "__main__":
# t = TestSecurity()