diff options
author | Roland Hedberg <roland@catalogix.se> | 2016-08-01 16:36:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-01 16:36:02 +0200 |
commit | fd7a4f694b137a92f2a8b7f502d51fc21e3528c7 (patch) | |
tree | 8c0ec8fd23a51b58a7218ad5eb8536056a1729ac | |
parent | 96170033ecf95aa86d3421f3f2b55233fdab7548 (diff) | |
parent | 43f84cd6331a510d1a3e1eeb64f116f37f7215c1 (diff) | |
download | pysaml2-fd7a4f694b137a92f2a8b7f502d51fc21e3528c7.tar.gz |
Merge pull request #348 from j3hyde/master
Fixes xmlsec output line parsing on CRLF platforms (e.g. Windows).
-rw-r--r-- | src/saml2/algsupport.py | 2 | ||||
-rw-r--r-- | src/saml2/sigver.py | 2 | ||||
-rw-r--r-- | tests/test_40_sigver.py | 13 |
3 files changed, 15 insertions, 2 deletions
diff --git a/src/saml2/algsupport.py b/src/saml2/algsupport.py index a2d32135..f9bc06b8 100644 --- a/src/saml2/algsupport.py +++ b/src/saml2/algsupport.py @@ -42,7 +42,7 @@ def get_algorithm_support(xmlsec): pof.wait() if not p_err: - p = p_out.split('\n') + p = p_out.splitlines() algs = [x.strip('"') for x in p[1].split(',')] digest = [] signing = [] diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py index 30be593e..095a79c8 100644 --- a/src/saml2/sigver.py +++ b/src/saml2/sigver.py @@ -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": diff --git a/tests/test_40_sigver.py b/tests/test_40_sigver.py index 801454d7..e2ba952f 100644 --- a/tests/test_40_sigver.py +++ b/tests/test_40_sigver.py @@ -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() |