Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
vicotor
mybee
Commits
f63a42cf
Commit
f63a42cf
authored
Jan 29, 2020
by
Janos Guljas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test invalid peer address in debug api peerDisconnectHandler
parent
f66ddb50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
peer.go
pkg/debugapi/peer.go
+1
-1
peer_test.go
pkg/debugapi/peer_test.go
+7
-0
No files found.
pkg/debugapi/peer.go
View file @
f63a42cf
...
@@ -44,7 +44,7 @@ func (s *server) peerDisconnectHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -44,7 +44,7 @@ func (s *server) peerDisconnectHandler(w http.ResponseWriter, r *http.Request) {
addr
:=
mux
.
Vars
(
r
)[
"address"
]
addr
:=
mux
.
Vars
(
r
)[
"address"
]
swarmAddr
,
err
:=
swarm
.
ParseHexAddress
(
addr
)
swarmAddr
,
err
:=
swarm
.
ParseHexAddress
(
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
s
.
Logger
.
Debugf
(
"debug api: p
eer disconnect
%s: %v"
,
addr
,
err
)
s
.
Logger
.
Debugf
(
"debug api: p
arse peer address
%s: %v"
,
addr
,
err
)
jsonhttp
.
BadRequest
(
w
,
"invalid peer address"
)
jsonhttp
.
BadRequest
(
w
,
"invalid peer address"
)
return
return
}
}
...
...
pkg/debugapi/peer_test.go
View file @
f63a42cf
...
@@ -91,6 +91,13 @@ func TestDisconnect(t *testing.T) {
...
@@ -91,6 +91,13 @@ func TestDisconnect(t *testing.T) {
})
})
})
})
t
.
Run
(
"invalid peer address"
,
func
(
t
*
testing
.
T
)
{
jsonhttptest
.
ResponseDirect
(
t
,
client
,
http
.
MethodDelete
,
"/peers/invalid-address"
,
nil
,
http
.
StatusBadRequest
,
jsonhttp
.
StatusResponse
{
Code
:
http
.
StatusBadRequest
,
Message
:
"invalid peer address"
,
})
})
t
.
Run
(
"error"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"error"
,
func
(
t
*
testing
.
T
)
{
jsonhttptest
.
ResponseDirect
(
t
,
client
,
http
.
MethodDelete
,
"/peers/"
+
errorAddress
.
String
(),
nil
,
http
.
StatusInternalServerError
,
jsonhttp
.
StatusResponse
{
jsonhttptest
.
ResponseDirect
(
t
,
client
,
http
.
MethodDelete
,
"/peers/"
+
errorAddress
.
String
(),
nil
,
http
.
StatusInternalServerError
,
jsonhttp
.
StatusResponse
{
Code
:
http
.
StatusInternalServerError
,
Code
:
http
.
StatusInternalServerError
,
...
...
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