guint32 *hp;
if (task != NULL) {
- hp = rspamd_mempool_get_variable (task->task_pool, "settings_hash");
+ hp = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_SETTINGS_HASH);
if (hp) {
lua_pushnumber (L, *hp);
*** Settings ***
-Test Setup Http Setup
-Test Teardown Http Teardown
+Test Setup Servers Setup
+Test Teardown Servers Teardown
Library Process
Library ${TESTDIR}/lib/rspamd.py
Resource ${TESTDIR}/lib/rspamd.robot
Check Rspamc ${result} HTTP_ASYNC_RESPONSE
Check Rspamc ${result} HTTP_ASYNC_RESPONSE_2
+SSL TCP request
+ ${result} = Scan Message With Rspamc ${MESSAGE}
+ Check Rspamc ${result} TCP_SSL_RESPONSE (0.00)[test]
+ Check Rspamc ${result} TCP_SSL_RESPONSE_2 (0.00)[test2]
Sync API TCP request
${result} = Scan Message With Rspamc ${MESSAGE}
Set Global Variable ${LUA_SCRIPT}
Generic Setup
-Http Setup
+Servers Setup
Run Dummy Http
+ Run Dummy Ssl
Lua Setup ${TESTDIR}/lua/tcp.lua
-Http Teardown
+Servers Teardown
${http_pid} = Get File /tmp/dummy_http.pid
Shutdown Process With Children ${http_pid}
+ ${ssl_pid} = Get File /tmp/dummy_ssl.pid
+ Shutdown Process With Children ${ssl_pid}
Normal Teardown
Run Dummy Http
[Arguments]
${result} = Start Process ${TESTDIR}/util/dummy_http.py
- Wait Until Created /tmp/dummy_http.pid
+ Wait Until Created /tmp/dummy_http.pid timeout=2 second
+Run Dummy Ssl
+ [Arguments]
+ ${result} = Start Process ${TESTDIR}/util/dummy_ssl.py ${TESTDIR}/util/server.pem
+ Wait Until Created /tmp/dummy_ssl.pid timeout=2 second
Check url
[Arguments] ${url} ${method} @{expect_results}
-import demjson
import grp
import os
import os.path
import httplib
def Check_JSON(j):
- d = demjson.decode(j, strict=True)
+ d = json.loads(j, strict=True)
assert len(d) > 0
assert 'error' not in d
return d
suite_name = BuiltIn().get_variable_value("${SUITE_NAME}")
test_name = BuiltIn().get_variable_value("${TEST NAME}")
if test_name is None:
- # this is suite-level tear down
+ # this is suite-level tear down
destination_directory = "%s/robot-save/%s" % (current_directory, suite_name)
else:
destination_directory = "%s/robot-save/%s/%s" % (current_directory, suite_name, test_name)
process.wait(TERM_TIMEOUT)
return
except psutil.TimeoutExpired:
- logger.info( "PID {} is not termianated in {} seconds, sending SIGKILL..." %
- (process.pid, TERM_TIMEOUT))
+ logger.info( "PID {} is not terminated in {} seconds, sending SIGKILL...".format(process.pid, TERM_TIMEOUT))
try:
# send SIGKILL
process.kill()
except psutil.NoSuchProcess:
- # process exited just befor we tried to kill
+ # process exited just before we tried to kill
return
try:
process.wait(KILL_WAIT)
except psutil.TimeoutExpired:
- raise RuntimeError("Failed to shutdown process %d (%s)" % (process.pid, process.name()))
+ raise RuntimeError("Failed to shutdown process {} ({})".format(process.pid, process.name()))
def shutdown_process_with_children(pid):
return myfile.read()
return None
-# copy-paste from
+# copy-paste from
# https://hg.python.org/cpython/file/6860263c05b3/Lib/shutil.py#l1068
# As soon as we move to Python 3, this should be removed in favor of shutil.which()
def python3_which(cmd, mode=os.F_OK | os.X_OK, path=None):
})
end
+local function http_simple_tcp_ssl_symbol(task)
+ logger.errx(task, 'ssl_tcp_symbol: begin')
+ local function ssl_get_cb(err, data, conn)
+ logger.errx(task, 'ssl_get_cb: got reply: %s, error: %s, conn: %s', data, err, conn)
+ task:insert_result('TCP_SSL_RESPONSE_2', 1.0, tostring(data):gsub('%s', ''))
+ end
+ local function ssl_read_post_cb(err, conn)
+ logger.errx(task, 'ssl_read_post_cb: write done: error: %s, conn: %s', err, conn)
+ conn:add_read(ssl_get_cb)
+ end
+ local function ssl_read_cb(err, data, conn)
+ logger.errx(task, 'ssl_read_cb: got reply: %s, error: %s, conn: %s', data, err, conn)
+ conn:add_write(ssl_read_post_cb, "test2\n")
+ task:insert_result('TCP_SSL_RESPONSE', 1.0, tostring(data):gsub('%s', ''))
+ end
+ rspamd_tcp:request({
+ task = task,
+ callback = ssl_read_cb,
+ host = '127.0.0.1',
+ data = {'test\n'},
+ read = true,
+ ssl = true,
+ ssl_noverify = true,
+ port = 14433,
+ })
+end
+
local function http_simple_tcp_symbol(task)
logger.errx(task, 'connect_sync, before')
callback = http_simple_tcp_async_symbol,
no_squeeze = true
})
+rspamd_config:register_symbol({
+ name = 'SIMPLE_TCP_ASYNC_SSL_TEST',
+ score = 1.0,
+ callback = http_simple_tcp_ssl_symbol,
+ no_squeeze = true
+})
rspamd_config:register_symbol({
name = 'SIMPLE_TCP_TEST',
score = 1.0,