'Test create_trust_context when creating a trust.'

def _test_create_trust_context_trust_create(self, delegate_roles=None):

    class MockTrust(object, ):
        id = 'atrust123'
    self._stub_admin_auth()
    (mock_ks_auth, mock_auth_ref) = self._stubs_auth(user_id='5678', project_id='42', stub_trust_context=True)
    cfg.CONF.set_override('deferred_auth_method', 'trusts')
    if delegate_roles:
        cfg.CONF.set_override('trusts_delegated_roles', delegate_roles)
    trustor_roles = ['heat_stack_owner', 'admin', '__member__']
    trustee_roles = (delegate_roles or trustor_roles)
    self.mock_ks_v3_client.trusts = self.m.CreateMockAnything()
    mock_auth_ref.user_id = '5678'
    mock_auth_ref.project_id = '42'
    self.mock_ks_v3_client.trusts = self.m.CreateMockAnything()
    self.mock_ks_v3_client.trusts.create(trustor_user='5678', trustee_user='1234', project='42', impersonation=True, role_names=trustee_roles).AndReturn(MockTrust())
    self.m.ReplayAll()
    ctx = utils.dummy_context(roles=trustor_roles)
    ctx.trust_id = None
    heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
    trust_context = heat_ks_client.create_trust_context()
    self.assertEqual('atrust123', trust_context.trust_id)
    self.assertEqual('5678', trust_context.trustor_user_id)
