Alerting: Provisioning message templates (#48665)

* Generate API for writing templates

* Persist templates app logic layer

* Validate templates

* Extract logic, make set and delete methods

* Drop post route for templates

* Fix response details, wire up remainder of API

* Authorize routes

* Mirror some existing tests on new APIs

* Generate mock for prov store

* Wire up prov store mock, add tests using it

* Cover cases for both storage paths

* Add happy path tests and fix bugs if file contains no template section

* Normalize template content with define statement

* Tests for deletion

* Fix linter error

* Move provenance field to DTO

* empty commit

* ID to name

* Fix in auth too
This commit is contained in:
Alexander Weaver
2022-05-05 15:21:42 -05:00
committed by GitHub
parent 6de77283c6
commit 0f56462fbe
12 changed files with 876 additions and 32 deletions

View File

@@ -183,13 +183,15 @@ func (api *API) authorize(method, path string) web.Handler {
case http.MethodGet + "/api/provisioning/policies",
http.MethodGet + "/api/provisioning/contact-points",
http.MethodGet + "/api/provisioning/templates",
http.MethodGet + "/api/provisioning/templates/{ID}":
http.MethodGet + "/api/provisioning/templates/{name}":
return middleware.ReqSignedIn
case http.MethodPost + "/api/provisioning/policies",
http.MethodPost + "/api/provisioning/contact-points",
http.MethodPut + "/api/provisioning/contact-points",
http.MethodDelete + "/api/provisioning/contact-points/{ID}":
http.MethodDelete + "/api/provisioning/contact-points/{ID}",
http.MethodPut + "/api/provisioning/templates/{name}",
http.MethodDelete + "/api/provisioning/templates/{name}":
return middleware.ReqEditorRole
}