- sudo apt-get update -qq
- sudo apt-get install -qq cmake gcc lcov libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make python-dev ragel redis-server
- gem install coveralls-lcov
- - sudo pip install psutil
- - sudo pip install robotframework
+ - sudo pip install demjson psutil robotframework
test:
override:
--- /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/lua_test.conf
+${LUA_SCRIPT} ${TESTDIR}/lua/preresult.lua
+${MESSAGE} ${TESTDIR}/messages/spam_message.eml
+${RSPAMD_SCOPE} Suite
+
+*** Test Cases ***
+Stat
+ @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /stat
+ Check JSON @{result}[1]
+
+History
+ ${result} = Scan Message With Rspamc ${MESSAGE}
+ Check Rspamc ${result} soft reject
+ @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /history
+ Check JSON @{result}[1]
+
+Scan
+ ${content} = Get File ${MESSAGE}
+ @{result} = HTTP POST ${LOCAL_ADDR} ${PORT_NORMAL} /check ${content}
+ Check JSON @{result}[1]
+import demjson
import grp
import os
import os.path
from urllib.request import urlopen
except:
from urllib2 import urlopen
+try:
+ import http.client as httplib
+except:
+ import httplib
+
+def Check_JSON(j):
+ d = demjson.decode(j, strict=True)
+ assert len(d) > 0
+ assert 'error' not in d
+ return d
def cleanup_temporary_directory(directory):
shutil.rmtree(directory)
dname = get_top_dir()
return dname + "/src/rspamadm/rspamadm"
+def HTTP(method, host, port, path, data=None, headers={}):
+ c = httplib.HTTPConnection("%s:%s" % (host, port))
+ c.request(method, path, data, headers)
+ r = c.getresponse()
+ t = r.read()
+ s = r.status
+ c.close()
+ return [s, t]
+
def make_temporary_directory():
return tempfile.mkdtemp()
--- /dev/null
+rspamd_config:register_post_filter(function(task)
+ task:set_pre_result('soft reject', 'Pre Result Set')
+end)