Files
BanGUI/e2e/tests/08_history.robot
Lukas 0d21e3253e test(e2e): split suite by feature area with shared resources
Restructure 5 existing .robot files into 10 numbered files, one per
feature area in Docs/Features.md. Each file is independently runnable.
Add api.resource + data.resource for CSRF/XFF-aware wrappers and
RFC5737 IP generators.

Coverage: 110 new tests across login, dashboard, map, jails, config,
history, blocklists, layout. Uses existing data-testid/aria-label/role
selectors only — no frontend changes.

Tests bypass per-IP rate limits via X-Forwarded-For header rotation.
Hard rule preserved: failures are findings, never app-code fixes.
2026-06-21 07:55:19 +02:00

103 lines
4.2 KiB
Plaintext

*** Settings ***
Documentation Ban History feature coverage — table, filters,
... per-IP timeline, archive vs fail2ban source.
Resource ${CURDIR}/../resources/common.resource
Resource ${CURDIR}/../resources/auth.resource
Suite Setup Wait For Backend Health
*** Test Cases ***
History Page Renders
Login As Admin
Go To ${FRONTEND_URL}/history
Wait For Elements State css=[data-testid="history-page"] visible timeout=15s
Page Should Contain History
Close Browser
History Page Shows Archive Source Badge By Default
[Documentation] Per Features.md, default source on history page is BanGUI archive.
Login As Admin
Go To ${FRONTEND_URL}/history
Wait For Elements State css=[data-testid="history-page"] visible timeout=15s
Sleep 2s
${has_arch}= Run Keyword And Return Status
... Get Text body contains BanGUI DB
${has_live}= Run Keyword And Return Status
... Get Text body contains fail2ban DB
Should Be True ${has_arch} or ${has_live} msg=No source badge visible on history page
Close Browser
History Page Default 7d Range
Login As Admin
Go To ${FRONTEND_URL}/history
Wait For Elements State css=[data-testid="history-page"] visible timeout=15s
Sleep 1s
${has_7d}= Run Keyword And Return Status
... Get Text body contains Last 7 days
Close Browser
History Endpoint Returns Paginated Data
Set Random Xff Header
Login Via HTTP
${headers}= Create Dictionary X-BanGUI-Request 1
Set To Dictionary ${headers} X-Forwarded-For ${XFF_HEADER}
${resp}= GET On Session bangsess /api/v1/history
... headers=${headers} expected_status=any
Should Be True ${resp.status_code} in [200, 204]
History Archive Endpoint Returns Data
Set Random Xff Header
Login Via HTTP
${headers}= Create Dictionary X-BanGUI-Request 1
Set To Dictionary ${headers} X-Forwarded-For ${XFF_HEADER}
${resp}= GET On Session bangsess /api/v1/history/archive
... headers=${headers} expected_status=any
Should Be True ${resp.status_code} in [200, 204]
History Per IP Endpoint Returns Data
Set Random Xff Header
Login Via HTTP
${ip}= Generate Unique Ip
${headers}= Create Dictionary X-BanGUI-Request 1
Set To Dictionary ${headers} X-Forwarded-For ${XFF_HEADER}
${resp}= GET On Session bangsess /api/v1/history/${ip}
... headers=${headers} expected_status=any
Should Be True ${resp.status_code} in [200, 204]
History Filter By Jail Returns Data
Set Random Xff Header
Login Via HTTP
${headers}= Create Dictionary X-BanGUI-Request 1
Set To Dictionary ${headers} X-Forwarded-For ${XFF_HEADER}
${resp}= GET On Session bangsess /api/v1/history
... params=jail=sshd&range=7d headers=${headers} expected_status=any
Should Be True ${resp.status_code} in [200, 204]
History Filter By Source Fail2ban
Set Random Xff Header
Login Via HTTP
${headers}= Create Dictionary X-BanGUI-Request 1
Set To Dictionary ${headers} X-Forwarded-For ${XFF_HEADER}
${resp}= GET On Session bangsess /api/v1/history
... params=source=fail2ban&range=24h headers=${headers} expected_status=any
Should Be True ${resp.status_code} in [200, 204]
History Filter By Source Archive
Set Random Xff Header
Login Via HTTP
${headers}= Create Dictionary X-BanGUI-Request 1
Set To Dictionary ${headers} X-Forwarded-For ${XFF_HEADER}
${resp}= GET On Session bangsess /api/v1/history
... params=source=archive&range=7d headers=${headers} expected_status=any
Should Be True ${resp.status_code} in [200, 204]
History URL Params Honored
[Documentation] Page should load with ?page_size=500&source=fail2ban params.
Login As Admin
Go To ${FRONTEND_URL}/history?page_size=500&source=fail2ban
Wait For Load State domcontentloaded
Sleep 2s
${url}= Get URL
Should Contain ${url} page_size=500
Should Contain ${url} source=fail2ban
Close Browser