Fixing issue around error messages not being populated

The super constructor was getting called with a message of None and
ignoring all of the remaining lines within the constructor that derive
the correct message.

(edit) Removing CR dependency

Change-Id: Iad34da64c03db6a3c9759c00edf7b3b7ae53f0b4
Closes-Bug: #1269594
This commit is contained in:
John Vrbanac 2014-01-16 21:21:04 -06:00
parent 95a335d98d
commit 4dd0b7b1c1
2 changed files with 13 additions and 1 deletions

View File

@ -40,7 +40,6 @@ class BarbicanException(Exception):
message = _("An unknown exception occurred")
def __init__(self, message=None, *args, **kwargs):
super(BarbicanException, self).__init__(message)
if not message:
message = self.message
try:
@ -51,6 +50,7 @@ class BarbicanException(Exception):
else:
# at least get the core message out if something happened
pass
super(BarbicanException, self).__init__(message)
class MissingArgumentError(BarbicanException):

View File

@ -192,6 +192,18 @@ class WhenTestingSecretValidator(unittest.TestCase):
with self.assertRaises(excep.InvalidObject):
self.validator.validate(self.secret_req)
def test_should_fail_with_message_w_bad_payload_content_type(self):
self.secret_req['payload_content_type'] = 'plain/text'
try:
self.validator.validate(self.secret_req)
except excep.InvalidObject as e:
self.assertNotEqual(str(e), 'None')
self.assertIsNotNone(e.message)
self.assertNotEqual(e.message, 'None')
else:
self.fail('No validation exception was raised')
def test_should_fail_with_plain_text_and_encoding(self):
self.secret_req['payload_content_encoding'] = 'base64'