Unverified Commit 0a12ddcb authored by Yeuoly's avatar Yeuoly

Merge branch 'feat/workflow-backend' into deploy/dev

parents 5ab12077 e80315f5
...@@ -134,5 +134,5 @@ SSRF_PROXY_HTTPS_URL= ...@@ -134,5 +134,5 @@ SSRF_PROXY_HTTPS_URL=
BATCH_UPLOAD_LIMIT=10 BATCH_UPLOAD_LIMIT=10
# CODE EXECUTION CONFIGURATION # CODE EXECUTION CONFIGURATION
CODE_EXECUTION_ENDPOINT= CODE_EXECUTION_ENDPOINT=http://127.0.0.1:8194
CODE_EXECUTION_API_KEY= CODE_EXECUTION_API_KEY=dify-sandbox
from typing import Literal, Optional, Union from typing import Literal, Optional, Union
from pydantic import BaseModel from pydantic import BaseModel, validator
from core.workflow.entities.base_node_data_entities import BaseNodeData from core.workflow.entities.base_node_data_entities import BaseNodeData
from core.workflow.entities.variable_entities import VariableSelector from core.workflow.entities.variable_entities import VariableSelector
...@@ -17,7 +17,20 @@ class HttpRequestNodeData(BaseNodeData): ...@@ -17,7 +17,20 @@ class HttpRequestNodeData(BaseNodeData):
header: Union[None, str] header: Union[None, str]
type: Literal['no-auth', 'api-key'] type: Literal['no-auth', 'api-key']
config: Config config: Optional[Config]
@validator('config', always=True, pre=True)
def check_config(cls, v, values):
"""
Check config, if type is no-auth, config should be None, otherwise it should be a dict.
"""
if values['type'] == 'no-auth':
return None
else:
if not v or not isinstance(v, dict):
raise ValueError('config should be a dict')
return v
class Body(BaseModel): class Body(BaseModel):
type: Literal[None, 'form-data', 'x-www-form-urlencoded', 'raw', 'json'] type: Literal[None, 'form-data', 'x-www-form-urlencoded', 'raw', 'json']
......
...@@ -95,7 +95,7 @@ class IfElseNode(BaseNode): ...@@ -95,7 +95,7 @@ class IfElseNode(BaseNode):
return NodeRunResult( return NodeRunResult(
status=WorkflowNodeExecutionStatus.FAILED, status=WorkflowNodeExecutionStatus.FAILED,
inputs=node_inputs, inputs=node_inputs,
process_datas=process_datas, process_data=process_datas,
error=str(e) error=str(e)
) )
...@@ -107,7 +107,7 @@ class IfElseNode(BaseNode): ...@@ -107,7 +107,7 @@ class IfElseNode(BaseNode):
return NodeRunResult( return NodeRunResult(
status=WorkflowNodeExecutionStatus.SUCCEEDED, status=WorkflowNodeExecutionStatus.SUCCEEDED,
inputs=node_inputs, inputs=node_inputs,
process_datas=process_datas, process_data=process_datas,
edge_source_handle="false" if not compare_result else "true", edge_source_handle="false" if not compare_result else "true",
outputs={ outputs={
"result": compare_result "result": compare_result
......
...@@ -54,6 +54,36 @@ def test_get(setup_http_mock): ...@@ -54,6 +54,36 @@ def test_get(setup_http_mock):
assert 'api-key: Basic ak-xxx' in data assert 'api-key: Basic ak-xxx' in data
assert 'X-Header: 123' in data assert 'X-Header: 123' in data
@pytest.mark.parametrize('setup_http_mock', [['none']], indirect=True)
def test_no_auth(setup_http_mock):
node = HttpRequestNode(config={
'id': '1',
'data': {
'title': 'http',
'desc': '',
'variables': [{
'variable': 'args1',
'value_selector': ['1', '123', 'args1'],
}],
'method': 'get',
'url': 'http://example.com',
'authorization': {
'type': 'no-auth',
'config': None,
},
'headers': 'X-Header:123',
'params': 'A:b',
'body': None,
}
}, **BASIC_NODE_DATA)
result = node.run(pool)
data = result.process_data.get('request', '')
assert '?A=b' in data
assert 'X-Header: 123' in data
@pytest.mark.parametrize('setup_http_mock', [['none']], indirect=True) @pytest.mark.parametrize('setup_http_mock', [['none']], indirect=True)
def test_template(setup_http_mock): def test_template(setup_http_mock):
node = HttpRequestNode(config={ node = HttpRequestNode(config={
......
...@@ -55,9 +55,12 @@ services: ...@@ -55,9 +55,12 @@ services:
sandbox: sandbox:
image: langgenius/dify-sandbox:latest image: langgenius/dify-sandbox:latest
restart: always restart: always
cap_add:
- SYS_ADMIN
environment: environment:
# The DifySandbox configurations # The DifySandbox configurations
API_KEY: dify-sandbox API_KEY: dify-sandbox
GIN_MODE: 'release'
ports: ports:
- "8194:8194" - "8194:8194"
......
...@@ -293,9 +293,12 @@ services: ...@@ -293,9 +293,12 @@ services:
sandbox: sandbox:
image: langgenius/dify-sandbox:latest image: langgenius/dify-sandbox:latest
restart: always restart: always
cap_add:
- SYS_ADMIN
environment: environment:
# The DifySandbox configurations # The DifySandbox configurations
API_KEY: dify-sandbox API_KEY: dify-sandbox
GIN_MODE: release
ports: ports:
- "8194:8194" - "8194:8194"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment