mirror of https://github.com/statping/statping
api fix
parent
940a3e1582
commit
345cc25512
|
@ -235,7 +235,6 @@ func apiNotifierUpdateHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
var notification *notifier.Notification
|
var notification *notifier.Notification
|
||||||
fmt.Println(r.Body)
|
|
||||||
decoder := json.NewDecoder(r.Body)
|
decoder := json.NewDecoder(r.Body)
|
||||||
err := decoder.Decode(¬ification)
|
err := decoder.Decode(¬ification)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -247,7 +246,6 @@ func apiNotifierUpdateHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sendErrorJson(err, w, r)
|
sendErrorJson(err, w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
notifer.Var1 = notification.Var1
|
notifer.Var1 = notification.Var1
|
||||||
notifer.Var2 = notification.Var2
|
notifer.Var2 = notification.Var2
|
||||||
notifer.Host = notification.Host
|
notifer.Host = notification.Host
|
||||||
|
|
|
@ -363,6 +363,18 @@ func TestPrometheusHandler(t *testing.T) {
|
||||||
assert.True(t, isRouteAuthenticated(req))
|
assert.True(t, isRouteAuthenticated(req))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpdateNotificationHandler(t *testing.T) {
|
||||||
|
t.SkipNow()
|
||||||
|
data := `{"limits": 7, "enabled": true, "method": "email", "host": "smtp.emailserver.com", "username": "exampleuser", "password": "password123", "port": 543, "var1": "info@betatude.com", "var2": "sendto@gmail.com"}`
|
||||||
|
rr, err := httpRequestAPI(t, "POST", "/api/notifier/email", strings.NewReader(data))
|
||||||
|
assert.Nil(t, err)
|
||||||
|
body := rr.Body.String()
|
||||||
|
var obj apiResponse
|
||||||
|
formatJSON(body, &obj)
|
||||||
|
assert.Equal(t, 200, rr.Code)
|
||||||
|
assert.Equal(t, "success", obj.Status)
|
||||||
|
}
|
||||||
|
|
||||||
func TestViewNotificationSettingsHandler(t *testing.T) {
|
func TestViewNotificationSettingsHandler(t *testing.T) {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
req, err := http.NewRequest("GET", "/settings", nil)
|
req, err := http.NewRequest("GET", "/settings", nil)
|
||||||
|
|
|
@ -280,6 +280,9 @@ func httpRequestAPI(t *testing.T, method, url string, body io.Reader) (*httptest
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if body != nil {
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
}
|
||||||
req.Header.Set("Authorization", core.CoreApp.ApiSecret)
|
req.Header.Set("Authorization", core.CoreApp.ApiSecret)
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
Router().ServeHTTP(rr, req)
|
Router().ServeHTTP(rr, req)
|
||||||
|
|
Loading…
Reference in New Issue