def _create_trust(self): if not CONF.engine.use_trusts: return trust_id = self._environment.system_attributes.get('TrustId') if not trust_id: trust_id = auth_utils.create_trust(self._environment.token, self._environment.tenant_id) self._environment.system_attributes['TrustId'] = trust_id self._environment.trust_id = trust_id
def _create_trust(self): if not CONF.engine.use_trusts: return trust_id = self._session.system_attributes.get('TrustId') if not trust_id: trust_id = auth_utils.create_trust(self._session.token, self._session.project_id) self._session.system_attributes['TrustId'] = trust_id self._session.trust_id = trust_id
def _create_trust(self): if not CONF.engine.use_trusts: return trust_id = self._session.system_attributes.get('TrustId') if not trust_id: trust_id = auth_utils.create_trust( self._session.token, self._session.project_id) self._session.system_attributes['TrustId'] = trust_id self._session.trust_id = trust_id
def my_post_data(environment_id, session_id, data, path, request): if path: path = '/services/' + path else: path = '/services' unit = db_session.get_session() model = unit.query(models.Session).get(session_id) if model is None: msg = _('Session is not found') LOG.error(msg) raise exc.HTTPNotFound(explanation=msg) if path == '/services': env_description = model.description['Objects'] if 'services' not in env_description: env_description['services'] = [] if isinstance(data, list): common_utils.TraverseHelper.extend(path, data, env_description) else: common_utils.TraverseHelper.insert(path, data, env_description) session = models.Session() session.environment_id = model.environment_id session.user_id = model.user_id session.state = states.EnvironmentStatus.PENDING session.version = 2 session.description = model.description session.description['Objects'] = env_description session.id = uuidutils.generate_uuid() session.description['SystemData']= {} session.description['SystemData']['SessionId'] = session.id session.description['SystemData']['TrustId'] = auth_utils.create_trust(request.context.auth_token, request.context.tenant) session.description['SystemData']['UserId'] = request.context.user session.description['SystemData']['Tenant'] = request.context.tenant session.description['SystemData']['Token'] = request.context.auth_token # TODO: alloc long-term token with unit.begin(): unit.add(session) session.save(unit) return data
def test_create_trust(self, mock_create_ks_admin_client, mock_create_ks_client): mock_auth_ref = mock.Mock(user_id=mock.sentinel.trustor_user, project_id=mock.sentinel.project_id, role_names=mock.sentinel.role_names) mock_admin_session = mock.Mock(**{ 'auth.get_user_id.return_value': mock.sentinel.trustee_user }) mock_user_session = mock.Mock(**{ 'auth.get_access.return_value': mock_auth_ref }) mock_trust = mock.Mock(id=mock.sentinel.trust_id) mock_admin_client = mock.Mock(session=mock_admin_session) mock_user_client = mock.Mock( session=mock_user_session, **{'trusts.create.return_value': mock_trust}) mock_create_ks_admin_client.return_value = mock_admin_client mock_create_ks_client.return_value = mock_user_client trust_id = auth_utils.create_trust( trustee_token=mock.sentinel.trustee_token, trustee_project_id=mock.sentinel.trustee_project_id) self.assertEqual(mock.sentinel.trust_id, trust_id) mock_create_ks_admin_client.assert_called_once_with() mock_create_ks_client.assert_called_once_with( token=mock.sentinel.trustee_token, project_id=mock.sentinel.trustee_project_id) mock_admin_client.session.auth.get_user_id.assert_called_once_with( mock_admin_session) mock_user_client.session.auth.get_access.assert_called_once_with( mock_user_session) mock_user_client.trusts.create.assert_called_once_with( trustor_user=mock.sentinel.trustor_user, trustee_user=mock.sentinel.trustee_user, impersonation=True, role_names=mock.sentinel.role_names, project=mock.sentinel.project_id)