def test_store_saves_creds_trust(self):
    'A user_creds entry is created on first stack store.'
    cfg.CONF.set_override('deferred_auth_method', 'trusts')
    self.patchobject(keystone.KeystoneClientPlugin, '_create', return_value=fake_ks.FakeKeystoneClient(user_id='auser123'))
    self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
    self.stack.store()
    db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
    user_creds_id = db_stack.user_creds_id
    self.assertIsNotNone(user_creds_id)
    user_creds = ucreds_object.UserCreds.get_by_id(self.ctx, user_creds_id)
    self.assertIsNone(user_creds.get('username'))
    self.assertIsNone(user_creds.get('password'))
    self.assertEqual('atrust', user_creds.get('trust_id'))
    self.assertEqual('auser123', user_creds.get('trustor_user_id'))
    auth = self.patchobject(context.RequestContext, 'trusts_auth_plugin')
    self.patchobject(auth, 'get_access', return_value=fakes.FakeAccessInfo([], None, None))
    expected_context = context.RequestContext(trust_id='atrust', trustor_user_id='auser123', request_id=self.ctx.request_id, is_admin=False).to_dict()
    stored_context = self.stack.stored_context().to_dict()
    self.assertEqual(expected_context, stored_context)
    self.stack.store()
    self.assertEqual(user_creds_id, db_stack.user_creds_id)
    keystone.KeystoneClientPlugin._create.assert_called_with()
A user_creds entry is created on first stack store.
def test_store_saves_creds_trust(self):
    
    cfg.CONF.set_override('deferred_auth_method', 'trusts')
    self.patchobject(keystone.KeystoneClientPlugin, '_create', return_value=fake_ks.FakeKeystoneClient(user_id='auser123'))
    self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
    self.stack.store()
    db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
    user_creds_id = db_stack.user_creds_id
    self.assertIsNotNone(user_creds_id)
    user_creds = ucreds_object.UserCreds.get_by_id(self.ctx, user_creds_id)
    self.assertIsNone(user_creds.get('username'))
    self.assertIsNone(user_creds.get('password'))
    self.assertEqual('atrust', user_creds.get('trust_id'))
    self.assertEqual('auser123', user_creds.get('trustor_user_id'))
    auth = self.patchobject(context.RequestContext, 'trusts_auth_plugin')
    self.patchobject(auth, 'get_access', return_value=fakes.FakeAccessInfo([], None, None))
    expected_context = context.RequestContext(trust_id='atrust', trustor_user_id='auser123', request_id=self.ctx.request_id, is_admin=False).to_dict()
    stored_context = self.stack.stored_context().to_dict()
    self.assertEqual(expected_context, stored_context)
    self.stack.store()
    self.assertEqual(user_creds_id, db_stack.user_creds_id)
    keystone.KeystoneClientPlugin._create.assert_called_with()