Beispiel #1
0
    def test_add_token_to_context(self):
        task_name = "create-vms"

        cfg.CONF.pecan.auth_enable = True
        try:
            workbook = create_workbook("test_rest.yaml")
            db_api.workbook_update(workbook['name'], {'trust_id': '123'})

            execution = self.engine.start_workflow_execution(workbook['name'],
                                                             task_name, {})
            tasks = db_api.tasks_get(workbook_name=workbook['name'],
                                     execution_id=execution['id'])

            task = self._assert_single_item(tasks, name=task_name)

            openstack_context = task['in_context']['openstack']

            self.assertIn("auth_token", openstack_context)
            self.assertEqual(TOKEN, openstack_context['auth_token'])
            self.assertEqual(USER_ID, openstack_context["user_id"])

            self.engine.convey_task_result(task['id'], states.SUCCESS, {})

            execution = db_api.execution_get(execution['id'])

            self.assertEqual(states.SUCCESS, execution['state'])
        finally:
            cfg.CONF.pecan.auth_enable = False
Beispiel #2
0
    def test_add_token_to_context(self):
        task_name = "create-vms"

        cfg.CONF.pecan.auth_enable = True
        try:
            workbook = create_workbook("test_rest.yaml")
            db_api.workbook_update(workbook['name'], {'trust_id': '123'})

            execution = self.engine.start_workflow_execution(
                workbook['name'], task_name, {})
            tasks = db_api.tasks_get(workbook['name'], execution['id'])

            task = self._assert_single_item(tasks, name=task_name)

            context = task['in_context']

            self.assertIn("auth_token", context)
            self.assertEqual(TOKEN, context['auth_token'])
            self.assertEqual(USER_ID, context["user_id"])

            self.engine.convey_task_result(workbook['name'], execution['id'],
                                           task['id'], states.SUCCESS, {})

            execution = db_api.execution_get(workbook['name'], execution['id'])

            self.assertEqual(states.SUCCESS, execution['state'])
        finally:
            cfg.CONF.pecan.auth_enable = False
Beispiel #3
0
def create_trust(workbook):
    client = keystone.client()

    ctx = context.ctx()

    trustee_id = keystone.client_for_admin(ctx['project_id']).user_id

    trust = client.trusts.create(trustor_user=client.user_id,
                                 trustee_user=trustee_id,
                                 impersonation=True,
                                 role_names=ctx['roles'],
                                 project=ctx['project_id'])

    return db_api.workbook_update(workbook['name'],
                                  {'trust_id': trust.id,
                                   'project_id': ctx['project_id']})
Beispiel #4
0
def create_trust(workbook):
    client = keystone.client()

    ctx = context.ctx()

    trustee_id = keystone.client_for_admin(
        CONF.keystone_authtoken.admin_tenant_name).user_id

    trust = client.trusts.create(trustor_user=client.user_id,
                                 trustee_user=trustee_id,
                                 impersonation=True,
                                 role_names=ctx.roles,
                                 project=ctx.project_id)

    return db_api.workbook_update(workbook['name'],
                                  {'trust_id': trust.id,
                                   'project_id': ctx.project_id})
Beispiel #5
0
def create_trust(workbook):
    client = keystone.client()

    ctx = context.ctx()

    trustee_id = keystone.client_for_admin(ctx['project_id']).user_id

    trust = client.trusts.create(trustor_user=client.user_id,
                                 trustee_user=trustee_id,
                                 impersonation=True,
                                 role_names=ctx['roles'],
                                 project=ctx['project_id'])

    return db_api.workbook_update(workbook['name'], {
        'trust_id': trust.id,
        'project_id': ctx['project_id']
    })
Beispiel #6
0
def create_trust(workbook):
    client = keystone.client()

    ctx = context.ctx()

    admin_user = CONF.keystone.admin_user
    admin_password = CONF.keystone.admin_password
    admin_tenant_name = CONF.keystone.admin_tenant_name

    trustee_id = keystone.client_for_trusts(
        admin_user,
        admin_password,
        project_name=admin_tenant_name).user_id

    trust = client.trusts.create(trustor_user=client.user_id,
                                 trustee_user=trustee_id,
                                 impersonation=True,
                                 role_names=ctx['roles'],
                                 project=ctx['project_id'])

    return db_api.workbook_update(workbook['name'],
                                  {'trust_id': trust.id,
                                   'project_id': ctx['project_id']})
Beispiel #7
0
    def put(self, name, workbook):
        """Update the named workbook."""
        LOG.debug("Update workbook [name=%s, workbook=%s]" % (name, workbook))

        return Workbook.from_dict(db_api.workbook_update(name,
                                                         workbook.to_dict()))
Beispiel #8
0
    def put(self, name, workbook):
        LOG.debug("Update workbook [name=%s, workbook=%s]" % (name, workbook))

        return Workbook.from_dict(
            db_api.workbook_update(name, workbook.to_dict()))