frontend: add filtering by protocol type to summary tables (#40)

* frontend: add option to filter by protocol type

Closes #33.

* frontend: use case insensitive comparisons for protocol filter
This commit is contained in:
James Lu
2021-09-07 13:17:16 -07:00
committed by GitHub
parent a64d839e2c
commit 2166d73b3d
4 changed files with 60 additions and 0 deletions

View File

@@ -77,3 +77,36 @@ func TestSummaryTableXSS(t *testing.T) {
t.Errorf("XSS injection succeeded: %s", result)
}
}
func TestSummaryTableProtocolFilter(t *testing.T) {
initSettings()
setting.protocolFilter = []string{"Static", "Direct", "Babel"}
data := `BIRD 2.0.8 ready.
Name Proto Table State Since Info
static1 Static master4 up 2021-08-27
static2 Static master6 up 2021-08-27
device1 Device --- up 2021-08-27
kernel1 Kernel master6 up 2021-08-27
kernel2 Kernel master4 up 2021-08-27
direct1 Direct --- up 2021-08-27
int_babel Babel --- up 2021-08-27 `
result := summaryTable(data, "testserver")
expectedInclude := []string{"static1", "static2", "int_babel", "direct1"}
expectedExclude := []string{"device1", "kernel1", "kernel2"}
for _, item := range expectedInclude {
if !strings.Contains(result, item) {
t.Errorf("Did not find expected %s in summary table output", result)
}
}
for _, item := range expectedExclude {
if strings.Contains(result, item) {
t.Errorf("Found unexpected %s in summary table output", result)
}
}
t.Cleanup(func() {
setting.protocolFilter = []string{}
})
}