@@ -15,25 +15,25 @@ ${RSPAMD_SCOPE} Test | |||
*** Test Cases *** | |||
Simple HTTP request | |||
Check url /request get HTTP_DNS_200 HTTP_200 method_get hello world | |||
Check url /request post HTTP_DNS_200 HTTP_200 method_post hello post | |||
Check url /request get HTTP_DNS_200 HTTP_200 HTTP_CORO_DNS_200 HTTP_CORO_200 method_get hello world HTTP_CORO_200 (0.00)[hello world] | |||
Check url /request post HTTP_DNS_200 HTTP_200 HTTP_CORO_DNS_200 HTTP_CORO_200 method_post hello post HTTP_CORO_DNS_200 (0.00)[hello post] | |||
*** Test Cases *** | |||
HTTP request 403 | |||
Check url /error_403 get HTTP_DNS_403 HTTP_403 method_get | |||
Check url /error_403 post HTTP_DNS_403 HTTP_403 method_post | |||
Check url /error_403 get HTTP_DNS_403 HTTP_403 HTTP_CORO_DNS_403 HTTP_CORO_403 method_get | |||
Check url /error_403 post HTTP_DNS_403 HTTP_403 HTTP_CORO_DNS_403 HTTP_CORO_403 method_post | |||
*** Test Cases *** | |||
HTTP timeout | |||
Check url /timeout get HTTP_ERROR HTTP_ERROR method_get IO timeout | |||
Check url /timeout post HTTP_DNS_ERROR HTTP_ERROR method_post IO timeout | |||
Check url /timeout get HTTP_ERROR HTTP_ERROR HTTP_CORO_DNS_ERROR HTTP_CORO_ERROR method_get IO timeout | |||
Check url /timeout post HTTP_DNS_ERROR HTTP_ERROR HTTP_CORO_DNS_ERROR HTTP_CORO_ERROR method_post IO timeout | |||
*** Test Cases *** | |||
HTTP empty response | |||
Check url /empty get HTTP_ERROR HTTP_ERROR method_get IO read error: unexpected EOF | |||
Check url /empty post HTTP_DNS_ERROR HTTP_ERROR method_post IO read error: unexpected EOF | |||
Check url /empty get HTTP_ERROR HTTP_ERROR HTTP_CORO_DNS_ERROR HTTP_CORO_ERROR method_get IO read error: unexpected EOF | |||
Check url /empty post HTTP_DNS_ERROR HTTP_ERROR HTTP_CORO_DNS_ERROR HTTP_CORO_ERROR method_post IO read error: unexpected EOF | |||
*** Keywords *** |
@@ -19,6 +19,22 @@ Simple TCP request | |||
Check Rspamc ${result} HTTP_ASYNC_RESPONSE | |||
Check Rspamc ${result} HTTP_ASYNC_RESPONSE_2 | |||
Sync API TCP request | |||
${result} = Scan Message With Rspamc ${MESSAGE} | |||
Check Rspamc ${result} HTTP_SYNC_RESPONSE | |||
Check Rspamc ${result} HTTP_SYNC_RESPONSE_2 | |||
Check Rspamc ${result} hello world | |||
Check Rspamc ${result} hello post | |||
Sync API TCP get request | |||
Check url /request get HTTP_SYNC_EOF_get (0.00)[hello world] | |||
Check url /content-length get HTTP_SYNC_CONTENT_get (0.00)[hello world] | |||
Sync API TCP post request | |||
Check url /request post HTTP_SYNC_EOF_post (0.00)[hello post] | |||
Check url /content-length post HTTP_SYNC_CONTENT_post (0.00)[hello post] | |||
*** Keywords *** | |||
Lua Setup | |||
[Arguments] ${LUA_SCRIPT} |
@@ -19,7 +19,7 @@ Sync API TCP get request when server is down | |||
[Documentation] We don't create HTTP server here, that's why | |||
... all requests fail with "connection refused" | |||
Check url /request get HTTP_ASYNC_RESPONSE (0.00)[Socket error detected: Connection refused] | |||
#Check url /content-length HTTP_SYNC_WRITE_ERROR (0.00)[Socket error detected: Connection refused] | |||
Check url /content-length HTTP_SYNC_WRITE_ERROR (0.00)[Socket error detected: Connection refused] | |||
*** Keywords *** |
@@ -20,6 +20,7 @@ ${MESSAGE} ${TESTDIR}/messages/spam_message.eml | |||
Redis client | |||
Redis SET test_key test value | |||
${result} = Scan Message With Rspamc ${MESSAGE} | |||
Check Rspamc ${result} REDIS (0.00)[hello from lua on redis] | |||
Check Rspamc ${result} REDIS_ASYNC (0.00)[test value] | |||
Check Rspamc ${result} REDIS_ASYNC201809 (0.00)[test value] | |||
@@ -43,7 +43,7 @@ local function http_symbol(task) | |||
callback = http_dns_callback, | |||
timeout = 1, | |||
}) | |||
--[[ | |||
rspamd_logger.errx(task, 'rspamd_http.request[before]') | |||
local err, response = rspamd_http.request({ | |||
@@ -73,7 +73,6 @@ local function http_symbol(task) | |||
else | |||
task:insert_result('HTTP_CORO_DNS_ERROR', 1.0, err) | |||
end | |||
--]] | |||
end | |||
@@ -110,7 +109,8 @@ rspamd_config:register_symbol({ | |||
name = 'SIMPLE_TEST', | |||
score = 1.0, | |||
callback = http_symbol, | |||
no_squeeze = true | |||
no_squeeze = true, | |||
flags = 'coro' | |||
}) | |||
@@ -2,11 +2,17 @@ | |||
-- Just a test for Redis API | |||
--]] | |||
local logger = require "rspamd_logger" | |||
local redis_lua = require "lua_redis" | |||
local redis_params | |||
local N = 'redis_test' | |||
local lua_script = [[ | |||
local f = function() end | |||
return "hello from lua on redis" | |||
]] | |||
local function redis_simple_async_symbol(task) | |||
local function redis_cb(err, data) | |||
if err then | |||
@@ -46,7 +52,7 @@ local function redis_simple_async_api201809(task) | |||
} | |||
redis_lua.request(redis_params, attrs, request) | |||
end | |||
--[[ | |||
local function redis_symbol(task) | |||
local attrs = {task = task} | |||
@@ -81,7 +87,7 @@ local function redis_symbol(task) | |||
task:insert_result('REDIS', 1.0, data) | |||
end | |||
--]] | |||
redis_params = rspamd_parse_redis_server(N) | |||
rspamd_config:register_symbol({ | |||
@@ -97,11 +103,11 @@ rspamd_config:register_symbol({ | |||
callback = redis_simple_async_api201809, | |||
no_squeeze = true | |||
}) | |||
--[[ | |||
rspamd_config:register_symbol({ | |||
name = 'REDIS_TEST', | |||
score = 1.0, | |||
callback = redis_symbol, | |||
no_squeeze = true | |||
flags = 'coro', | |||
}) | |||
-- ]] |
@@ -31,7 +31,7 @@ local function http_simple_tcp_async_symbol(task) | |||
port = 18080, | |||
}) | |||
end | |||
--[[ | |||
local function http_simple_tcp_symbol(task) | |||
logger.errx(task, 'connect_sync, before') | |||
@@ -171,25 +171,26 @@ local function http_tcp_symbol(task) | |||
end | |||
logger.errx(task, '(is_ok: %1) content [%2 bytes] %3', is_ok, content_length, content) | |||
end | |||
--]] | |||
rspamd_config:register_symbol({ | |||
name = 'SIMPLE_TCP_ASYNC_TEST', | |||
score = 1.0, | |||
callback = http_simple_tcp_async_symbol, | |||
no_squeeze = true | |||
}) | |||
--[[ | |||
rspamd_config:register_symbol({ | |||
name = 'SIMPLE_TCP_TEST', | |||
score = 1.0, | |||
callback = http_simple_tcp_symbol, | |||
no_squeeze = true | |||
no_squeeze = true, | |||
flags = 'coro', | |||
}) | |||
rspamd_config:register_symbol({ | |||
name = 'HTTP_TCP_TEST', | |||
score = 1.0, | |||
callback = http_tcp_symbol, | |||
no_squeeze = true | |||
no_squeeze = true, | |||
flags = 'coro', | |||
}) | |||
-- ]] |