Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
e80315f5
Unverified
Commit
e80315f5
authored
Mar 13, 2024
by
Yeuoly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: allow None AuthorizationConfig
parent
1f4826ca
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
entities.py
api/core/workflow/nodes/http_request/entities.py
+15
-2
test_http.py
api/tests/integration_tests/workflow/nodes/test_http.py
+30
-0
No files found.
api/core/workflow/nodes/http_request/entities.py
View file @
e80315f5
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'
]
...
...
api/tests/integration_tests/workflow/nodes/test_http.py
View file @
e80315f5
...
@@ -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
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment