Merge "Fix formatting of ImportError"
This commit is contained in:
commit
207f34f34e
@ -78,7 +78,7 @@ def load_driver(namespace, driver_name, *args):
|
||||
return driver_manager.driver
|
||||
except stevedore.exception.NoMatches:
|
||||
msg = (_('Unable to find %(name)r driver in %(namespace)r.'))
|
||||
raise ImportError(msg, {'name': driver_name, 'namespace': namespace})
|
||||
raise ImportError(msg % {'name': driver_name, 'namespace': namespace})
|
||||
|
||||
|
||||
class _TraceMeta(type):
|
||||
|
@ -10,9 +10,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from six.moves import urllib
|
||||
|
||||
from keystone.tests import unit
|
||||
from keystone.token import provider
|
||||
from keystone.token.providers import common
|
||||
|
||||
|
||||
@ -20,3 +23,14 @@ class TestTokenProvidersCommon(unit.TestCase):
|
||||
def test_strings_are_url_safe(self):
|
||||
s = common.random_urlsafe_str()
|
||||
self.assertEqual(s, urllib.parse.quote_plus(s))
|
||||
|
||||
def test_unsupported_provider_raises_import_error(self):
|
||||
namespace = "keystone.token.provider"
|
||||
# Generate a random name
|
||||
driver = uuid.uuid4().hex
|
||||
self.config_fixture.config(group='token', provider=driver)
|
||||
msg = "Unable to find '%(driver)s' driver in '%(namespace)s'." % {
|
||||
'namespace': namespace, 'driver': driver
|
||||
}
|
||||
|
||||
self.assertRaisesRegex(ImportError, msg, provider.Manager)
|
||||
|
6
releasenotes/notes/bug-1753584-e052bc7805f001b4.yaml
Normal file
6
releasenotes/notes/bug-1753584-e052bc7805f001b4.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
[`bug 1753584 <https://bugs.launchpad.net/keystone/+bug/1753584>`_]
|
||||
Fix formatting of ImportError when using a driver not found in the list
|
||||
of token providers.
|
Loading…
Reference in New Issue
Block a user