Skip to content

Commit b276d7b

Browse files
Merge pull request #926 from amit12297/fix_assertion_sigver_fail_error_log
Set error log message when assertion signature verification fails
2 parents cae1326 + 8a12088 commit b276d7b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/saml2/response.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ def _assertion(self, assertion, verified=False):
791791
try:
792792
self.sec.check_signature(assertion, class_name(assertion), self.xmlstr)
793793
except Exception as exc:
794-
logger.error("correctly_signed_response: %s", exc)
794+
logger.error("The signature on the assertion cannot be verified.")
795+
logger.debug("correctly_signed_response: %s", exc)
795796
raise
796797

797798
self.assertion = assertion

tests/test_41_response.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
2+
import logging
33
from contextlib import closing
44
import datetime
55
from unittest.mock import Mock
@@ -125,7 +125,8 @@ def test_issuer_none(self):
125125
assert resp.issuer() == ""
126126

127127
@patch("saml2.time_util.datetime")
128-
def test_false_sign(self, mock_datetime):
128+
def test_false_sign(self, mock_datetime, caplog):
129+
caplog.set_level(logging.ERROR)
129130
mock_datetime.utcnow = Mock(return_value=datetime.datetime(2016, 9, 4, 9, 59, 39))
130131
with open(FALSE_ASSERT_SIGNED) as fp:
131132
xml_response = fp.read()
@@ -145,6 +146,7 @@ def test_false_sign(self, mock_datetime):
145146
assert isinstance(resp, AuthnResponse)
146147
with raises(SignatureError):
147148
resp.verify()
149+
assert 'The signature on the assertion cannot be verified.' in caplog.text
148150

149151
def test_other_response(self):
150152
with open(full_path("attribute_response.xml")) as fp:

0 commit comments

Comments
 (0)