mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 16:57:14 -06:00
Alerting: Fix misleading status code in provisioning API (#67331)
Fixes #66249
This commit is contained in:
parent
dd6cda1511
commit
dfc99cdd19
@ -266,6 +266,9 @@ func (srv *ProvisioningSrv) RouteGetAlertRules(c *contextmodel.ReqContext) respo
|
||||
func (srv *ProvisioningSrv) RouteRouteGetAlertRule(c *contextmodel.ReqContext, UID string) response.Response {
|
||||
rule, provenace, err := srv.alertRules.GetAlertRule(c.Req.Context(), c.OrgID, UID)
|
||||
if err != nil {
|
||||
if errors.Is(err, alerting_models.ErrAlertRuleNotFound) {
|
||||
return response.Empty(http.StatusNotFound)
|
||||
}
|
||||
return ErrResp(http.StatusInternalServerError, err, "")
|
||||
}
|
||||
return response.JSON(http.StatusOK, ProvisionedAlertRuleFromAlertRule(rule, provenace))
|
||||
|
@ -307,6 +307,14 @@ func TestProvisioningApi(t *testing.T) {
|
||||
require.Equal(t, 404, response.Status())
|
||||
})
|
||||
|
||||
t.Run("are missing, GET returns 404", func(t *testing.T) {
|
||||
sut := createProvisioningSrvSut(t)
|
||||
rc := createTestRequestCtx()
|
||||
response := sut.RouteRouteGetAlertRule(&rc, "does not exist")
|
||||
|
||||
require.Equal(t, 404, response.Status())
|
||||
})
|
||||
|
||||
t.Run("have reached the rule quota, POST returns 403", func(t *testing.T) {
|
||||
env := createTestEnv(t)
|
||||
quotas := provisioning.MockQuotaChecker{}
|
||||
|
Loading…
Reference in New Issue
Block a user