Store tenant with trust details in user_creds

Currently we don't store tenant name/ID to user_creds when a trust_id
is found in the context.  However as mentioned in bug #1231483 keystone
currently requires the tenant_id when re-scoping a token to a trust via
the v2 tokens API.

Change-Id: I5bd9cb914a8c9365ed30ece8e0a61ba1e0a3c4bc
Partial-Bug: #1227901
This commit is contained in:
Steven Hardy 2013-09-27 11:11:59 +01:00
parent e3c59c10bb
commit 01d6ce3858
2 changed files with 6 additions and 2 deletions

View File

@ -282,6 +282,8 @@ def user_creds_create(context):
user_creds_ref.trustor_user_id = values.get('trustor_user_id')
user_creds_ref.username = None
user_creds_ref.password = None
user_creds_ref.tenant = values.get('tenant')
user_creds_ref.tenant_id = values.get('tenant_id')
else:
user_creds_ref.update(values)
user_creds_ref.password = _encrypt(values['password'])

View File

@ -318,15 +318,17 @@ class SqlAlchemyTest(HeatTestCase):
self.ctx.password = None
self.ctx.trust_id = 'atrust123'
self.ctx.trustor_user_id = 'atrustor123'
self.ctx.tenant_id = 'atenant123'
self.ctx.tenant = 'atenant'
db_creds = db_api.user_creds_create(self.ctx)
load_creds = db_api.user_creds_get(db_creds.id)
self.assertIsNone(load_creds.get('username'))
self.assertIsNone(load_creds.get('password'))
self.assertIsNone(load_creds.get('tenant'))
self.assertIsNone(load_creds.get('tenant_id'))
self.assertIsNotNone(load_creds.get('created_at'))
self.assertIsNone(load_creds.get('updated_at'))
self.assertIsNone(load_creds.get('auth_url'))
self.assertEqual(load_creds.get('tenant_id'), 'atenant123')
self.assertEqual(load_creds.get('tenant'), 'atenant')
self.assertEqual(load_creds.get('trust_id'), 'atrust123')
self.assertEqual(load_creds.get('trustor_user_id'), 'atrustor123')