Merge "Make error message clear when no supported secret store found"
This commit is contained in:
commit
d0ebc6c321
@ -77,17 +77,35 @@ class SecretStorePluginNotFound(exception.BarbicanHTTPException):
|
|||||||
|
|
||||||
|
|
||||||
class SecretStoreSupportedPluginNotFound(exception.BarbicanHTTPException):
|
class SecretStoreSupportedPluginNotFound(exception.BarbicanHTTPException):
|
||||||
"""Raised if no plugins are found that support the requested operation."""
|
"""Raised when no secret store supported plugin is found."""
|
||||||
|
|
||||||
client_message = u._("Secret store supported plugin not found.")
|
client_message = u._("Secret store supported plugin not found.")
|
||||||
status_code = 400
|
status_code = 400
|
||||||
|
|
||||||
def __init__(self, plugin_name=None):
|
def __init__(self, key_spec):
|
||||||
message = u._("Secret store plugin not found for requested operation.")
|
message = u._("Could not find a secret store plugin for storing "
|
||||||
|
"secret with algorithm '{alg}' and bit-length "
|
||||||
|
"'{len}'.").format(alg=key_spec.alg,
|
||||||
|
len=key_spec.bit_length)
|
||||||
super(SecretStoreSupportedPluginNotFound, self).__init__(
|
super(SecretStoreSupportedPluginNotFound, self).__init__(
|
||||||
message)
|
message)
|
||||||
|
|
||||||
|
|
||||||
|
class SecretGenerateSupportedPluginNotFound(exception.BarbicanHTTPException):
|
||||||
|
"""Raised when no secret generate supported plugin is found."""
|
||||||
|
|
||||||
|
client_message = u._("Secret generate supported plugin not found.")
|
||||||
|
status_code = 400
|
||||||
|
|
||||||
|
def __init__(self, key_spec):
|
||||||
|
message = u._("Could not find a secret store plugin for generating "
|
||||||
|
"secret with algorithm '{alg}' and bit-length "
|
||||||
|
"'{len}'.").format(alg=key_spec.alg,
|
||||||
|
len=key_spec.bit_length)
|
||||||
|
super(SecretGenerateSupportedPluginNotFound, self).__init__(
|
||||||
|
message)
|
||||||
|
|
||||||
|
|
||||||
class SecretContentTypeNotSupportedException(exception.BarbicanHTTPException):
|
class SecretContentTypeNotSupportedException(exception.BarbicanHTTPException):
|
||||||
"""Raised when support for payload content type is not available."""
|
"""Raised when support for payload content type is not available."""
|
||||||
|
|
||||||
@ -567,7 +585,7 @@ class SecretStorePluginManager(named.NamedExtensionManager):
|
|||||||
plugin.store_secret_supports(key_spec)):
|
plugin.store_secret_supports(key_spec)):
|
||||||
return plugin
|
return plugin
|
||||||
|
|
||||||
raise SecretStoreSupportedPluginNotFound()
|
raise SecretStoreSupportedPluginNotFound(key_spec)
|
||||||
|
|
||||||
@_enforce_extensions_configured
|
@_enforce_extensions_configured
|
||||||
def get_plugin_retrieve_delete(self, plugin_name):
|
def get_plugin_retrieve_delete(self, plugin_name):
|
||||||
@ -605,7 +623,7 @@ class SecretStorePluginManager(named.NamedExtensionManager):
|
|||||||
for plugin in active_plugins:
|
for plugin in active_plugins:
|
||||||
if plugin.generate_supports(key_spec):
|
if plugin.generate_supports(key_spec):
|
||||||
return plugin
|
return plugin
|
||||||
raise SecretStoreSupportedPluginNotFound()
|
raise SecretGenerateSupportedPluginNotFound(key_spec)
|
||||||
|
|
||||||
def _get_internal_plugin_names(self, secretstore_conf):
|
def _get_internal_plugin_names(self, secretstore_conf):
|
||||||
"""Gets plugin names used for loading via stevedore.
|
"""Gets plugin names used for loading via stevedore.
|
||||||
|
@ -185,7 +185,7 @@ class WhenTestingSecretStorePluginManager(utils.BaseTestCase):
|
|||||||
self.manager.extensions = [plugin_mock]
|
self.manager.extensions = [plugin_mock]
|
||||||
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
keySpec = str.KeySpec(str.KeyAlgorithm.AES, 128)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
str.SecretStoreSupportedPluginNotFound,
|
str.SecretGenerateSupportedPluginNotFound,
|
||||||
self.manager.get_plugin_generate,
|
self.manager.get_plugin_generate,
|
||||||
keySpec,
|
keySpec,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user