diff --git a/spiffworkflow-backend/bin/run_message_start_event_with_api b/spiffworkflow-backend/bin/run_message_start_event_with_api new file mode 100755 index 000000000..449cfb91e --- /dev/null +++ b/spiffworkflow-backend/bin/run_message_start_event_with_api @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +function error_handler() { + >&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}." + exit "$2" +} +trap 'error_handler ${LINENO} $?' ERR +set -o errtrace -o errexit -o nounset -o pipefail + +script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +if [[ -z "${KEYCLOAK_BASE_URL:-}" ]]; then + # export KEYCLOAK_BASE_URL=https://keycloak.dev.spiffworkflow.org + export KEYCLOAK_BASE_URL=http://localhost:7002 +fi +if [[ -z "${BACKEND_BASE_URL:-}" ]]; then + # export BACKEND_BASE_URL=https://api.dev.spiffworkflow.org + export BACKEND_BASE_URL=http://localhost:7000 +fi + +message_identifier="${1:-start_test}" +username="${2:-admin}" +password="${3:-admin}" +realm_name="${4:-spiffworkflow}" +if [[ -z "${message_identifier}" ]]; then + >&2 echo "usage: $(basename "$0") [message_identifier] [username: OPTONAL] [password: OPTONAL] [realm_name: OPTONAL]" + exit 1 +fi + +function check_result_for_error() { + local result="$1" + error_code=$(jq '.error_code' <<<"$result") + if [[ -n "$error_code" && "$error_code" != "null" ]]; then + >&2 echo "ERROR: Failed to run process instance. Received error: $result" + exit 1 + fi +} + +access_token=$("${script_dir}/get_token" "$username" "$password" "$realm_name") +curl --silent -X POST "${BACKEND_BASE_URL}/v1.0/login_with_access_token?access_token=${access_token}" -H "Authorization: Bearer $access_token" >/dev/null +result=$(curl --silent -X POST "${BACKEND_BASE_URL}/v1.0/messages/${message_identifier}" -H "Authorization: Bearer $access_token" -d '{"payload": {"email": "HEY@example.com"}}' -H 'Content-type: application/json') +check_result_for_error "$result" +echo "$result" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/messages_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/messages_controller.py index f7db74db3..62d3779c7 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/messages_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/messages_controller.py @@ -69,7 +69,6 @@ def message_send( message_name: str, body: Dict[str, Any], ) -> flask.wrappers.Response: - """Message_start.""" if "payload" not in body: raise ( ApiError(