Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/spiffworkflow_proxy/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ def do_command(plugin_display_name: str, command_name: str) -> Response:
status=404
)

params = typing.cast(dict, request.json)
params = typing.cast(dict, request.json or {})
task_data = params.pop('spiff__task_data', '{}')
params = {key: value for key, value in params.items() if not key.startswith("spiff__")}

try:
result = command(**params).execute(current_app.config, task_data)
Expand Down Expand Up @@ -164,4 +165,3 @@ def json_error_response(message: str, error_code: str, status: int) -> Response:
},
}
return Response(json.dumps(response), status=status)

Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ def execute(self, config: Any, task_data: Any) -> CommandResponseDict:
"""Execute."""

return {
"body": {
"command_response": {
"example_response": "whatever you want",
"arg1": self.arg1,
"arg2": self.arg2
"command_response_version": 2,
"command_response": {
"body": {
"command_response": {
"example_response": "whatever you want",
"arg1": self.arg1,
"arg2": self.arg2,
},
},
"mimetype": "application/json",
},
"http_status": 200,
"mimetype": "application/json",
"error": None,
"spiff__logs": [],
}

18 changes: 18 additions & 0 deletions tests/spiffworkflow_proxy/integration/blueprint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ def test_list_commands() -> None:
assert(len(json_resp) == 1)
assert(json_resp[0]["id"] == "example/CombineStrings")
assert(len(json_resp[0]["parameters"]) == 2)


def test_do_command_ignores_spiff_params() -> None:
payload = {
"arg1": "hello",
"arg2": "world",
"spiff__process_instance_id": 123,
"spiff__task_id": "task-1",
"spiff__callback_url": "http://localhost/callback",
"spiff__task_data": {"example": True},
}

rv = web_client().post("/v1/do/example/CombineStrings", json=payload)

assert rv.status_code == 200
json_resp = json.loads(rv.get_data(as_text=True))
assert json_resp["command_response"]["body"]["command_response"]["arg1"] == "hello"
assert json_resp["command_response"]["body"]["command_response"]["arg2"] == "world"
Loading