Add deprecated context parameters to the new security context
In the recent parameter migration, a number of parameters were
incorrectly deprecated. They were not redirected to the new location
correctly and would cause an error.
Change-Id: I5ea09c3c79df5a43b06194a48f7425a15a1b23cf
Closes-Bug: #1728081
(cherry picked from commit e195c6d90f
)
This commit is contained in:
parent
b5e6b22ba9
commit
90457d594a
|
@ -61,7 +61,8 @@ class SecurityContext(object):
|
|||
def __init__(self, auth_uri=None, auth_cacert=None, insecure=None,
|
||||
service_catalog=None, region_name=None, is_trust_scoped=None,
|
||||
redelivered=None, expires_at=None, trust_id=None,
|
||||
is_target=None):
|
||||
is_target=None, project_id=None, project_name=None,
|
||||
user_name=None, auth_token=None):
|
||||
self.auth_uri = auth_uri
|
||||
self.auth_cacert = auth_cacert
|
||||
self.insecure = insecure
|
||||
|
@ -72,6 +73,10 @@ class SecurityContext(object):
|
|||
self.expires_at = expires_at
|
||||
self.trust_id = trust_id
|
||||
self.is_target = is_target
|
||||
self.project_id = project_id
|
||||
self.project_name = project_name
|
||||
self.user_name = user_name
|
||||
self.auth_token = auth_token
|
||||
|
||||
|
||||
class ExecutionContext(object):
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from mistral_lib import actions
|
||||
from mistral_lib.actions import context
|
||||
from mistral_lib.tests import base as tests_base
|
||||
|
||||
|
||||
|
@ -24,8 +25,8 @@ class TestAction(actions.Action):
|
|||
|
||||
class TestActionsBase(tests_base.TestCase):
|
||||
|
||||
def test_run(self):
|
||||
context = {"name": "test"}
|
||||
def test_run_empty_context(self):
|
||||
ctx = context.ActionContext()
|
||||
action = TestAction()
|
||||
result = action.run(context)
|
||||
assert result == context
|
||||
result = action.run(ctx)
|
||||
assert result == ctx
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from mistral_lib.actions import context
|
||||
from mistral_lib.tests import base as tests_base
|
||||
|
||||
|
||||
def _fake_context():
|
||||
security_ctx = context.SecurityContext(
|
||||
auth_uri='auth_uri',
|
||||
auth_cacert='auth_cacert',
|
||||
insecure='insecure',
|
||||
service_catalog='service_catalog',
|
||||
region_name='region_name',
|
||||
is_trust_scoped='is_trust_scoped',
|
||||
redelivered='redelivered',
|
||||
expires_at='expires_at',
|
||||
trust_id='trust_id',
|
||||
is_target='is_target',
|
||||
project_id='project_id')
|
||||
|
||||
execution_ctx = context.ExecutionContext(
|
||||
workflow_execution_id='workflow_execution_id',
|
||||
task_id='task_id',
|
||||
action_execution_id='action_execution_id',
|
||||
workflow_name='workflow_name',
|
||||
callback_url='callback_url')
|
||||
|
||||
ctx = context.ActionContext(security_ctx, execution_ctx)
|
||||
return ctx
|
||||
|
||||
|
||||
class TestActionsBase(tests_base.TestCase):
|
||||
|
||||
def test_empty_context(self):
|
||||
|
||||
ctx = context.ActionContext(
|
||||
context.SecurityContext(),
|
||||
context.ExecutionContext()
|
||||
)
|
||||
|
||||
self.assertIsInstance(ctx.security, context.SecurityContext)
|
||||
self.assertIsInstance(ctx.execution, context.ExecutionContext)
|
||||
|
||||
self.assertEqual(ctx.security.auth_uri, None)
|
||||
self.assertEqual(ctx.execution.workflow_name, None)
|
||||
|
||||
def test_deprecated_properties(self):
|
||||
|
||||
ctx = _fake_context()
|
||||
|
||||
deprecated_properties = [
|
||||
"auth_uri", "user_name", "auth_token", "project_name",
|
||||
"project_id", "insecure"
|
||||
]
|
||||
|
||||
for deprecated in deprecated_properties:
|
||||
old = getattr(ctx, deprecated)
|
||||
new = getattr(ctx.security, deprecated)
|
||||
self.assertEqual(old, new)
|
Loading…
Reference in New Issue