summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-10-09 16:00:36 +0000
committerGerrit Code Review <review@openstack.org>2013-10-09 16:00:36 +0000
commit102b8677fd787998cc28809d56a7319832abb557 (patch)
tree5c64bb45d71a5b0fe2465e039e83dce0e8b19c60
parente9fb6c7c8f5e37a5b94141bcd5b94fcacf41c075 (diff)
parent8a036c3f76f0d0ae4cb4c57f902a5e6b90baa9c9 (diff)
downloadpython-keystoneclient-102b8677fd787998cc28809d56a7319832abb557.tar.gz
Merge "Fix H202 assertRaises Exception"
-rw-r--r--keystoneclient/middleware/auth_token.py9
-rw-r--r--keystoneclient/tests/test_auth_token_middleware.py15
-rw-r--r--keystoneclient/tests/v3/test_endpoints.py8
-rw-r--r--keystoneclient/v3/endpoints.py3
-rw-r--r--tox.ini3
5 files changed, 23 insertions, 15 deletions
diff --git a/keystoneclient/middleware/auth_token.py b/keystoneclient/middleware/auth_token.py
index cd89cf1..52605f4 100644
--- a/keystoneclient/middleware/auth_token.py
+++ b/keystoneclient/middleware/auth_token.py
@@ -462,11 +462,12 @@ class AuthProtocol(object):
def _assert_valid_memcache_protection_config(self):
if self._memcache_security_strategy:
if self._memcache_security_strategy not in ('MAC', 'ENCRYPT'):
- raise Exception('memcache_security_strategy must be '
- 'ENCRYPT or MAC')
+ raise ConfigurationError('memcache_security_strategy must be '
+ 'ENCRYPT or MAC')
if not self._memcache_secret_key:
- raise Exception('mecmache_secret_key must be defined when '
- 'a memcache_security_strategy is defined')
+ raise ConfigurationError('mecmache_secret_key must be defined '
+ 'when a memcache_security_strategy '
+ 'is defined')
def _init_cache(self, env):
cache = self._conf_get('cache')
diff --git a/keystoneclient/tests/test_auth_token_middleware.py b/keystoneclient/tests/test_auth_token_middleware.py
index 25ff514..afc717d 100644
--- a/keystoneclient/tests/test_auth_token_middleware.py
+++ b/keystoneclient/tests/test_auth_token_middleware.py
@@ -771,31 +771,36 @@ class CommonAuthTokenMiddlewareTest(object):
'memcached_servers': ['localhost:11211'],
'memcache_security_strategy': 'Encrypt'
}
- self.assertRaises(Exception, self.set_middleware, conf=conf)
+ self.assertRaises(auth_token.ConfigurationError, self.set_middleware,
+ conf=conf)
# test invalue memcache_security_strategy
conf = {
'memcached_servers': ['localhost:11211'],
'memcache_security_strategy': 'whatever'
}
- self.assertRaises(Exception, self.set_middleware, conf=conf)
+ self.assertRaises(auth_token.ConfigurationError, self.set_middleware,
+ conf=conf)
# test missing memcache_secret_key
conf = {
'memcached_servers': ['localhost:11211'],
'memcache_security_strategy': 'mac'
}
- self.assertRaises(Exception, self.set_middleware, conf=conf)
+ self.assertRaises(auth_token.ConfigurationError, self.set_middleware,
+ conf=conf)
conf = {
'memcached_servers': ['localhost:11211'],
'memcache_security_strategy': 'Encrypt',
'memcache_secret_key': ''
}
- self.assertRaises(Exception, self.set_middleware, conf=conf)
+ self.assertRaises(auth_token.ConfigurationError, self.set_middleware,
+ conf=conf)
conf = {
'memcached_servers': ['localhost:11211'],
'memcache_security_strategy': 'mAc',
'memcache_secret_key': ''
}
- self.assertRaises(Exception, self.set_middleware, conf=conf)
+ self.assertRaises(auth_token.ConfigurationError, self.set_middleware,
+ conf=conf)
def test_config_revocation_cache_timeout(self):
conf = {
diff --git a/keystoneclient/tests/v3/test_endpoints.py b/keystoneclient/tests/v3/test_endpoints.py
index 6734523..050a646 100644
--- a/keystoneclient/tests/v3/test_endpoints.py
+++ b/keystoneclient/tests/v3/test_endpoints.py
@@ -14,6 +14,7 @@
import uuid
+from keystoneclient import exceptions
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import endpoints
@@ -49,7 +50,7 @@ class EndpointTests(utils.TestCase, utils.CrudTests):
def test_create_invalid_interface(self):
ref = self.new_ref(interface=uuid.uuid4().hex)
- self.assertRaises(Exception, self.manager.create,
+ self.assertRaises(exceptions.ValidationError, self.manager.create,
**utils.parameterize(ref))
def test_update_public_interface(self):
@@ -66,7 +67,8 @@ class EndpointTests(utils.TestCase, utils.CrudTests):
def test_update_invalid_interface(self):
ref = self.new_ref(interface=uuid.uuid4().hex)
- self.assertRaises(Exception, self.manager.update,
+ ref['endpoint'] = "fake_endpoint"
+ self.assertRaises(exceptions.ValidationError, self.manager.update,
**utils.parameterize(ref))
def test_list_public_interface(self):
@@ -87,5 +89,5 @@ class EndpointTests(utils.TestCase, utils.CrudTests):
def test_list_invalid_interface(self):
interface = uuid.uuid4().hex
expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
- self.assertRaises(Exception, self.manager.list,
+ self.assertRaises(exceptions.ValidationError, self.manager.list,
expected_path=expected_path, interface=interface)
diff --git a/keystoneclient/v3/endpoints.py b/keystoneclient/v3/endpoints.py
index 7030d28..4950fa5 100644
--- a/keystoneclient/v3/endpoints.py
+++ b/keystoneclient/v3/endpoints.py
@@ -15,6 +15,7 @@
# under the License.
from keystoneclient import base
+from keystoneclient import exceptions
VALID_INTERFACES = ['public', 'admin', 'internal']
@@ -45,7 +46,7 @@ class EndpointManager(base.CrudManager):
if interface is not None and interface not in VALID_INTERFACES:
msg = '"interface" must be one of: %s'
msg = msg % ', '.join(VALID_INTERFACES)
- raise Exception(msg)
+ raise exceptions.ValidationError(msg)
def create(self, service, url, interface=None, region=None, enabled=True,
**kwargs):
diff --git a/tox.ini b/tox.ini
index bc0144a..c41c8b8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -27,9 +27,8 @@ commands = python setup.py testr --coverage --testr-args='{posargs}'
downloadcache = ~/cache/pip
[flake8]
-# H202: assertRaises Exception too broad
# F821: undefined name
# H304: no relative imports
-ignore = F821,H202,H304
+ignore = F821,H304
show-source = True
exclude = .venv,.tox,dist,doc,*egg,build