--- /dev/null
+*** Settings ***
+Suite Setup Generic Setup
+Suite Teardown Generic Teardown
+Library ${TESTDIR}/lib/rspamd.py
+Resource ${TESTDIR}/lib/rspamd.robot
+Variables ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG} ${TESTDIR}/configs/plugins.conf
+${RSPAMD_SCOPE} Suite
+
+*** Test Cases ***
+Zip
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip.eml
+ Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1
+
+Zip Double Bad Extension
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/zip-doublebad.eml
+ Check Rspamc ${result} MIME_DOUBLE_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[pdf, exe\\]\\n re=1
+
+Rar4
+ ${result} = Scan Message With Rspamc ${TESTDIR}/messages/rar4.eml
+ Check Rspamc ${result} MIME_BAD_EXTENSION \\(\\d+\\.\\d+\\)\\[exe\\]\\n re=1
*** Keywords ***
Broken Learn Test
${result} = Run Rspamc -h ${LOCAL_ADDR}:${PORT_CONTROLLER} learn_spam ${MESSAGE}
- Follow Rspamd Log
- Should Not Contain ${result.stdout} success = true
- Should Not Equal As Integers ${result.rc} 0
+ Check Rspamc ${result} inverse=1
Empty Part Test
Set Test Variable ${MESSAGE} ${TESTDIR}/messages/empty_part.eml
--- /dev/null
+options = {
+ pidfile = "${TMPDIR}/rspamd.pid"
+}
+logging = {
+ type = "file",
+ level = "debug"
+ filename = "${TMPDIR}/rspamd.log"
+}
+metric = {
+ name = "default",
+ actions = {
+ reject = 100500,
+ }
+ unknown_weight = 1
+}
+worker {
+ type = normal
+ bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL}
+ count = 1
+}
+mime_types {
+ file = "${TESTDIR}/../../../conf/mime_types.inc";
+ extension_map {
+ html = "text/html";
+ txt [
+ "message/disposition-notification",
+ "text/plain",
+ "text/rfc822-headers",
+ ]
+ pdf [
+ "application/octet-stream",
+ "application/pdf",
+ ]
+ }
+}
+modules {
+ path = "${TESTDIR}/../../src/plugins/lua/"
+}
*** Keywords ***
Check Rspamc
- [Arguments] ${result} @{args}
- ${arglen} = Get Length ${args}
- ${expected_output} = Set Variable If ${arglen} < 1 success = true @{args}[0]
- ${expected_rc} = Set Variable If ${arglen} < 2 0 @{args}[1]
+ [Arguments] ${result} @{args} &{kwargs}
Follow Rspamd Log
- Should Contain ${result.stdout} ${expected_output}
- Should Be Equal As Integers ${result.rc} ${expected_rc}
+ Run Keyword If ${result.rc} != 0 Log ${result.stderr}
+ ${has_rc} = Evaluate 'rc' in $kwargs
+ ${inverse} = Evaluate 'inverse' in $kwargs
+ ${re} = Evaluate 're' in $kwargs
+ ${rc} = Set Variable If ${has_rc} == True &{kwargs}[rc] 0
+ : FOR ${i} IN @{args}
+ \ Run Keyword If ${re} == True Check Rspamc Match Regexp ${result.stdout} ${i} ${inverse}
+ \ ... ELSE Check Rspamc Match String ${result.stdout} ${i} ${inverse}
+ Run Keyword If @{args} == @{EMPTY} Check Rspamc Match Default ${result.stdout} ${inverse}
+ ${rc_nocheck} = Evaluate 'rc_nocheck' in $kwargs
+ Run Keyword If ${rc_nocheck} == True Return From Keyword
+ Run Keyword If ${inverse} == False Should Be Equal As Integers ${result.rc} ${rc}
+ ... ELSE Should Not Be Equal As Integers ${result.rc} ${rc}
+
+Check Rspamc Match Default
+ [Arguments] ${subject} ${inverse}
+ Run Keyword If ${inverse} == False Should Contain ${subject} success = true
+ ... ELSE Should Not Contain ${subject} success = true
+
+Check Rspamc Match Regexp
+ [Arguments] ${subject} ${re} ${inverse}
+ Run Keyword If ${inverse} == False Should Match Regexp ${subject} ${re}
+ ... ELSE Should Not Match Regexp ${subject} ${re}
+
+Check Rspamc Match String
+ [Arguments] ${subject} ${str} ${inverse}
+ Run Keyword If ${inverse} == False Should Contain ${subject} ${str}
+ ... ELSE Should Not Contain ${subject} ${str}
Export Rspamd Vars To Suite
[Arguments] ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID}
Run Rspamc
[Arguments] @{args}
- ${result} = Run Process ${RSPAMC} @{args}
+ ${result} = Run Process ${RSPAMC} @{args} env:LD_LIBRARY_PATH=${TESTDIR}/../../contrib/aho-corasick
[Return] ${result}
Run Rspamd
Log ${config}
Create File ${TMPDIR}/rspamd.conf ${config}
${result} = Run Process ${RSPAMD} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP}
- ... -c ${TMPDIR}/rspamd.conf
+ ... -c ${TMPDIR}/rspamd.conf env:LD_LIBRARY_PATH=${TESTDIR}/../../contrib/aho-corasick
+ Run Keyword If ${result.rc} != 0 Log ${result.stderr}
${rspamd_logpos} = Log Logs ${TMPDIR}/rspamd.log 0
Should Be Equal As Integers ${result.rc} 0
${rspamd_pid} = Get File ${TMPDIR}/rspamd.pid
--- /dev/null
+Content-Type: multipart/mixed; boundary="=_hqO3MQBWZkrB1Zd_nWFL3XM"
+
+--=_hqO3MQBWZkrB1Zd_nWFL3XM
+Content-Type: application/x-rar-compressed; name=f.rar
+Content-Disposition: attachment; size=68; filename=f.rar
+Content-Transfer-Encoding: base64
+
+UmFyIRoHAM+QcwAADQAAAAAAAADSkHQggCgAAQAAAAEAAAADkwbXMiqO6UgdMAgAtIEAAGZha2Uu
+ZXhlCsQ9ewBABwA=
+--=_hqO3MQBWZkrB1Zd_nWFL3XM--
--- /dev/null
+Content-Type: multipart/mixed; boundary="=__i0GhaBNmijobzbiTaqMvfI"
+
+--=__i0GhaBNmijobzbiTaqMvfI
+Content-Type: application/zip; name=f.zip
+Content-Disposition: attachment; size=174; filename=f.zip
+Content-Transfer-Encoding: base64
+
+UEsDBAoAAAAAAJNg6kgAAAAAAAAAAAAAAAAMABwAZmFrZS5wZGYuZXhlVVQJAAO1HYJXtR2CV3V4
+CwABBOgDAAAE6AMAAFBLAQIeAwoAAAAAAJNg6kgAAAAAAAAAAAAAAAAMABgAAAAAAAAAAAC0gQAA
+AABmYWtlLnBkZi5leGVVVAUAA7Udgld1eAsAAQToAwAABOgDAABQSwUGAAAAAAEAAQBSAAAARgAA
+AAAA
+--=__i0GhaBNmijobzbiTaqMvfI--
--- /dev/null
+Content-Type: multipart/mixed; boundary="=_MlaYox31rMNP821ZlG2h4Xe"
+
+--=_MlaYox31rMNP821ZlG2h4Xe
+Content-Type: application/zip; name=f.zip
+Content-Disposition: attachment; size=166; filename=f.zip
+Content-Transfer-Encoding: base64
+
+UEsDBAoAAAAAAINe6kgAAAAAAAAAAAAAAAAIABwAZmFrZS5leGVVVAkAA8YaglfGGoJXdXgLAAEE
+6AMAAAToAwAAUEsBAh4DCgAAAAAAg17qSAAAAAAAAAAAAAAAAAgAGAAAAAAAAAAAALSBAAAAAGZh
+a2UuZXhlVVQFAAPGGoJXdXgLAAEE6AMAAAToAwAAUEsFBgAAAAABAAEATgAAAEIAAAAAAA==
+--=_MlaYox31rMNP821ZlG2h4Xe--