Add bad request status code for wrong action
This commit is contained in:
parent
7d61179ee1
commit
226a35fb43
|
@ -108,7 +108,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
cons := newConsumer(conn)
|
||||
h.backend.AddEventListener(cons)
|
||||
} else {
|
||||
http.Error(w, fmt.Sprintf("unknown action %s\n", action), 500)
|
||||
http.Error(w, fmt.Sprintf("unknown action %s\n", action), 400)
|
||||
return
|
||||
}
|
||||
return
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
@ -131,3 +132,18 @@ func TestServer_Search(t *testing.T) {
|
|||
assert.Equal(t, "test", feeds[0].Description)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_UnknownAction(t *testing.T) {
|
||||
server, c := createServerClient()
|
||||
defer server.Close()
|
||||
|
||||
u := c.MicrosubEndpoint
|
||||
q := u.Query()
|
||||
q.Add("action", "missing")
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
resp, err := http.Get(u.String())
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, 400, resp.StatusCode)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user