Commit f63a42cf authored by Janos Guljas's avatar Janos Guljas

test invalid peer address in debug api peerDisconnectHandler

parent f66ddb50
......@@ -44,7 +44,7 @@ func (s *server) peerDisconnectHandler(w http.ResponseWriter, r *http.Request) {
addr := mux.Vars(r)["address"]
swarmAddr, err := swarm.ParseHexAddress(addr)
if err != nil {
s.Logger.Debugf("debug api: peer disconnect %s: %v", addr, err)
s.Logger.Debugf("debug api: parse peer address %s: %v", addr, err)
jsonhttp.BadRequest(w, "invalid peer address")
return
}
......
......@@ -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) {
jsonhttptest.ResponseDirect(t, client, http.MethodDelete, "/peers/"+errorAddress.String(), nil, http.StatusInternalServerError, jsonhttp.StatusResponse{
Code: http.StatusInternalServerError,
......
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