mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
test: add a test for automatic entry of src and dst ports
This commit is contained in:
committed by
Vincent Bernat
parent
f92d2ef9e2
commit
7805aad457
@@ -132,6 +132,50 @@ LIMIT 20`, "6540").
|
|||||||
{"65402:200:100", "large community"},
|
{"65402:200:100", "large community"},
|
||||||
}).
|
}).
|
||||||
Return(nil)
|
Return(nil)
|
||||||
|
mockConn.EXPECT().
|
||||||
|
Select(gomock.Any(), gomock.Any(), `
|
||||||
|
SELECT label, detail FROM (
|
||||||
|
SELECT toString(SrcPort) AS label, dictGet('tcp', 'name', SrcPort) AS detail, 1 AS rank, count(*) AS c
|
||||||
|
FROM flows
|
||||||
|
WHERE TimeReceived > date_sub(minute, 1, now())
|
||||||
|
AND detail != ''
|
||||||
|
AND positionCaseInsensitive(detail, $1) >= 1
|
||||||
|
AND Proto = 6
|
||||||
|
GROUP BY SrcPort
|
||||||
|
ORDER BY COUNT(*) DESC
|
||||||
|
LIMIT 20
|
||||||
|
UNION DISTINCT
|
||||||
|
SELECT toString(SrcPort) AS label, dictGet(udp, 'name', SrcPort) AS detail, 1 AS rank, count(*) AS c
|
||||||
|
FROM flows
|
||||||
|
WHERE TimeReceived > date_sub(minute, 1, now())
|
||||||
|
AND detail != ''
|
||||||
|
AND positionCaseInsensitive(detail, $1) >= 1
|
||||||
|
AND Proto = 17
|
||||||
|
GROUP BY SrcPort
|
||||||
|
ORDER BY COUNT(*) DESC
|
||||||
|
LIMIT 20
|
||||||
|
UNION DISTINCT
|
||||||
|
SELECT toString(port) AS label, name AS detail, 2 AS rank, 0 AS c
|
||||||
|
FROM tcp
|
||||||
|
WHERE positionCaseInsensitive(name, $1) >= 1
|
||||||
|
ORDER BY positionCaseInsensitive(name, $1) ASC, port ASC
|
||||||
|
LIMIT 20
|
||||||
|
UNION DISTINCT
|
||||||
|
SELECT toString(port) AS label, name AS detail, 2 AS rank, 0 AS c
|
||||||
|
FROM udp
|
||||||
|
WHERE positionCaseInsensitive(name, $1) >= 1
|
||||||
|
ORDER BY positionCaseInsensitive(name, $1) ASC, port ASC
|
||||||
|
LIMIT 20
|
||||||
|
) GROUP BY rank, label, detail ORDER BY rank ASC, MAX(c) DESC, MIN(rowNumberInBlock()) ASC LIMIT 20`, "http").
|
||||||
|
SetArg(1, []struct {
|
||||||
|
Label string `ch:"label"`
|
||||||
|
Detail string `ch:"detail"`
|
||||||
|
}{
|
||||||
|
{"443", "https"},
|
||||||
|
{"80", "http"},
|
||||||
|
{"8080", "http-alt"},
|
||||||
|
}).
|
||||||
|
Return(nil)
|
||||||
|
|
||||||
helpers.TestHTTPEndpoints(t, h.LocalAddr(), helpers.HTTPEndpointCases{
|
helpers.TestHTTPEndpoints(t, h.LocalAddr(), helpers.HTTPEndpointCases{
|
||||||
{
|
{
|
||||||
@@ -269,6 +313,16 @@ LIMIT 20`, "6540").
|
|||||||
{"label": "AS41264", "detail": "Google Switzerland", "quoted": false},
|
{"label": "AS41264", "detail": "Google Switzerland", "quoted": false},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
URL: "/api/v0/console/filter/complete",
|
||||||
|
StatusCode: 200,
|
||||||
|
JSONInput: gin.H{"what": "value", "column": "srcport", "prefix": "http"},
|
||||||
|
JSONOutput: gin.H{"completions": []gin.H{
|
||||||
|
{"label": "443", "detail": "https", "quoted": false},
|
||||||
|
{"label": "80", "detail": "http", "quoted": false},
|
||||||
|
{"label": "8080", "detail": "http-alt", "quoted": false},
|
||||||
|
}},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
URL: "/api/v0/console/filter/complete",
|
URL: "/api/v0/console/filter/complete",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
|
|||||||
Reference in New Issue
Block a user