notify: the log names a notification endpoint, not its webhook URL (closes #288)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
With debug logging on, each delivery logged the full Slack, Mattermost or ntfy URL, whose path or query lets anyone who has it post to the channel or topic. The two debug lines now give the endpoint's name and the title; sendSlack is told which of Slack or Mattermost it sends to. A webhook URL that does not parse gave a startup error quoting the whole URL; it now gives only the reason. Errors from a failed request come from the transport, not from an HTTP client, and carry no part of the path or query; a test now checks that too. Model: opus-5-5
This commit was merged in pull request #294.
This commit is contained in:
@@ -79,6 +79,23 @@ func TestValidateWebhookURLInvalid(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestValidateWebhookURLErrorOmitsURL checks that the error for a
|
||||
// webhook URL that does not parse, here because a carriage return
|
||||
// was left at its end, leaves out the URL's path and query: the
|
||||
// error is logged at startup.
|
||||
func TestValidateWebhookURLErrorOmitsURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := notify.ValidateWebhookURL(
|
||||
"https://hooks.example.com" + webhookPathAndQuery + "\r",
|
||||
)
|
||||
if err == nil {
|
||||
t.Fatal("expected an error for a URL ending in a carriage return")
|
||||
}
|
||||
|
||||
assertNoWebhookSecret(t, err.Error())
|
||||
}
|
||||
|
||||
func TestIsAllowedScheme(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user