Fix issue in test_forbidden_action_exposure.

Updates the test_forbidden_action_exposure in test_exception.py
so that it no longer tries to raise an incorrectly formed
ForbiddenAction exception when CONF.debug = False.

ForbiddenAction exception *should* have all kwargs specified even if
a message is set because in non-debug mode only exception formatting gets used.

Previously this test would pass because exception.py handled all
exception format errors. While handling exception formatting errors is
Okay at runtime ideally we want to check for them when running tests.

This commit also enhances the test_forbidden_action_exposure so that it
checks for the existence of the 'action' in the exception message...
where the 'message' should be absent.

Change-Id: I47d16405254c14655c64e4587530c29ba15ab80c
This commit is contained in:
Dan Prince 2013-01-09 13:34:35 -05:00
parent 2c1785add4
commit 24f21f5b55

View File

@ -114,10 +114,11 @@ class SecurityErrorTestCase(ExceptionTestCase):
CONF.debug = False
risky_info = uuid.uuid4().hex
e = exception.ForbiddenAction(message=risky_info)
action = uuid.uuid4().hex
e = exception.ForbiddenAction(message=risky_info, action=action)
self.assertValidJsonRendering(e)
self.assertNotIn(risky_info, str(e))
self.assertIn(action, str(e))
e = exception.ForbiddenAction(action=risky_info)
self.assertValidJsonRendering(e)