Fix logging in federation/idp.py
The existing code would raise a TypeError exception: TypeError: Message objects do not support addition. This is because oslo.i18n Message objects do not support the + operator and instead require substitution to be used. Closes-Bug: 1484735 Change-Id: I65e093808b243d8eff5b3cefdf6d64c3d7216801
This commit is contained in:
parent
e16aa8e5e5
commit
82bddf17cd
|
@ -426,11 +426,10 @@ def _sign_assertion(assertion):
|
|||
stdout = subprocess.check_output(command_list,
|
||||
stderr=subprocess.STDOUT)
|
||||
except Exception as e:
|
||||
msg = _LE('Error when signing assertion, reason: %(reason)s')
|
||||
msg = msg % {'reason': e}
|
||||
if hasattr(e, 'output'):
|
||||
msg += ' output: %(output)s' % {'output': e.output}
|
||||
LOG.error(msg)
|
||||
msg = _LE('Error when signing assertion, reason: %(reason)s%(output)s')
|
||||
LOG.error(msg,
|
||||
{'reason': e,
|
||||
'output': ' ' + e.output if hasattr(e, 'output') else ''})
|
||||
raise exception.SAMLSigningError(reason=e)
|
||||
finally:
|
||||
try:
|
||||
|
|
|
@ -3451,12 +3451,15 @@ class SAMLGenerationTests(FederationTests):
|
|||
returncode=sample_returncode, cmd=CONF.saml.xmlsec1_binary,
|
||||
output=sample_output)
|
||||
|
||||
# FIXME(blk-u): This should raise exception.SAMLSigningError instead,
|
||||
# but fails with TypeError due to concatenating string to Message, see
|
||||
# bug 1484735.
|
||||
self.assertRaises(TypeError,
|
||||
logger_fixture = self.useFixture(fixtures.LoggerFixture())
|
||||
self.assertRaises(exception.SAMLSigningError,
|
||||
keystone_idp._sign_assertion,
|
||||
self.signed_assertion)
|
||||
expected_log = (
|
||||
"Error when signing assertion, reason: Command '%s' returned "
|
||||
"non-zero exit status %s %s\n" %
|
||||
(CONF.saml.xmlsec1_binary, sample_returncode, sample_output))
|
||||
self.assertEqual(expected_log, logger_fixture.output)
|
||||
|
||||
@mock.patch('oslo_utils.fileutils.write_to_tempfile')
|
||||
def test__sign_assertion_fileutils_exc(self, write_to_tempfile_mock):
|
||||
|
|
Loading…
Reference in New Issue