def _submit( self, action=None, decision_task_id=None, task_id=None, input=None, static_action_variables=None, ) -> str: context = { "taskGroupId": decision_task_id, "taskId": task_id or None, "input": input, } context.update(static_action_variables) action_kind = action["kind"] if action_kind == "hook": hook_payload = jsone.render(action["hookPayload"], context) hook_id, hook_group_id = action["hookId"], action["hookGroupId"] decision_task = self.queue.task(decision_task_id) expansion = self.auth.expandScopes( {"scopes": decision_task["scopes"]}) expression = f"in-tree:hook-action:{hook_group_id}/{hook_id}" if not satisfiesExpression(expansion["scopes"], expression): raise RuntimeError( f"Action is misconfigured: decision task's scopes do not satisfy {expression}" ) result = self.hooks.triggerHook(hook_group_id, hook_id, hook_payload) return result["status"]["taskId"] raise NotImplementedError( f"Unable to submit actions with '{action_kind}' kind.")
def test_expression_is_satisfied(scopeset, expression): assert satisfiesExpression(scopeset, expression) is True
def test_wrong_scopeset_type_raises_exception(scopeset): with pytest.raises(TypeError): satisfiesExpression(scopeset, 'in-tree:hook-action:{hook_group_id}/{hook_id}')
def test_expression_is_not_satisfied(scopeset, expression): assert not satisfiesExpression(scopeset, expression)