Add debug API endpoint for mail template rendering#830
Add debug API endpoint for mail template rendering#830
Conversation
9f10ae5 to
30e7863
Compare
|
|
||
| Renders the mail template of the respective type using dummy values and | ||
| verifies that the generated content is valid HTML. | ||
| Requires the `?template_type` query parameter. No newline at end of file |
There was a problem hiding this comment.
| Requires the `?template_type` query parameter. | |
| Requires the `template_type` query parameter. |
There was a problem hiding this comment.
The ? was added to be consistent with the existing admin endpoints documentation
| case "transferred_commitments": | ||
| template = mailConfig.Templates.ConfirmedCommitments | ||
| default: | ||
| http.Error(w, "invalid template type", http.StatusBadRequest) |
There was a problem hiding this comment.
Should we list available templates here? The user needs admin anyhow, so we don't leak anything, right?
5975026 to
f9975ec
Compare
wagnerd3
left a comment
There was a problem hiding this comment.
I think this current state would be sufficient for me right now.
There was a problem hiding this comment.
Pull request overview
Adds an admin-only debug endpoint to render configured mail templates using dummy data, primarily to help validate mail template rendering during development/testing.
Changes:
- Add
GET /admin/mail/renderendpoint that renders a chosen template type using dummy commitment data. - Extend test setup with
WithMailTemplatesand add an API test covering auth and parameter validation. - Vendor
golang.org/x/net/html(and updatego.mod/go.sum/vendor/modules.txt) to parse the rendered output.
Reviewed changes
Copilot reviewed 6 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
internal/api/mail.go |
Implements the new mail template render endpoint and HTML parse check. |
internal/api/core.go |
Registers the new route in the v1 API router. |
internal/api/mail_test.go |
Adds tests for permissions and request parameter validation. |
internal/test/setup.go |
Adds WithMailTemplates option to inject dummy mail templates for tests. |
docs/users/api-spec-resources.md |
Documents the new endpoint and its query parameter. |
go.mod |
Adds direct dependency on golang.org/x/net. |
go.sum |
Updates checksums for updated golang.org/x/* dependencies. |
vendor/modules.txt |
Reflects newly vendored golang.org/x/net and updated golang.org/x/sys. |
vendor/golang.org/x/net/html/token.go |
Vendored HTML tokenizer implementation. |
vendor/golang.org/x/net/html/render.go |
Vendored HTML renderer implementation. |
vendor/golang.org/x/net/html/parse.go |
Vendored HTML parser implementation. |
vendor/golang.org/x/net/html/node.go |
Vendored DOM node model implementation. |
vendor/golang.org/x/net/html/iter.go |
Vendored iterator helpers for node traversal (go build tag). |
vendor/golang.org/x/net/html/foreign.go |
Vendored foreign content parsing helpers (SVG/MathML). |
vendor/golang.org/x/net/html/escape.go |
Vendored HTML escaping/unescaping helpers. |
vendor/golang.org/x/net/html/doctype.go |
Vendored doctype parsing logic. |
vendor/golang.org/x/net/html/doc.go |
Vendored package documentation. |
vendor/golang.org/x/net/html/const.go |
Vendored parsing constants/helpers. |
vendor/golang.org/x/net/html/atom/table.go |
Vendored generated atom table for tags/attrs. |
vendor/golang.org/x/net/html/atom/atom.go |
Vendored atom lookup implementation. |
vendor/golang.org/x/net/LICENSE |
Vendored license for golang.org/x/net. |
vendor/golang.org/x/net/PATENTS |
Vendored patents grant for golang.org/x/net. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f9975ec to
cebced3
Compare
cebced3 to
123d050
Compare
|
The tests are failing since with the test cases added in this PR, the total amount of tests exceeds the concurrency limit of postgres connections in our testing setup. Increasing the amount of |
|
It's in go-bits 😅 fix at sapcc/go-bits#292 |
123d050 to
387c935
Compare
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
Checklist: