This commit is contained in:
15
shuffle/backend/tests/cache.sh
Normal file
15
shuffle/backend/tests/cache.sh
Normal file
@ -0,0 +1,15 @@
|
||||
curl -XPOST http://192.168.3.8:5001/api/v1/orgs/6a6a99f5-6630-4f91-88ff-571c9f030ea0/set_cache -H "Authorization: Bearer e663cf93-7f10-4560-bef0-303f14aad982" -d '{
|
||||
"workflow_id": "61825389-a125-43a5-9119-97c401e9934b",
|
||||
"execution_id": "2c8ca1b7-6658-4742-86a1-105c9467702d",
|
||||
"org_id": "6a6a99f5-6630-4f91-88ff-571c9f030ea0",
|
||||
"key": "test",
|
||||
"value": "THIS IS SOME DATA HELLO"
|
||||
}'
|
||||
|
||||
curl -XPOST http://192.168.3.8:5001/api/v1/orgs/6a6a99f5-6630-4f91-88ff-571c9f030ea0/get_cache -H "Authorization: Bearer e663cf93-7f10-4560-bef0-303f14aad982" -d '{
|
||||
"workflow_id": "61825389-a125-43a5-9119-97c401e9934b",
|
||||
"execution_id": "2c8ca1b7-6658-4742-86a1-105c9467702d",
|
||||
"org_id": "6a6a99f5-6630-4f91-88ff-571c9f030ea0",
|
||||
"key": "test"
|
||||
}'
|
||||
|
2
shuffle/backend/tests/cleanup.sh
Normal file
2
shuffle/backend/tests/cleanup.sh
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
curl http://localhost:5001/api/v1/execution_cleanup -H "Authorization: Bearer e08c6f22-9a55-4557-b008-04388cc51fb0"
|
5
shuffle/backend/tests/dockerpull.sh
Normal file
5
shuffle/backend/tests/dockerpull.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
#curl -XPOST http://localhost:5001/api/v1/get_docker_image -d '{"name":"frikky/shuffle:testing_1.0.0"}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4" --output tarball.tgz
|
||||
#curl -XPOST http://localhost:5001/api/v1/get_docker_image -d '{"name":"frikky/shuffle:testing_1.0.0"}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4" -O -J
|
||||
#curl -XPOST http://localhost:5001/api/v1/get_docker_image -d '{"name":"frikky/shuffle:testing_1.0.0"}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4" --output tarball.tgz
|
||||
curl -XPOST http://localhost:5001/api/v1/get_docker_image -d '{"name":"frikky/shuffle:shuffle-tools_1.0.0"}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4" --output tarball.tgz
|
26
shuffle/backend/tests/execute.sh
Normal file
26
shuffle/backend/tests/execute.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/425efd39-08e7-4390-9387-170c172775f7/execute -d '{"execution_argument":""}' -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
3
shuffle/backend/tests/file_download.sh
Normal file
3
shuffle/backend/tests/file_download.sh
Normal file
@ -0,0 +1,3 @@
|
||||
# ./b199646b-16d2-456d-9fd6-b9972e929466/2e9d6474-402c-4dcc-bb53-45f638ca18d3/0d676d72-5d53-4803-a6b0-4afb464df828
|
||||
# org_id / workflow_id / file_id
|
||||
curl http://192.168.3.6:5001/api/v1/files/0d676d72-5d53-4803-a6b0-4afb464df828/content -H "Authorization: Bearer 093b576f-19ea-4353-b685-362ab50f39f4"
|
22
shuffle/backend/tests/files.sh
Normal file
22
shuffle/backend/tests/files.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#curl http://192.168.3.6:5001/api/v1/files/create -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4" -d '{"filename": "file.txt", "org_id": "b199646b-16d2-456d-9fd6-b9972e929466", "workflow_id": "global"}'
|
||||
#
|
||||
#curl http://localhost:5001/api/v1/files/create -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4" -d '{"filename": "file.txt", "org_id": "b199646b-16d2-456d-9fd6-b9972e929466", "workflow_id": "global"}'
|
||||
#
|
||||
#echo
|
||||
#curl http://localhost:5001/api/v1/apps/upload -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4" -F 'shuffle_file=@files.sh'
|
||||
#
|
||||
#curl http://localhost:5001/api/v1/files/1915981b-b897-4db1-8a2e-44bc34cead3b/content -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
#curl http://localhost:5001/api/v1/files/e19cffe4-e2da-47e9-809e-904f5cb03687 -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
#curl -XDELETE http://localhost:5001/api/v1/files/e19cffe4-e2da-47e9-809e-904f5cb03687 -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
||||
|
||||
#r.HandleFunc("/api/v1/files/{fileId}/content", handleGetFileContent).Methods("GET", "OPTIONS")
|
||||
#r.HandleFunc("/api/v1/files/create", handleCreateFile).Methods("POST", "OPTIONS")
|
||||
#r.HandleFunc("/api/v1/files/{fileId}/upload", handleUploadFile).Methods("POST", "OPTIONS")
|
||||
#r.HandleFunc("/api/v1/files/{fileId}", handleGetFileMeta).Methods("GET", "OPTIONS")
|
||||
#r.HandleFunc("/api/v1/files/{fileId}", handleDeleteFile).Methods("DELETE", "OPTIONS")
|
||||
|
||||
|
||||
curl http://localhost:5001/api/v1/files/create -H "Authorization: Bearer 317f5066-395c-414d-aa3d-479cf27f47dd" -d '{"filename": "rule2.yar", "org_id": "292c7e25-40ad-4f05-904f-77d3c7b735e6", "workflow_id": "global", "namespace": "yara"}'
|
||||
curl http://localhost:5001/api/v1/files/file_eb89e315-eb66-4d76-9df7-530fb003fc84/upload -H "Authorization: Bearer 317f5066-395c-414d-aa3d-479cf27f47dd" -F 'shuffle_file=@upload.sh'
|
||||
|
||||
#curl http://localhost:5001/api/v1/files/namespaces/yara -H "Authorization: Bearer c5b4c827-65ec-47f4-9e8a-234cdba38959" --output rules.zip
|
206
shuffle/backend/tests/forparser.py
Normal file
206
shuffle/backend/tests/forparser.py
Normal file
@ -0,0 +1,206 @@
|
||||
import re
|
||||
import json
|
||||
|
||||
fullexecution = {"type":"workflow","status":"FINISHED","start":"40447f30-fa44-4a4f-a133-4ee710368737","execution_argument":"","execution_id":"083eaa87-17ff-4aba-996c-83245051cf3d","execution_source":"default","workflow_id":"d7b73e8a-08fe-460e-987b-971cb6f1857f","last_node":"40447f30-fa44-4a4f-a133-4ee710368737","authorization":"b1264cd6-ed7a-4839-8caf-187eee8804b9","result":"TypeError: list indices must be integers or slices, not str","started_at":1593236788,"completed_at":1593236790,"project_id":"shuffle","locations":["europe-west2"],"workflow":{"actions":[{"app_name":"Testing","app_version":"1.0.0","app_id":"5411f573-9bba-44c4-a8d3-0e2bb704546d","errors":"null","id":"40447f30-fa44-4a4f-a133-4ee710368737","is_valid":True,"isStartNode":True,"sharing":True,"private_id":"","label":"Hello this is a name","small_image":"","large_image":"","environment":"Shuffle","name":"repeat_back_to_me","parameters":[{"description":"The message to repeat","id":"","name":"call","example":"REPEATING: Hello world","value":"$this is a test.name is not the same as $this is a test.name2 \n\n\nNot list $this is a test.loop.# either","multiline":True,"action_field":"","variant":"STATIC_VALUE","required":True,"schema":{"type":"string"}}],"execution_variable":{"description":"","id":"","name":"","value":""},"position":{"x":360.5,"y":454.5},"priority":0}],"branches":"null","triggers":"null","schedules":"null","configuration":{"exit_on_error":False,"start_from_top":False},"id":"d7b73e8a-08fe-460e-987b-971cb6f1857f","is_valid":True,"name":"App sdk parser testing","description":"","start":"40447f30-fa44-4a4f-a133-4ee710368737","owner":"43c36230-0a6e-40fc-aebc-a8ef57c81a88","sharing":"private","execution_org":{"name":"","org":"","users":"null","id":""},"workflow_variables":[{"description":"","id":"a034abee-5a5f-4347-9e58-6d2e58ce70f2","name":"This is a test","value":"[{\"data\": \"1.1.1.1\", \"data_type\": \"ip\"}]"}]},"results":[{"action":{"app_name":"Testing","app_version":"1.0.0","app_id":"5411f573-9bba-44c4-a8d3-0e2bb704546d","errors":"null","id":"40447f30-fa44-4a4f-a133-4ee710368737","is_valid":True,"isStartNode":True,"sharing":True,"private_id":"","label":"Hello this is a name","small_image":"","large_image":"","environment":"Shuffle","name":"repeat_back_to_me","parameters":[{"description":"The message to repeat","id":"","name":"call","example":"","value":"testing is not the same as testing2 \n\n\nNot list $this is a test.loop.# either","multiline":"false","action_field":"","variant":"STATIC_VALUE","required":True,"schema":{"type":"string"}}],"execution_variable":{"description":"","id":"","name":"","value":""},"position":{"x":360.5,"y":454.5},"priority":0},"execution_id":"083eaa87-17ff-4aba-996c-83245051cf3d","authorization":"b1264cd6-ed7a-4839-8caf-187eee8804b9","result":"TypeError: list indices must be integers or slices, not str","started_at":1593236790,"completed_at":1593236790,"status":"FAILURE"}]}
|
||||
|
||||
|
||||
# Takes a workflow execution as argument
|
||||
# Returns a string if the result is single, or a list if it's a list
|
||||
|
||||
# Not implemented: lists
|
||||
multiexecutions = True
|
||||
def get_json_value(execution_data, input_data):
|
||||
parsersplit = input_data.split(".")
|
||||
actionname = parsersplit[0][1:].replace(" ", "_", -1)
|
||||
print(f"Actionname: {actionname}")
|
||||
|
||||
# 1. Find the action
|
||||
baseresult = ""
|
||||
actionname_lower = actionname.lower()
|
||||
try:
|
||||
if actionname_lower == "exec":
|
||||
baseresult = execution_data["execution_argument"]
|
||||
else:
|
||||
for result in execution_data["results"]:
|
||||
resultlabel = result["action"]["label"].replace(" ", "_", -1).lower()
|
||||
if resultlabel.lower() == actionname_lower:
|
||||
baseresult = result["result"]
|
||||
break
|
||||
|
||||
print("BEFORE VARIABLES!")
|
||||
if len(baseresult) == 0:
|
||||
try:
|
||||
#print("WF Variables: %s" % execution_data["workflow"]["workflow_variables"])
|
||||
for variable in execution_data["workflow"]["workflow_variables"]:
|
||||
variablename = variable["name"].replace(" ", "_", -1).lower()
|
||||
|
||||
if variablename.lower() == actionname_lower:
|
||||
baseresult = variable["value"]
|
||||
break
|
||||
except KeyError as e:
|
||||
print("KeyError wf variables: %s" % e)
|
||||
pass
|
||||
except TypeError as e:
|
||||
print("TypeError wf variables: %s" % e)
|
||||
pass
|
||||
|
||||
print("BEFORE EXECUTION VAR")
|
||||
if len(baseresult) == 0:
|
||||
try:
|
||||
#print("Execution Variables: %s" % execution_data["execution_variables"])
|
||||
for variable in execution_data["execution_variables"]:
|
||||
variablename = variable["name"].replace(" ", "_", -1).lower()
|
||||
if variablename.lower() == actionname_lower:
|
||||
baseresult = variable["value"]
|
||||
break
|
||||
except KeyError as e:
|
||||
print("KeyError exec variables: %s" % e)
|
||||
pass
|
||||
except TypeError as e:
|
||||
print("TypeError exec variables: %s" % e)
|
||||
pass
|
||||
|
||||
except KeyError as error:
|
||||
print(f"KeyError in JSON: {error}")
|
||||
|
||||
print(f"After first trycatch")
|
||||
|
||||
# 2. Find the JSON data
|
||||
if len(baseresult) == 0:
|
||||
return ""
|
||||
|
||||
if len(parsersplit) == 1:
|
||||
return baseresult
|
||||
|
||||
baseresult = baseresult.replace("\'", "\"")
|
||||
basejson = {}
|
||||
try:
|
||||
basejson = json.loads(baseresult)
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
return baseresult
|
||||
|
||||
# This whole thing should be recursive.
|
||||
try:
|
||||
cnt = 0
|
||||
for value in parsersplit[1:]:
|
||||
cnt += 1
|
||||
|
||||
print("VALUE: %s" % value)
|
||||
if value == "#":
|
||||
# FIXME - not recursive - should go deeper if there are more #
|
||||
print("HANDLE RECURSIVE LOOP OF %s" % basejson)
|
||||
returnlist = []
|
||||
try:
|
||||
for innervalue in basejson:
|
||||
print("Value: %s" % innervalue[parsersplit[cnt+1]])
|
||||
returnlist.append(innervalue[parsersplit[cnt+1]])
|
||||
except IndexError as e:
|
||||
print("Indexerror inner: %s" % e)
|
||||
# Basically means its a normal list, not a crazy one :)
|
||||
# Custom format for ${name[0,1,2,...]}$
|
||||
indexvalue = "${NO_SPLITTER%s}$" % json.dumps(basejson)
|
||||
if len(returnlist) > 0:
|
||||
indexvalue = "${NO_SPLITTER%s}$" % json.dumps(returnlist)
|
||||
|
||||
print("INDEXVAL: ", indexvalue)
|
||||
return indexvalue
|
||||
except TypeError as e:
|
||||
print("TypeError inner: %s" % e)
|
||||
|
||||
# Example format: ${[]}$
|
||||
parseditem = "${%s%s}$" % (parsersplit[cnt+1], json.dumps(returnlist))
|
||||
print("PARSED LOOP ITEM: %s" % parseditem)
|
||||
return parseditem
|
||||
|
||||
else:
|
||||
print("BEFORE NORMAL VALUE: ", basejson, value)
|
||||
if len(value) == 0:
|
||||
return basejson
|
||||
|
||||
if isinstance(basejson[value], str):
|
||||
print(f"LOADING STRING '%s' AS JSON" % basejson[value])
|
||||
try:
|
||||
basejson = json.loads(basejson[value])
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
print("RETURNING BECAUSE '%s' IS A NORMAL STRING" % basejson[value])
|
||||
return basejson[value]
|
||||
else:
|
||||
basejson = basejson[value]
|
||||
|
||||
except KeyError as e:
|
||||
print("Lower keyerror: %s" % e)
|
||||
return "KeyError: Couldn't find key: %s" % e
|
||||
|
||||
return basejson
|
||||
|
||||
parameter = {
|
||||
"value": """{
|
||||
"data8": "Not list $this is a test.#.data either with the items $this is a test.#.data_type"
|
||||
}"""
|
||||
}
|
||||
|
||||
match = ".*?([$]{1}([a-zA-Z0-9 _-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})"
|
||||
actualitem = re.findall(match, parameter["value"], re.MULTILINE)
|
||||
print("ACTUAL: ", actualitem)
|
||||
if len(actualitem) > 0:
|
||||
data = parameter["value"]
|
||||
|
||||
counter = 0
|
||||
for replace in actualitem:
|
||||
try:
|
||||
to_be_replaced = replace[0]
|
||||
except IndexError:
|
||||
continue
|
||||
|
||||
value = get_json_value(fullexecution, to_be_replaced)
|
||||
if isinstance(value, str):
|
||||
if "${" in value and "}$" in value:
|
||||
counter += 1
|
||||
|
||||
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
|
||||
elif isinstance(value, dict):
|
||||
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
||||
elif isinstance(value, list):
|
||||
parameter["value"] = parameter["value"].replace(to_be_replaced, json.dumps(value))
|
||||
|
||||
|
||||
print(parameter["value"])
|
||||
submatch = "([${]{2}([0-9a-zA-Z_-]+)(\[.*\])[}$]{2})"
|
||||
actualitem = re.findall(submatch, parameter["value"], re.MULTILINE)
|
||||
print()
|
||||
# Kind of the same thing again, but different usage
|
||||
if len(actualitem) > 0:
|
||||
minlength = 0
|
||||
# 1. Find the length of the longest array
|
||||
# 2. Build an array with the base values based on parameter["value"]
|
||||
# 3. Get the n'th value of the generated list from values
|
||||
# 4. Execute all n answers
|
||||
replacements = {}
|
||||
for replace in actualitem:
|
||||
try:
|
||||
to_be_replaced = replace[0]
|
||||
actualitem = replace[2]
|
||||
except IndexError:
|
||||
continue
|
||||
|
||||
itemlist = json.loads(actualitem)
|
||||
if len(itemlist) > minlength:
|
||||
minlength = len(itemlist)
|
||||
|
||||
replacements[to_be_replaced] = actualitem
|
||||
|
||||
resultarray = []
|
||||
for i in range(0, minlength):
|
||||
tmpitem = json.loads(json.dumps(parameter["value"]))
|
||||
|
||||
for key, value in replacements.items():
|
||||
replacement = json.loads(value)[i]
|
||||
tmpitem = tmpitem.replace(key, replacement, -1)
|
||||
|
||||
resultarray.append(tmpitem)
|
||||
|
||||
# With this parameter ready, add it to... a greater list of parameters. Rofl
|
||||
print(resultarray[0])
|
||||
else:
|
||||
print("Normal execution")
|
||||
pass
|
26
shuffle/backend/tests/hooks.sh
Normal file
26
shuffle/backend/tests/hooks.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#curl localhost:5000/api/v1/hooks
|
||||
|
||||
# Starts a webhook
|
||||
#curl localhost:5000/api/v1/hooks/d6ef8912e8bd37776e654cbc14c2629c/start
|
||||
|
||||
# Runs a request towards the webhook created
|
||||
#curl -XPOST localhost:5002/webhook -d '{"helo": "hi"}'
|
||||
|
||||
# Gets the ID of a new hook
|
||||
|
||||
#curl -X PUT localhost:5001/api/v1/hooks/e6f77059e6d469a6c4c314cc06d5a4c0 -d '{"name": "asd", "description": "hola", "type": "webhook", "id": "e6f77059e6d469a6c4c314cc06d5a4c0", "status": "stopped", "info": {"name": "lul", "url": "http://test"}}'
|
||||
|
||||
#curl -X POST localhost:5000/api/v1/hooks/new -d '{"name": "asd", "description": "hola", "type": "webhook"}'
|
||||
|
||||
#curl -X POST "https://europe-west1-shuffle-241517.cloudfunctions.net/webhook_982995716e67c3a549092d3a3a7921cd" -H "Content-Type:application/json" -H "Authorization: Bearer 144308d0-6aab-4d4f-8bb2-75189281ee26" --data '{"name":"Keyboard Cat"}' -v
|
||||
|
||||
## GET HOOK
|
||||
#curl http://localhost:5001/api/v1/hooks/b4ba07c9-45d4-41f2-b260-83c8e99eba0c -H "Authorization: Bearer "
|
||||
|
||||
#curl https://shuffler.io/api/v1/hooks/b4ba07c9-45d4-41f2-b260-83c8e99eba0c -H "Authorization: Bearer "
|
||||
|
||||
|
||||
#curl -X POST "https://europe-west1-shuffle-241517.cloudfunctions.net/webhook_3ceff795-ce9a-43a2-a2f5-d4401a6e772d" -H "Authorization: Bearer 144308d0-6aab-4d4f-8bb2-75189281ee26" --data 'wut'
|
||||
#curl POST "https://europe-west1-shuffler.cloudfunctions.net/outlooktrigger_be4dbb0a-d396-4544-bc36-e57d1bdb2e40" -H "Authorization: Bearer 144308d0-6aab-4d4f-8bb2-75189281ee26" --data 'wut' -vvv
|
||||
|
||||
curl -X POST "http://localhost:5002/api/v1/hooks/webhook_f22b5e54-e55d-48e5-a1d1-f40453513fd3" -H "Content-Type:application/json" --data '{"test": {"hello": "HEYOOOO"}}'
|
1
shuffle/backend/tests/hotload.sh
Normal file
1
shuffle/backend/tests/hotload.sh
Normal file
@ -0,0 +1 @@
|
||||
curl http://localhost:5001/api/v1/apps/run_hotload -H "Authorization: Bearer e08c6f22-9a55-4557-b008-04388cc51fb0"
|
1
shuffle/backend/tests/list_files.sh
Normal file
1
shuffle/backend/tests/list_files.sh
Normal file
@ -0,0 +1 @@
|
||||
curl -XGET http://192.168.3.6:5001/api/v1/files -H "Authorization: Bearer db0373c6-1083-4dec-a05d-3ba73f02ccd4"
|
2
shuffle/backend/tests/migrate_db.sh
Normal file
2
shuffle/backend/tests/migrate_db.sh
Normal file
@ -0,0 +1,2 @@
|
||||
curl -XPOST -v localhost:5001/api/v1/migrate_database -H 'Authorization: Bearer 0184d7be-33c1-4391-bf9c-dfb8508a4ea2'
|
||||
|
69
shuffle/backend/tests/run_function.py
Normal file
69
shuffle/backend/tests/run_function.py
Normal file
@ -0,0 +1,69 @@
|
||||
# This is a script to test a function by itself
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
def invoke(url, headers, message):
|
||||
# Used for testing
|
||||
try:
|
||||
ret = requests.post(url, headers=headers, json=message, timeout=5)
|
||||
print(ret.text)
|
||||
print(ret.status_code)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
print(f"Requesterror: {e}")
|
||||
|
||||
def invoke_multi(url, headers, message):
|
||||
cnt = 0
|
||||
maxcnt = 100
|
||||
print("Running %d requests towards %s." % (maxcnt, url))
|
||||
while(1):
|
||||
try:
|
||||
ret = requests.post(url, headers=headers, json=message, timeout=1)
|
||||
print(ret.status_code)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
print(f"Connectionerror: {e}")
|
||||
except requests.exceptions.ReadTimeout as e:
|
||||
print(f"Readtimeout: {e}")
|
||||
|
||||
cnt += 1
|
||||
if cnt == maxcnt:
|
||||
break
|
||||
|
||||
print("Done :)")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Specific thingies for hello_world
|
||||
message = {
|
||||
"parameters": [{
|
||||
"id_": "asd",
|
||||
"name": "call",
|
||||
"value": "REPEAT THIS DATA PLEASE THANKS",
|
||||
"variant": "STATIC_VALUE",
|
||||
}],
|
||||
"name": "repeat_back_to_me",
|
||||
"execution_id": "asd",
|
||||
"label": "",
|
||||
"position": "",
|
||||
"app_name": "hello_world",
|
||||
"app_version": "1.0.0",
|
||||
"label": "lul",
|
||||
"priority": "1",
|
||||
"id_": "test",
|
||||
"id": "test",
|
||||
"authorization": "hey",
|
||||
}
|
||||
|
||||
apikey = ""
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {apikey}"
|
||||
}
|
||||
|
||||
location = "europe-west2"
|
||||
functionname = "hello-world-1-0-6"
|
||||
project = "shuffler"
|
||||
|
||||
url = f"https://{location}-{project}.cloudfunctions.net/{functionname}"
|
||||
print(url)
|
||||
invoke(url, headers, message)
|
||||
#invoke_multi(url, headers, message)
|
2
shuffle/backend/tests/scheduleapps.sh
Normal file
2
shuffle/backend/tests/scheduleapps.sh
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
curl localhost:5000/api/v1/schedules/apps
|
2
shuffle/backend/tests/schedules.sh
Normal file
2
shuffle/backend/tests/schedules.sh
Normal file
@ -0,0 +1,2 @@
|
||||
# Fails cus of unmarshal
|
||||
curl -XPOST http://localhost:5001/api/v1/workflows/1d9d8ce2-566e-4c3f-8a37-5d6c7d2000b5/schedule -d '{"name": "hey", "frequency": "*/1 * * * *", "execution_argument": "{\"test\": \"hey\"}"}' -H "Authorization: Bearer WUT"
|
3
shuffle/backend/tests/sendmail.sh
Normal file
3
shuffle/backend/tests/sendmail.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#curl -X POST -H "Content-Type: application/json" shuffler.io/functions/sendmail -H "Authorization: Bearer " -d '{"target": "frikky@shuffler.io", "body": "Hey, this is a body for something to look at", "subject": "SOS check me", "type": "alert", "sender_company": "shuffler"}'
|
||||
|
||||
curl -X POST -H "Content-Type: application/json" localhost:5001/functions/sendmail -H "Authorization: Bearer " -d '{"targets": ["frikky@shuffler.io", "rheyix.yt@gmail.com"], "body": "Hey, this is a body for something to look at", "subject": "SOS check me", "type": "alert", "sender_company": "shuffler"}'
|
1
shuffle/backend/tests/stop_execution.sh
Normal file
1
shuffle/backend/tests/stop_execution.sh
Normal file
@ -0,0 +1 @@
|
||||
curl "http://localhost:5001/api/v1/environments/Shuffle/stop" -H "Authorization: Bearer e663cf93-7f10-4560-bef0-303f14aad982"
|
7
shuffle/backend/tests/testWorkflows.sh
Normal file
7
shuffle/backend/tests/testWorkflows.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Should give 401
|
||||
curl localhost:5000/api/v1/uploadResult/asdasd -d {}
|
||||
echo
|
||||
|
||||
# Should give 200 if it exists
|
||||
curl localhost:5000/api/v1/uploadResult/e07910a06a086c83ba41827aa00b26ed -d '{"title": "helo","description": "wut", "type": "hi", "source": "wutface", "sourceRef": "halvor hei"}'
|
210
shuffle/backend/tests/test_wrappers.py
Normal file
210
shuffle/backend/tests/test_wrappers.py
Normal file
@ -0,0 +1,210 @@
|
||||
import re
|
||||
import json
|
||||
|
||||
def parse_nested_param(string, level):
|
||||
"""
|
||||
Generate strings contained in nested (), indexing i = level
|
||||
"""
|
||||
if len(re.findall("\(", string)) == len(re.findall("\)", string)):
|
||||
LeftRightIndex = [x for x in zip(
|
||||
[Left.start()+1 for Left in re.finditer('\(', string)],
|
||||
reversed([Right.start() for Right in re.finditer('\)', string)]))]
|
||||
|
||||
elif len(re.findall("\(", string)) > len(re.findall("\)", string)):
|
||||
return parse_nested_param(string + ')', level)
|
||||
elif len(re.findall("\(", string)) < len(re.findall("\)", string)):
|
||||
return parse_nested_param('(' + string, level)
|
||||
|
||||
else:
|
||||
return 'Failed to parse params'
|
||||
|
||||
try:
|
||||
return [string[LeftRightIndex[level][0]:LeftRightIndex[level][1]]]
|
||||
except IndexError:
|
||||
return [string[LeftRightIndex[level+1][0]:LeftRightIndex[level+1][1]]]
|
||||
|
||||
# Parses the deepest part
|
||||
def maxDepth(S):
|
||||
current_max = 0
|
||||
max = 0
|
||||
n = len(S)
|
||||
|
||||
# Traverse the input string
|
||||
for i in range(n):
|
||||
if S[i] == '(':
|
||||
current_max += 1
|
||||
|
||||
if current_max > max:
|
||||
max = current_max
|
||||
elif S[i] == ')':
|
||||
if current_max > 0:
|
||||
current_max -= 1
|
||||
else:
|
||||
return -1
|
||||
|
||||
# finally check for unbalanced string
|
||||
if current_max != 0:
|
||||
return -1
|
||||
|
||||
return max-1
|
||||
|
||||
def parse_type(data, thistype):
|
||||
if data == None:
|
||||
return "Empty"
|
||||
|
||||
if "int" in thistype:
|
||||
try:
|
||||
return int(data)
|
||||
except ValueError:
|
||||
print("ValueError while casting %s" % data)
|
||||
return data
|
||||
if "lower" in thistype:
|
||||
return data.lower()
|
||||
if "upper" in thistype:
|
||||
return data.upper()
|
||||
if "trim" in thistype:
|
||||
return data.strip()
|
||||
if "strip" in thistype:
|
||||
return data.strip()
|
||||
if "split" in thistype:
|
||||
# Should be able to split anything
|
||||
return data.split()
|
||||
if "len" in thistype or "length" in thistype:
|
||||
return len(data)
|
||||
if "parse" in thistype:
|
||||
splitvalues = []
|
||||
default_error = """Error. Expected syntax: parse(["hello","test1"],0:1)"""
|
||||
if "," in data:
|
||||
splitvalues = data.split(",")
|
||||
|
||||
for item in range(len(splitvalues)):
|
||||
splitvalues[item] = splitvalues[item].strip()
|
||||
else:
|
||||
return default_error
|
||||
|
||||
lastsplit = []
|
||||
if ":" in splitvalues[-1]:
|
||||
lastsplit = splitvalues[-1].split(":")
|
||||
else:
|
||||
try:
|
||||
lastsplit = [int(splitvalues[-1])]
|
||||
except ValueError:
|
||||
return default_error
|
||||
|
||||
try:
|
||||
parsedlist = ",".join(splitvalues[0:-1])
|
||||
print(parsedlist)
|
||||
print(lastsplit)
|
||||
|
||||
if len(lastsplit) > 1:
|
||||
tmp = json.loads(parsedlist)[int(lastsplit[0]):int(lastsplit[1])]
|
||||
else:
|
||||
tmp = json.loads(parsedlist)[lastsplit[0]]
|
||||
|
||||
print(tmp)
|
||||
return tmp
|
||||
except IndexError as e:
|
||||
return default_error
|
||||
|
||||
# Parses the INNER value and recurses until everything is done
|
||||
def parse_wrapper(data):
|
||||
try:
|
||||
if "(" not in data or ")" not in data:
|
||||
return data
|
||||
except TypeError:
|
||||
return data
|
||||
|
||||
print("Running %s" % data)
|
||||
|
||||
# Look for the INNER wrapper first, then move out
|
||||
wrappers = ["int", "number", "lower", "upper", "trim", "strip", "split", "parse", "len", "length"]
|
||||
found = False
|
||||
for wrapper in wrappers:
|
||||
if wrapper not in data.lower():
|
||||
continue
|
||||
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
return data
|
||||
|
||||
# Do stuff here.
|
||||
innervalue = parse_nested_param(data, maxDepth(data)-0)
|
||||
outervalue = parse_nested_param(data, maxDepth(data)-1)
|
||||
print("INNER: ", outervalue)
|
||||
print("OUTER: ", outervalue)
|
||||
|
||||
if outervalue != innervalue:
|
||||
#print("Outer: ", outervalue, " inner: ", innervalue)
|
||||
for key in range(len(innervalue)):
|
||||
# Replace OUTERVALUE[key] with INNERVALUE[key] in data.
|
||||
print("Replace %s with %s in %s" % (outervalue[key], innervalue[key], data))
|
||||
data = data.replace(outervalue[key], innervalue[key])
|
||||
else:
|
||||
for thistype in wrappers:
|
||||
if thistype not in data.lower():
|
||||
continue
|
||||
|
||||
parsed_value = parse_type(innervalue[0], thistype)
|
||||
return parsed_value
|
||||
|
||||
print("DATA: %s\n" % data)
|
||||
return parse_wrapper(data)
|
||||
|
||||
def parse_wrapper_start(data):
|
||||
newdata = []
|
||||
newstring = ""
|
||||
record = True
|
||||
paranCnt = 0
|
||||
for char in data:
|
||||
if char == "(":
|
||||
paranCnt += 1
|
||||
|
||||
if not record:
|
||||
record = True
|
||||
|
||||
if record:
|
||||
newstring += char
|
||||
|
||||
if paranCnt == 0 and char == " ":
|
||||
newdata.append(newstring)
|
||||
newstring = ""
|
||||
record = True
|
||||
|
||||
if char == ")":
|
||||
paranCnt -= 1
|
||||
|
||||
if paranCnt == 0:
|
||||
record = False
|
||||
|
||||
if len(newstring) > 0:
|
||||
newdata.append(newstring)
|
||||
|
||||
parsedlist = []
|
||||
non_string = False
|
||||
for item in newdata:
|
||||
ret = parse_wrapper(item)
|
||||
if not isinstance(ret, str):
|
||||
non_string = True
|
||||
|
||||
parsedlist.append(ret)
|
||||
|
||||
if len(parsedlist) > 0 and not non_string:
|
||||
return " ".join(parsedlist)
|
||||
elif len(parsedlist) == 1 and non_string:
|
||||
return parsedlist[0]
|
||||
else:
|
||||
print("Casting back to string because multi: ", parsedlist)
|
||||
newlist = []
|
||||
for item in parsedlist:
|
||||
try:
|
||||
newlist.append(str(item))
|
||||
except ValueError:
|
||||
newlist.append("parsing_error")
|
||||
return " ".join(newlist)
|
||||
|
||||
data = "split(hello there)"
|
||||
data = """parse(["testing", "what", "is this"], 0:2)"""
|
||||
#data = "int(int(2))"
|
||||
print("RET: ", parse_wrapper_start(data))
|
3
shuffle/backend/tests/triggers.sh
Normal file
3
shuffle/backend/tests/triggers.sh
Normal file
@ -0,0 +1,3 @@
|
||||
# curl -H "Content-Type: application/json" localhost:5001/api/v1/triggers/9e845679-5843-4959-a76c-a6d664e9df35 -H "Authorization: Bearer 377469e8-dd5d-4521-8d9e-416d8d2f6fd4"
|
||||
|
||||
curl -XPOST http://localhost:5001/api/v1/hooks/webhook_1b968d49-2d78-4132-bf91-0f3a1f6a79f3 -d '{}'
|
4
shuffle/backend/tests/upload.sh
Normal file
4
shuffle/backend/tests/upload.sh
Normal file
@ -0,0 +1,4 @@
|
||||
# hello
|
||||
this is line 2
|
||||
and 3
|
||||
Is it a python problem?
|
13
shuffle/backend/tests/users.sh
Normal file
13
shuffle/backend/tests/users.sh
Normal file
@ -0,0 +1,13 @@
|
||||
curl http://localhost:5001/api/v1/users/register -H "Authorization: Bearer 36a3eb38-0070-41c6-b20a-2a3e0941d10e" -d '{"username": "username1", "password": ""}'
|
||||
|
||||
echo
|
||||
curl http://localhost:5001/api/v1/users -H "Authorization: Bearer 36a3eb38-0070-41c6-b20a-2a3e0941d10e"
|
||||
|
||||
echo UPDATE
|
||||
curl -XPUT http://localhost:5001/api/v1/users/updateuser -H "Authorization: Bearer 36a3eb38-0070-41c6-b20a-2a3e0941d10e" -d '{"user_id": "id", "role": "admin"}'
|
||||
|
||||
echo
|
||||
curl -XDELETE http://localhost:5001/api/v1/users/userid -H "Authorization: Bearer 36a3eb38-0070-41c6-b20a-2a3e0941d10e"
|
||||
|
||||
echo
|
||||
curl -XPOST http://localhost:5001/api/v1/users/generateapikey -H "Authorization: Bearer 36a3eb38-0070-41c6-b20a-2a3e0941d10e" -d '{"user_id": "390efa79-73a3-454b-8b1d-38f56eec14ad"}'
|
14
shuffle/backend/tests/validate_app_values.sh
Normal file
14
shuffle/backend/tests/validate_app_values.sh
Normal file
@ -0,0 +1,14 @@
|
||||
# ExecutionOrg MUST be executing.
|
||||
curl -XPOST http://localhost:5001/api/v1/orgs/b199646b-16d2-456d-9fd6-b9972e929466/validate_app_values -d '{
|
||||
"append": true,
|
||||
"workflow_check": true,
|
||||
"authorization": "1aae630c-ccaf-4cb5-87f9-8a9e0a9afd11",
|
||||
"execution_ref": "c59ff288-4f02-4d02-b839-133d55c7fdf0",
|
||||
"org_id": "b199646b-16d2-456d-9fd6-b9972e929466",
|
||||
"values": [{
|
||||
"app": "testing",
|
||||
"action": "repeat_back_to_me",
|
||||
"parameternames": ["call"],
|
||||
"parametervalues": ["hey", "ho", "lets", "go"]
|
||||
}]
|
||||
}'
|
4
shuffle/backend/tests/websocket.sh
Normal file
4
shuffle/backend/tests/websocket.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
curl http://localhost:5001/ws -H "Connections: Upgrade"
|
||||
|
||||
#curl -X POST "https://europe-west1-shuffle-241517.cloudfunctions.net/webhook_982995716e67c3a549092d3a3a7921cd" -H "Content-Type:application/json" -H "Authorization: Bearer 144308d0-6aab-4d4f-8bb2-75189281ee26" --data '{"name":"Keyboard Cat"}' -v
|
202
shuffle/backend/tests/workflowdata.json
Normal file
202
shuffle/backend/tests/workflowdata.json
Normal file
@ -0,0 +1,202 @@
|
||||
[
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"app_name": "hello_world",
|
||||
"app_version": "1.0.0",
|
||||
"errors": [],
|
||||
"id_": "2686a5d4-531d-158f-6b1a-0c1d23481304",
|
||||
"is_valid": true,
|
||||
"label": "check_bool",
|
||||
"name": "check_bool",
|
||||
"environment": "cloud",
|
||||
"parameters": [],
|
||||
"position": {
|
||||
"x": 329.98133726556375,
|
||||
"y": 160.01013778166904
|
||||
},
|
||||
"priority": 3
|
||||
}
|
||||
],
|
||||
"branches": [
|
||||
{
|
||||
"destination_id": "6478ecae-b10e-88e9-e34d-9bbe6aff393d",
|
||||
"id_": "5fd6a357-ae33-b1af-5dc2-0306efa28887",
|
||||
"source_id": "2686a5d4-531d-158f-6b1a-0c1d23481304"
|
||||
},
|
||||
{
|
||||
"destination_id": "2686a5d4-531d-158f-6b1a-0c1d23481304",
|
||||
"id_": "d46d0b05-5757-5084-c339-70ac63985781",
|
||||
"source_id": "6478ecae-b10e-88e9-e34d-9bbe6aff393d"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"app_name": "Builtin",
|
||||
"app_version": "1.0.0",
|
||||
"conditional": "",
|
||||
"errors": [],
|
||||
"id_": "6478ecae-b10e-88e9-e34d-9bbe6aff393d",
|
||||
"is_valid": true,
|
||||
"label": "Condition",
|
||||
"name": "Condition",
|
||||
"position": {
|
||||
"x": 320.97142988802364,
|
||||
"y": 394.9753467582139
|
||||
}
|
||||
}
|
||||
],
|
||||
"description": "",
|
||||
"errors": [],
|
||||
"id_": "a5f82cfd-0f38-3474-20e2-f757f3718707",
|
||||
"is_valid": true,
|
||||
"name": "asd2",
|
||||
"start": "2686a5d4-531d-158f-6b1a-0c1d23481304",
|
||||
"tags": [],
|
||||
"transforms": [],
|
||||
"triggers": [],
|
||||
"workflow_variables": []
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"app_name": "hello_world",
|
||||
"app_version": "1.0.0",
|
||||
"errors": [],
|
||||
"id_": "51df7c4f-b856-1aca-402b-9fec660b6505",
|
||||
"is_valid": true,
|
||||
"label": "wut",
|
||||
"name": "hello_world",
|
||||
"parameters": [],
|
||||
"position": {
|
||||
"x": 250,
|
||||
"y": 150
|
||||
},
|
||||
"priority": 3
|
||||
},
|
||||
{
|
||||
"app_name": "hello_world",
|
||||
"app_version": "1.0.0",
|
||||
"errors": [],
|
||||
"id_": "36975212-3b9a-2e4c-4ad7-0ee5a6325842",
|
||||
"is_valid": true,
|
||||
"label": "check_bool",
|
||||
"name": "check_bool",
|
||||
"parameters": [],
|
||||
"position": {
|
||||
"x": 241.00207363715955,
|
||||
"y": 294.9896318142021
|
||||
},
|
||||
"priority": 3
|
||||
}
|
||||
],
|
||||
"branches": [
|
||||
{
|
||||
"destination_id": "36975212-3b9a-2e4c-4ad7-0ee5a6325842",
|
||||
"id_": "44231b8f-4331-764e-0c1d-ccbc901d1309",
|
||||
"source_id": "51df7c4f-b856-1aca-402b-9fec660b6505"
|
||||
},
|
||||
{
|
||||
"destination_id": "51df7c4f-b856-1aca-402b-9fec660b6505",
|
||||
"id_": "9b3dc561-e879-4877-c32e-ab7149d83b39",
|
||||
"source_id": "36975212-3b9a-2e4c-4ad7-0ee5a6325842"
|
||||
}
|
||||
],
|
||||
"conditions": [],
|
||||
"description": "",
|
||||
"errors": [],
|
||||
"id_": "4e437698-fc18-29d3-e875-969b57354685",
|
||||
"is_valid": true,
|
||||
"name": "hi",
|
||||
"start": "51df7c4f-b856-1aca-402b-9fec660b6505",
|
||||
"tags": [],
|
||||
"transforms": [],
|
||||
"triggers": [],
|
||||
"workflow_variables": []
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"app_name": "hello_world",
|
||||
"app_version": "1.0.0",
|
||||
"errors": [],
|
||||
"id_": "d0dbd1c4-dd61-6d4a-70e1-ac05dad0fe1f",
|
||||
"is_valid": true,
|
||||
"label": "i am bool",
|
||||
"name": "check_bool",
|
||||
"parameters": [],
|
||||
"position": {
|
||||
"x": 377.9998262128892,
|
||||
"y": 330.01190441708906
|
||||
},
|
||||
"priority": 3
|
||||
},
|
||||
{
|
||||
"app_name": "hello_world",
|
||||
"app_version": "1.0.0",
|
||||
"errors": [],
|
||||
"id_": "39353c1c-b179-152c-f977-615a15a5de37",
|
||||
"is_valid": true,
|
||||
"label": "hello_world",
|
||||
"name": "hello_world",
|
||||
"parameters": [],
|
||||
"position": {
|
||||
"x": 375.2590614780782,
|
||||
"y": 160.6226941577116
|
||||
},
|
||||
"priority": 3
|
||||
}
|
||||
],
|
||||
"branches": [
|
||||
{
|
||||
"destination_id": "d0dbd1c4-dd61-6d4a-70e1-ac05dad0fe1f",
|
||||
"id_": "7c81993f-5fd6-fc83-2f41-8074d6c8dc25",
|
||||
"source_id": "39353c1c-b179-152c-f977-615a15a5de37"
|
||||
}
|
||||
],
|
||||
"conditions": [],
|
||||
"description": "",
|
||||
"errors": [],
|
||||
"id_": "af8467be-43ca-d38b-3f7e-9aeb922fb21a",
|
||||
"is_valid": true,
|
||||
"name": "new!",
|
||||
"start": "39353c1c-b179-152c-f977-615a15a5de37",
|
||||
"tags": [],
|
||||
"transforms": [],
|
||||
"triggers": [],
|
||||
"workflow_variables": []
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"app_name": "Builtin",
|
||||
"app_version": "1.0.0",
|
||||
"errors": [],
|
||||
"id_": "7dddec9a-b493-8b58-9234-1b74dd9b420a",
|
||||
"is_valid": true,
|
||||
"label": "Boolean",
|
||||
"name": "Boolean",
|
||||
"parameters": [],
|
||||
"position": {
|
||||
"x": 350,
|
||||
"y": 250
|
||||
},
|
||||
"priority": 3
|
||||
}
|
||||
],
|
||||
"branches": [],
|
||||
"conditions": [],
|
||||
"description": "",
|
||||
"errors": [
|
||||
"Action Builtin.Boolean does not exist"
|
||||
],
|
||||
"id_": "07bae551-21e6-c0f5-4db3-81e8a1e8a805",
|
||||
"is_valid": false,
|
||||
"name": "wutface",
|
||||
"start": "7dddec9a-b493-8b58-9234-1b74dd9b420a",
|
||||
"tags": [],
|
||||
"transforms": [],
|
||||
"triggers": [],
|
||||
"workflow_variables": []
|
||||
}
|
||||
]
|
23
shuffle/backend/tests/workflowresults.sh
Normal file
23
shuffle/backend/tests/workflowresults.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#curl -X POST -H "Content-Type: application/json" localhost:5001/api/v1/workflows/3d14ca4a-67bd-8dfb-2673-2864f1ccf59c/execute -d '{"workflow_id": "3d14ca4a-67bd-8dfb-2673-2864f1ccf59c", "execution_id": "eaaa8d19-a761-12b8-cac2-f34eb50c3711"}'
|
||||
|
||||
curl -X POST -H "Content-Type: application/json" https://shuffle-241517.appspot.com/api/v1/workflows/3d14ca4a-67bd-8dfb-2673-2864f1ccf59c/execute -d '{"workflow_id": "3d14ca4a-67bd-8dfb-2673-2864f1ccf59c", "execution_id": "eaaa8d19-a761-12b8-cac2-f34eb50c3711"}'
|
||||
|
||||
#curl -X POST http://localhost:5001/api/v1/workflows/streams -H "Content-Type: application/json" \
|
||||
# -d '{"execution_id": "eaaa8d19-a761-12b8-cac2-f34eb50c3711",
|
||||
# "result": "hello_result",
|
||||
# "started_at": 1562309342,
|
||||
# "authorization": "afcc298d-c6c2-4b0d-8221-1603b44d072d",
|
||||
# "status": "ABORTED",
|
||||
# "action": {
|
||||
# "app_name": "hi",
|
||||
# "app_version": "ho",
|
||||
# "id_": "this_is_an_id",
|
||||
# "label": "wut",
|
||||
# "name": "stream_testing",
|
||||
# "parameters": [],
|
||||
# "position": {
|
||||
# "x": 100,
|
||||
# "y": 100
|
||||
# },
|
||||
# "priority": 1
|
||||
# }}'
|
15
shuffle/backend/tests/workflows.sh
Normal file
15
shuffle/backend/tests/workflows.sh
Normal file
@ -0,0 +1,15 @@
|
||||
# Get all workflows
|
||||
curl localhost:5001/api/v1/workflows
|
||||
|
||||
# Get A workflow
|
||||
#curl localhost:5001/api/v1/workflows/a5f82cfd-0f38-3474-20e2-f757f3718707
|
||||
|
||||
# NEW workflow
|
||||
# curl -XPOST localhost:5001/api/v1/workflows -d '{"tags":[],"actions":[],"branches":[],"conditions":[{"label":"Condition","app_name":"Builtin","name":"Condition","conditional":"","id_":"18165f42-aab9-6c9a-0ef4-4e5a37a3b2ad","app_version":"1.0.0","position":{"x":224,"y":168}}],"workflow_variables":[],"name":"asd","start":"18165f42-aab9-6c9a-0ef4-4e5a37a3b2ad","id_":"3d14ca4a-67bd-8dfb-2673-2864f1ccf59c"}'
|
||||
|
||||
# Add a workflow
|
||||
#curl localhost:5001/api/v1/workflows/a5f82cfd-0f38-3474-20e2-f757f3718707 -d '{"actions":[{"app_name":"hello_world","app_version":"1.0.0","errors":[],"id_":"2686a5d4-531d-158f-6b1a-0c1d23481304","is_valid":true,"label":"check_bool","name":"check_bool","parameters":[],"position":{"x":329.98133726556375,"y":160.01013778166904},"priority":3}],"branches":[{"destination_id":"6478ecae-b10e-88e9-e34d-9bbe6aff393d","id_":"5fd6a357-ae33-b1af-5dc2-0306efa28887","source_id":"2686a5d4-531d-158f-6b1a-0c1d23481304"},{"destination_id":"2686a5d4-531d-158f-6b1a-0c1d23481304","id_":"d46d0b05-5757-5084-c339-70ac63985781","source_id":"6478ecae-b10e-88e9-e34d-9bbe6aff393d"}],"conditions":[{"app_name":"Builtin","app_version":"1.0.0","conditional":"","errors":[],"id_":"6478ecae-b10e-88e9-e34d-9bbe6aff393d","is_valid":true,"label":"Condition","name":"Condition","position":{"x":320.97142988802364,"y":394.9753467582139}}],"description":"","errors":[],"id_":"a5f82cfd-0f38-3474-20e2-f757f3718707","is_valid":true,"name":"asd2","start":"2686a5d4-531d-158f-6b1a-0c1d23481304","tags":[],"transforms":[],"triggers":[],"workflow_variables":[]}'
|
||||
|
||||
# Execute a workflow
|
||||
# curl -H "Content-Type: application/json" localhost:5001/api/v1/workflows/3d14ca4a-67bd-8dfb-2673-2864f1ccf59c/execute
|
||||
#curl -X POST -H "Content-Type: application/json" localhost:5001/api/v1/workflows/3d14ca4a-67bd-8dfb-2673-2864f1ccf59c/execute -d '{"workflow_id": "3d14ca4a-67bd-8dfb-2673-2864f1ccf59c", "execution_id": "eaaa8d19-a761-12b8-cac2-f34eb50c3711"}'
|
Reference in New Issue
Block a user