summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Stanek <dstanek@dstanek.com>2014-10-03 18:52:54 +0000
committerDolph Mathews <dolph.mathews@gmail.com>2014-10-06 14:33:41 +0000
commit4ae1879a79e338e7323935fd17896ba8a4e84fb9 (patch)
tree369e6149727cfa7716290a28aa09a276665a2b01
parent5caf29ad5d90a65d3b10dc55bb101c96b543e4f8 (diff)
downloadkeystone-4ae1879a79e338e7323935fd17896ba8a4e84fb9.tar.gz
Validates controller methods exist when specified
It was possible to specify an invalid controller method in a router. This will not cause an error until runtime. This change catches the error much earlier in the application lifecycle. In fact with this change errors should not be able to pass unit tests even if there is no specific test for the behavior. Related-bug: #1377304 Change-Id: Icc5646c143a234127a8b4ac8a74342ef3dca7e80
-rw-r--r--keystone/common/wsgi.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py
index 693b5bef1..7d1d06d1a 100644
--- a/keystone/common/wsgi.py
+++ b/keystone/common/wsgi.py
@@ -640,27 +640,35 @@ class RoutersBase(object):
delete_action=None, get_post_action=None,
path_vars=None):
if get_head_action:
+ getattr(controller, get_head_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=get_head_action,
conditions=dict(method=['GET', 'HEAD']))
if get_action:
+ getattr(controller, get_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=get_action,
conditions=dict(method=['GET']))
if head_action:
+ getattr(controller, head_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=head_action,
conditions=dict(method=['HEAD']))
if put_action:
+ getattr(controller, put_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=put_action,
conditions=dict(method=['PUT']))
if post_action:
+ getattr(controller, post_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=post_action,
conditions=dict(method=['POST']))
if patch_action:
+ getattr(controller, patch_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=patch_action,
conditions=dict(method=['PATCH']))
if delete_action:
+ getattr(controller, delete_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=delete_action,
conditions=dict(method=['DELETE']))
if get_post_action:
+ getattr(controller, get_post_action) # ensure the attribute exists
mapper.connect(path, controller=controller, action=get_post_action,
conditions=dict(method=['GET', 'POST']))