'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.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
    keystone.KeystoneClientPlugin._create().AndReturn(fakes.FakeKeystoneClient(user_id='auser123'))
    keystone.KeystoneClientPlugin._create().AndReturn(fakes.FakeKeystoneClient(user_id='auser123'))
    self.m.ReplayAll()
    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)
