Fix heat-api-cfn 500 error on an unknown action

Add a default function in heat-api-cfn StackController, and raise
an HeatActionNotSupported exception.

Change-Id: I9023817792e949bde558dd22e818f38d6185f0fd
Closes-Bug: #1473083
This commit is contained in:
zhufeng 2015-08-20 13:58:10 +08:00
parent 795b954b58
commit 5c3607cdb1
2 changed files with 7 additions and 0 deletions

View File

@ -48,6 +48,9 @@ class StackController(object):
self.rpc_client = rpc_client.EngineClient()
self.policy = policy.Enforcer(scope='cloudformation')
def default(self, req, **args):
raise exception.HeatInvalidActionError()
def _enforce(self, req, action):
"""Authorize an action against the policy.json."""
try:

View File

@ -62,6 +62,10 @@ class CfnStackControllerTest(common.HeatTestCase):
'deny_stack_user.json')
self.addCleanup(self.m.VerifyAll)
def test_default(self):
self.assertRaises(
exception.HeatInvalidActionError, self.controller.default, None)
def tearDown(self):
super(CfnStackControllerTest, self).tearDown()
cfg.CONF.unregister_opts(self.opts)