Merge "Pass user_creds_id when creating backup stack"

This commit is contained in:
Jenkins 2014-07-17 10:41:23 +00:00 committed by Gerrit Code Review
commit 14ad2e749e
2 changed files with 14 additions and 1 deletions

View File

@ -566,7 +566,8 @@ class Stack(collections.Mapping):
return self.load(self.context, stack=s)
elif create_if_missing:
prev = type(self)(self.context, self.name, copy.deepcopy(self.t),
self.env, owner_id=self.id)
self.env, owner_id=self.id,
user_creds_id=self.user_creds_id)
prev.store(backup=True)
LOG.debug('Created new backup stack')
return prev

View File

@ -3064,6 +3064,18 @@ class StackTest(HeatTestCase):
self.stack.store()
self.assertEqual(user_creds_id, db_stack.user_creds_id)
def test_backup_copies_user_creds_id(self):
ctx_init = utils.dummy_context(user='my_user',
password='my_pass')
ctx_init.request_id = self.ctx.request_id
creds = db_api.user_creds_create(ctx_init)
self.stack = parser.Stack(self.ctx, 'creds_init', self.tmpl,
user_creds_id=creds.id)
self.stack.store()
self.assertEqual(creds.id, self.stack.user_creds_id)
backup = self.stack._backup_stack()
self.assertEqual(creds.id, backup.user_creds_id)
def test_stored_context_err(self):
"""
Test stored_context error path.