all the changes
This commit is contained in:
1 parent
94f30165f9
commit
f30adf05af
35 files changed
+2979
-1607
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package triage
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestClassify(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
in Input
|
||||
want Category
|
||||
}{
|
||||
{"wp 500 is a probe not an outage", Input{Status: 500, Route: "/wp"}, ScannerProbe},
|
||||
{"php 405 is a probe", Input{Status: 405, Route: "/index.php"}, ScannerProbe},
|
||||
{"ses.env", Input{Status: 404, Route: "/ses.env"}, ScannerProbe},
|
||||
{"yaml config 302", Input{Status: 302, Route: "/config/aws.yml"}, ScannerProbe},
|
||||
{"traversal", Input{Status: 404, Route: "/api/w/admins/get_log_file/../../../../proc/self/environ"}, ScannerProbe},
|
||||
{"credentials file", Input{Status: 404, Route: "/firebase-credentials.json"}, ScannerProbe},
|
||||
{"matrix rooms is not OOM", Input{Status: 200, Route: "/_matrix/client/r0/rooms/x/messages"}, ExpectedLifecycle},
|
||||
{"real api 404 stays stale", Input{Status: 404, Route: "/api/config"}, StaleReference},
|
||||
{"env 404", Input{Status: 404, Route: "/.env"}, ScannerProbe},
|
||||
{"git config 502", Input{Status: 502, Route: "/.git/config"}, ScannerProbe},
|
||||
{"poller 401", Input{Status: 401, Route: "/api/repos/available"}, ClientCredentialIssue},
|
||||
{"upstream 503", Input{Status: 503, Route: "/store/regions"}, DependencyUnreachable},
|
||||
{"real 500", Input{Status: 500, Route: "/"}, ServiceDefect},
|
||||
{"panic in message", Input{Message: "panic: nil pointer dereference"}, ServiceDefect},
|
||||
{"timeout flag", Input{IsTimeout: true, Message: "query"}, CapacitySaturation},
|
||||
{"dial error", Input{Message: "*websocket.dialerror: connection refused"}, DependencyUnreachable},
|
||||
{"missing commit", Input{Status: 404, Route: "/mats/repo/commit/{id}"}, StaleReference},
|
||||
{"cancellation", Input{IsCancellation: true, Message: "context canceled"}, ExpectedLifecycle},
|
||||
{"health", Input{Kind: "span", Status: 200, Route: "/readyz"}, ExpectedLifecycle},
|
||||
{"unknown", Input{Kind: "metric", Status: 418}, NeedsReview},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := Classify(c.in); got.Category != c.want {
|
||||
t.Errorf("%s: got %s (%s), want %s", c.name, got.Category, got.Rule, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProbeBeatsLifecycleFlags(t *testing.T) {
|
||||
if got := Classify(Input{Route: "/.env", IsRetry: true}); got.Category != ScannerProbe {
|
||||
t.Fatalf("got %s", got.Category)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user