feat(ui): Implement parameter to hide URL from results (#294)

* Add support for HideURL UI config parameter

* Redact whole URL when hide-url parameter is set to true

* Add integration test for hide-url functionality

* Document the hide-url config parameter in README

* Apply suggestions from code review

Co-authored-by: TwiN <twin@linux.com>

* Update test to have client config with 1ms timeout

* Re-align README tables

* Update core/endpoint_test.go

* Update core/endpoint_test.go

Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
asymness
2022-06-17 02:53:03 +05:00
committed by GitHub
parent 017847240d
commit 5807d76c2f
4 changed files with 35 additions and 1 deletions

View File

@ -396,6 +396,31 @@ func TestIntegrationEvaluateHealthWithError(t *testing.T) {
}
}
func TestIntegrationEvaluateHealthWithErrorAndHideURL(t *testing.T) {
endpoint := Endpoint{
Name: "invalid-url",
URL: "https://httpstat.us/200?sleep=100",
Conditions: []Condition{Condition("[STATUS] == 200")},
ClientConfig: &client.Config{
Timeout: 1 * time.Millisecond,
},
UIConfig: &ui.Config{
HideURL: true,
},
}
endpoint.ValidateAndSetDefaults()
result := endpoint.EvaluateHealth()
if result.Success {
t.Error("Because one of the conditions was invalid, result.Success should have been false")
}
if len(result.Errors) == 0 {
t.Error("There should've been an error")
}
if !strings.Contains(result.Errors[0], "<redacted>") || strings.Contains(result.Errors[0], endpoint.URL) {
t.Error("result.Errors[0] should've had the URL redacted because ui.hide-url is set to true")
}
}
func TestIntegrationEvaluateHealthForDNS(t *testing.T) {
conditionSuccess := Condition("[DNS_RCODE] == NOERROR")
conditionBody := Condition("[BODY] == 93.184.216.34")