From: Vsevolod Stakhov Date: Sat, 4 Oct 2025 18:46:05 +0000 (+0100) Subject: [Minor] Fix HTML fuzzy test to use standard flags and keywords X-Git-Tag: 3.14.0~87^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3eceb8b0c94427642caf93a911c18deb7afe0dd4;p=thirdparty%2Frspamd.git [Minor] Fix HTML fuzzy test to use standard flags and keywords Use RSPAMD_FLAG1_NUMBER (50) instead of custom flag 100 to match existing fuzzy.conf configuration. Add proper test flow with setup checks and standard Robot Framework keywords. --- diff --git a/test/functional/cases/120_fuzzy/html-fuzzy.robot b/test/functional/cases/120_fuzzy/html-fuzzy.robot index 3cdc1c4e54..ee63c445d3 100644 --- a/test/functional/cases/120_fuzzy/html-fuzzy.robot +++ b/test/functional/cases/120_fuzzy/html-fuzzy.robot @@ -1,5 +1,5 @@ *** Settings *** -Suite Setup HTML Fuzzy Setup +Suite Setup HTML Fuzzy Setup Mumhash Suite Teardown Rspamd Redis Teardown Resource lib.robot @@ -7,43 +7,75 @@ Resource lib.robot ${HTML_TEMPLATE_1} ${RSPAMD_TESTDIR}/messages/html_template_1.eml ${HTML_TEMPLATE_1_VAR} ${RSPAMD_TESTDIR}/messages/html_template_1_variation.eml ${HTML_PHISHING} ${RSPAMD_TESTDIR}/messages/html_phishing.eml -${FLAG_HTML_WHITE} 100 -${FLAG_HTML_SPAM} 101 *** Keywords *** -HTML Fuzzy Setup +HTML Fuzzy Setup Mumhash Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} mumhash Set Suite Variable ${RSPAMD_FUZZY_SERVER_MODE} servers - Set Suite Variable ${SETTINGS_FUZZY_CHECK} servers = "${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_FUZZY}"; html_shingles = true; min_html_tags = 5; + # Use standard test flags and add HTML-specific settings + Set Suite Variable ${SETTINGS_FUZZY_CHECK} servers = "${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_FUZZY}"; html_shingles = true; min_html_tags = 5; html_weight = 1.0; Rspamd Redis Setup -HTML Fuzzy Add Whitelist +HTML Fuzzy Add Test [Documentation] Learn legitimate HTML template - ${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -w 10 -f ${FLAG_HTML_WHITE} fuzzy_add ${HTML_TEMPLATE_1} + Set Suite Variable ${RSPAMD_FUZZY_HTML_ADD} 0 + ${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -w 10 -f ${RSPAMD_FLAG1_NUMBER} fuzzy_add ${HTML_TEMPLATE_1} Check Rspamc ${result} Sync Fuzzy Storage + Set Suite Variable ${RSPAMD_FUZZY_HTML_ADD} 1 -HTML Fuzzy Check Variation - [Documentation] Check variation of same template (different text, same structure) +HTML Fuzzy Check Test + [Documentation] Check exact match + IF ${RSPAMD_FUZZY_HTML_ADD} == 0 + Fail "HTML Fuzzy Add was not run" + END + Scan File ${HTML_TEMPLATE_1} + Expect Symbol ${FLAG1_SYMBOL} + +HTML Fuzzy Variation Test + [Documentation] Check variation of same template (different text, same HTML structure) + IF ${RSPAMD_FUZZY_HTML_ADD} == 0 + Fail "HTML Fuzzy Add was not run" + END Scan File ${HTML_TEMPLATE_1_VAR} - Expect Symbol R_TEST_FUZZY_DENIED - ${symbols} = Get Rspamd Symbols - Log Fuzzy symbols: ${symbols} + # Should match via HTML shingles despite different text + Expect Symbol ${FLAG1_SYMBOL} -HTML Fuzzy Check Phishing - [Documentation] Check phishing email (same structure, different CTA domains) +HTML Fuzzy Phishing Test + [Documentation] Check phishing email with same structure but different CTA domains + IF ${RSPAMD_FUZZY_HTML_ADD} == 0 + Fail "HTML Fuzzy Add was not run" + END Scan File ${HTML_PHISHING} - # Should match structure but CTA differs - # Depending on CTA weight, might have lower score or specific handling - ${symbols} = Get Rspamd Symbols - Log Phishing check symbols: ${symbols} + # Structure similar but CTA domains different + # Might match with lower score or not match depending on CTA weight + # For now just verify no crash + ${result} = Scan Message With Rspamc ${HTML_PHISHING} + Should Be Equal As Numbers ${result.returncode} 0 + +HTML Fuzzy Delete Test + [Documentation] Delete HTML fuzzy hash + IF ${RSPAMD_FUZZY_HTML_ADD} == 0 + Fail "HTML Fuzzy Add was not run" + END + ${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -f ${RSPAMD_FLAG1_NUMBER} fuzzy_del ${HTML_TEMPLATE_1} + Check Rspamc ${result} + Sync Fuzzy Storage + Scan File ${HTML_TEMPLATE_1} + Do Not Expect Symbol ${FLAG1_SYMBOL} *** Test Cases *** -HTML Fuzzy Add Whitelist Test - HTML Fuzzy Add Whitelist +HTML Fuzzy Add + HTML Fuzzy Add Test + +HTML Fuzzy Exact Match + HTML Fuzzy Check Test + +HTML Fuzzy Template Variation + HTML Fuzzy Variation Test -HTML Fuzzy Variation Match Test - HTML Fuzzy Check Variation +HTML Fuzzy Phishing Detection + HTML Fuzzy Phishing Test -HTML Fuzzy Phishing Detection Test - HTML Fuzzy Check Phishing +HTML Fuzzy Delete + HTML Fuzzy Delete Test