index param is required for /fragment/nodes

This commit is contained in:
Yuce Tekol 2018-04-05 22:29:03 +03:00
parent 1764d5a9bf
commit cc521e5c91
No known key found for this signature in database
GPG key ID: CB59E46D2FB90573
2 changed files with 8 additions and 1 deletions

View file

@ -122,7 +122,7 @@ func BuildRouters(handler *Handler) {
func (h *Handler) populateValidators() {
h.validators = map[string]*queryValidationSpec{}
h.validators["GetFragmentNodes"] = QueryValidationSpecRequired("slice").Optional("index")
h.validators["GetFragmentNodes"] = QueryValidationSpecRequired("slice", "index")
h.validators["GetSliceMax"] = QueryValidationSpecRequired().Optional("inverse")
h.validators["PostQuery"] = QueryValidationSpecRequired().Optional("slices", "columnAttrs", "excludeAttrs", "excludeBits")
h.validators["GetExport"] = QueryValidationSpecRequired("index", "frame", "view", "slice")

View file

@ -1225,6 +1225,13 @@ func TestHandler_Fragment_Nodes(t *testing.T) {
t.Fatalf("unexpected status code: %d", w.Code)
}
// index is required
w = httptest.NewRecorder()
r = test.MustNewHTTPRequest("GET", "/fragment/nodes?slice=0", nil)
h.ServeHTTP(w, r)
if w.Code != http.StatusBadRequest {
t.Fatalf("unexpected status code: %d", w.Code)
}
}
// Ensure the handler can return expvars without panicking.