*** Test Cases ***
RESOLVE URLS
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
RESOLVE URLS CACHED
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
STEALTH FINGERPRINT HEADERS
# The live HEAD requests issued by RESOLVE URLS are logged by the dummy
Urlredirector Setup
Run Dummy Http
Rspamd Redis Setup
+ # .eml fixtures carry the dummy_http port as a ${RSPAMD_PORT_DUMMY_HTTP}
+ # placeholder; render them now that RSPAMD_TMPDIR exists so the per-worker
+ # offset is baked into the message the scanner reads.
+ ${MESSAGE} = Render Message Template ${MESSAGE}
+ Set Suite Variable ${MESSAGE}
+ ${CHAIN_MESSAGE} = Render Message Template ${CHAIN_MESSAGE}
+ Set Suite Variable ${CHAIN_MESSAGE}
Urlredirector Teardown
Rspamd Redis Teardown
BASIC CHAIN RESOLUTION AND CACHING
[Documentation] Test chain resolution with intermediate hops and caching
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
NESTED LIMIT MARKER
[Documentation] Test ^nested: markers for limit exceeded
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
CHAIN AWARE CACHE
[Documentation] Test per-hop Redis cache with markers
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
TIMEOUT SETTINGS
[Documentation] Test timeout, http_timeout, redis_timeout configuration
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
SAVE INTERMEDIATE REDIRECTS
[Documentation] Test save_intermediate_redirs configuration
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
REDIRECTOR SYMBOL
[Documentation] Test redirector_symbol with host path output
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
*** Keywords ***
Urlredirector Chain Setup
Run Dummy Http
Rspamd Redis Setup
+ ${MESSAGE} = Render Message Template ${MESSAGE}
+ Set Suite Variable ${MESSAGE}
Urlredirector Chain Teardown
Rspamd Redis Teardown
[Documentation] Test PR 6014 feature: resolve redirect chains with intermediate hops
... Tests /redirect2 -> /redirect1 -> /hello chain
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
CHAIN REDIRECT WITH SYMBOL
[Documentation] Test that redirector_symbol shows the full redirect path (host1->host2->...->hostN)
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
CHAIN REDIRECT CACHED RESOLUTION
[Documentation] Test that cached chain resolution works correctly on second scan
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
REDIRECT CYCLE DETECTION
[Documentation] Test cycle detection with /redirect3 <-> /redirect4 cycle
NESTED LIMIT HANDLING
[Documentation] Test ^nested: marker behavior when nested_limit is exceeded
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
TIMEOUT CONFIGURATION
[Documentation] Test that timeout, http_timeout, and redis_timeout are correctly applied
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
SAVE INTERMEDIATE REDIRS
[Documentation] Test save_intermediate_redirs = {redirectors=false, non_redirectors=true}
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
BASIC URL RESOLUTION
[Documentation] Test basic URL resolution without redirects
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
*** Keywords ***
Urlredirector PR6014 Setup
Run Dummy Http
Rspamd Redis Setup
+ ${MESSAGE} = Render Message Template ${MESSAGE}
+ Set Suite Variable ${MESSAGE}
+ ${CHAIN_MESSAGE} = Render Message Template ${CHAIN_MESSAGE}
+ Set Suite Variable ${CHAIN_MESSAGE}
+ ${MULTIPART_MESSAGE} = Render Message Template ${MULTIPART_MESSAGE}
+ Set Suite Variable ${MULTIPART_MESSAGE}
Urlredirector PR6014 Teardown
Rspamd Redis Teardown
... - ^nested: for limit exceeded
... - no marker for terminal URLs
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
PER-ADJACENT-PAIR CACHE LAYOUT
[Documentation] Test PR 6014 cache layout: one Redis entry per adjacent URL pair
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
CACHE WALK WITH MARKERS
[Documentation] Test cache walk behavior: reader follows markers until terminal
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
SELF-HEALING CACHE
[Documentation] Test self-healing: ^nested: marker upgrade on extension
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
CYCLE DETECTION
[Documentation] Test cycle protection with per-walk seen-set
REDIS TIMEOUT APPLIED
[Documentation] Test that redis_timeout setting is applied to Redis calls
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
TOP_URLS TRACKING
[Documentation] Test that ZINCRBY on top_urls uses canonical URL string
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
RESERVATION LOCK
[Documentation] Test that reservation lock has correct TTL = settings.timeout
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
*** Keywords ***
Urlredirector Cache Setup
Run Dummy Http
Rspamd Redis Setup
+ ${MESSAGE} = Render Message Template ${MESSAGE}
+ Set Suite Variable ${MESSAGE}
Urlredirector Cache Teardown
Rspamd Redis Teardown
SAVE_INTERMEDIATE_REDIRECTORS_ONLY
[Documentation] Test save_intermediate_redirs={redirectors=true, non_redirectors=false}
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
SAVE_INTERMEDIATE_DISABLED
[Documentation] Test save_intermediate_redirs with both options disabled
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
DEFAULT_TIMEOUT_VALUE
[Documentation] Test default timeout value (8s) from settings
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
CUSTOM_HTTP_TIMEOUT
[Documentation] Test custom http_timeout setting overrides default
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
CUSTOM_REDIS_TIMEOUT
[Documentation] Test custom redis_timeout setting
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
REDIRECTOR_SYMBOL_DISABLED
[Documentation] Test behavior when redirector_symbol is not configured
Scan File ${MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/hello
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/hello
*** Keywords ***
Urlredirector Config Setup
Run Dummy Http
Rspamd Redis Setup
+ ${MESSAGE} = Render Message Template ${MESSAGE}
+ Set Suite Variable ${MESSAGE}
Urlredirector Config Teardown
Rspamd Redis Teardown
# but then stop when it encounters the tel: scheme and not attempt HTTP request
Scan File ${TEL_MESSAGE} Flags=ext_urls Settings=${SETTINGS}
# The original URL should be processed
- Expect Extended URL http://127.0.0.1:18080/tel_redirect
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/tel_redirect
Expect Symbol With Exact Options URL_REDIRECTOR_NON_HTTP telephone=127.0.0.1->tel:88006007775
Do Not Expect Added URL tel:88006007775
# Intermediate redirector hops are not saved to chain by default (redirectors=false),
# so the chain string only shows the original redirector host and the tel: target.
Scan File ${CHAIN_TEL_MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/chain_intermediate_1
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/chain_intermediate_1
Expect Symbol With Exact Options URL_REDIRECTOR_NON_HTTP telephone=127.0.0.1->tel:88006007776
Do Not Expect Added URL tel:88006007776
# tel_redirect -> tel:88006007775 (rspamd scheme: telephone)
# mailto_redirect -> mailto:user@example.net (rspamd scheme: mailto)
Scan File ${MULTI_NON_HTTP_MESSAGE} Flags=ext_urls Settings=${SETTINGS}
- Expect Extended URL http://127.0.0.1:18080/tel_redirect
- Expect Extended URL http://127.0.0.1:18080/mailto_redirect
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/tel_redirect
+ Expect Extended URL http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/mailto_redirect
Expect Symbol With Exact Options URL_REDIRECTOR_NON_HTTP
... telephone=127.0.0.1->tel:88006007775
... mailto=127.0.0.1->mailto:user@example.net
Urlredirector Setup
Run Dummy Http
Rspamd Redis Setup
+ ${TEL_MESSAGE} = Render Message Template ${TEL_MESSAGE}
+ Set Suite Variable ${TEL_MESSAGE}
+ ${CHAIN_TEL_MESSAGE} = Render Message Template ${CHAIN_TEL_MESSAGE}
+ Set Suite Variable ${CHAIN_TEL_MESSAGE}
+ ${MULTI_NON_HTTP_MESSAGE} = Render Message Template ${MULTI_NON_HTTP_MESSAGE}
+ Set Suite Variable ${MULTI_NON_HTTP_MESSAGE}
Urlredirector Teardown
Rspamd Redis Teardown
Urlredirector Setup
Run Dummy Http
Rspamd Redis Setup
+ ${MESSAGE} = Render Message Template ${MESSAGE}
+ Set Suite Variable ${MESSAGE}
Urlredirector Teardown
Rspamd Redis Teardown
Urlredirector Setup
Run Dummy Http
Rspamd Redis Setup
+ ${MESSAGE} = Render Message Template ${MESSAGE}
+ Set Suite Variable ${MESSAGE}
Urlredirector Teardown
Rspamd Redis Teardown
symbol_ham = "NEURAL_HAM";
ann_expire = 86400;
watch_interval = 0.5;
- providers = [{ type = "llm"; model = "dummy-embed"; url = "http://127.0.0.1:18080"; weight = 1.0;
+ providers = [{ type = "llm"; model = "dummy-embed"; url = "http://127.0.0.1:{= env.PORT_DUMMY_HTTP|default('18080') =}"; weight = 1.0;
#reply_trim_mode = "replies"; # always|none|replies
}];
fusion { normalization = "none"; }
Log ${result.stdout}
RETURN ${result}
+Render Message Template
+ [Documentation] Read an .eml fixture that contains Robot ${VARIABLE}
+ ... placeholders (e.g. ${RSPAMD_PORT_DUMMY_HTTP}), expand them, write
+ ... the result into the suite tmpdir and return the rendered path.
+ ... .eml files are fed raw to the scanner and are NOT processed by the
+ ... config-time Jinja engine, so per-pabot-worker values (dummy ports)
+ ... must be substituted here at runtime. Requires ${RSPAMD_TMPDIR}
+ ... (set by Rspamd Setup) -- call after the rspamd setup keyword.
+ [Arguments] ${template_path}
+ ${template} = Get File ${template_path}
+ ${rendered} = Replace Variables ${template}
+ ${name} = Evaluate os.path.basename($template_path) modules=os
+ ${out} = Set Variable ${RSPAMD_TMPDIR}/${name}
+ Create File ${out} ${rendered}
+ RETURN ${out}
+
Scan File By Reference
[Arguments] ${filename} &{headers}
Set To Dictionary ${headers} File=${filename}
local rspamd_http = require "rspamd_http"
local rspamd_logger = require "rspamd_logger"
+-- dummy_http / dummy_https ports come from the test harness; rspamd_env
+-- strips the RSPAMD_ prefix so PORT_DUMMY_HTTP/HTTPS carry the per-pabot
+-- worker slot value. Default to the historical literals for ad-hoc runs.
+local http_port = tonumber(rspamd_env and rspamd_env.PORT_DUMMY_HTTP) or 18080
+local https_port = tonumber(rspamd_env and rspamd_env.PORT_DUMMY_HTTPS) or 18081
+
local function http_symbol(task)
local url = tostring(task:get_request_header('url'))
rspamd_logger.errx(task, 'do http request with callback')
rspamd_http.request({
- url = 'http://127.0.0.1:18080' .. url,
+ url = string.format('http://127.0.0.1:%d%s', http_port, url),
task = task,
method = method,
callback = http_callback,
--[[ request to this address involved DNS resolver subsystem ]]
rspamd_logger.errx(task, 'do http request with callback + dns resolving')
rspamd_http.request({
- url = 'http://site.resolveme:18080' .. url,
+ url = string.format('http://site.resolveme:%d%s', http_port, url),
task = task,
method = method,
callback = http_dns_callback,
rspamd_logger.errx(task, 'rspamd_http.request[before]')
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18080' .. url,
+ url = string.format('http://127.0.0.1:%d%s', http_port, url),
task = task,
method = method,
timeout = 1,
rspamd_logger.errx(task, 'do http request after coroutine finished')
err, response = rspamd_http.request({
- url = 'http://site.resolveme:18080' .. url,
+ url = string.format('http://site.resolveme:%d%s', http_port, url),
task = task,
method = method,
timeout = 1,
local function finish(task)
rspamd_logger.errx('function finish')
local err, response = rspamd_http.request({
- url = 'http://site.resolveme:18080/timeout',
+ url = string.format('http://site.resolveme:%d/timeout', http_port),
task = task,
method = 'get',
timeout = 1,
local function periodic(cfg, ev_base)
local err, response = rspamd_http.request({
- url = 'http://site.resolveme:18080/request/periodic',
+ url = string.format('http://site.resolveme:%d/request/periodic', http_port),
config = cfg,
})
if err then
end
end
rspamd_http.request({
- url = 'https://127.0.0.1:18081/',
+ url = string.format('https://127.0.0.1:%d/', https_port),
task = task,
method = 'post',
callback = http_callback,
rspamd_config:add_on_load(function(cfg, ev_base, worker)
local err, response = rspamd_http.request({
- url = 'http://site.resolveme:18080/request/add_on_load',
+ url = string.format('http://site.resolveme:%d/request/add_on_load', http_port),
config = cfg,
})
if err then
This tests edge cases where a server responds before the client has finished
sending the request body (which is allowed by HTTP/1.1 spec).
-The test server (dummy_http_early_response.py) runs on port 18083.
+The test server (dummy_http_early_response.py) runs on port 18083
+(per-pabot-worker offset applied via rspamd_env.PORT_DUMMY_HTTP_EARLY).
]]
local rspamd_http = require "rspamd_http"
local rspamd_logger = require "rspamd_logger"
+-- dummy_http_early_response port comes from the test harness; rspamd_env
+-- strips the RSPAMD_ prefix so PORT_DUMMY_HTTP_EARLY carries the per-pabot
+-- worker slot value. Default to the historical literal for ad-hoc runs.
+local early_port = tonumber(rspamd_env and rspamd_env.PORT_DUMMY_HTTP_EARLY) or 18083
+local base_url = string.format('http://127.0.0.1:%d', early_port)
+
-- Register all possible result symbols upfront
-- These are the symbols that will be inserted based on HTTP response codes
local result_symbols = {
end
rspamd_http.request({
- url = 'http://127.0.0.1:18083/early-reply',
+ url = base_url .. '/early-reply',
task = task,
method = 'post',
body = large_body,
end
rspamd_http.request({
- url = 'http://127.0.0.1:18083/early-error-413',
+ url = base_url .. '/early-error-413',
task = task,
method = 'post',
body = large_body,
end
rspamd_http.request({
- url = 'http://127.0.0.1:18083/keepalive-early',
+ url = base_url .. '/keepalive-early',
task = task,
method = 'post',
body = body,
local body = table.concat(body_parts)
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083/early-reply',
+ url = base_url .. '/early-reply',
task = task,
method = 'post',
body = body,
end
rspamd_http.request({
- url = 'http://127.0.0.1:18083/request',
+ url = base_url .. '/request',
task = task,
method = 'post',
body = 'normal test body',
-- Make 3 sequential requests using keepalive
for i = 1, 3 do
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083/keepalive-normal',
+ url = base_url .. '/keepalive-normal',
task = task,
method = 'post',
body = string.format('request %d body', i),
end
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083' .. endpoint,
+ url = base_url .. endpoint,
task = task,
method = 'post',
body = table.concat(body_parts),
end
rspamd_http.request({
- url = 'http://127.0.0.1:18083/immediate-close-413',
+ url = base_url .. '/immediate-close-413',
task = task,
method = 'post',
body = large_body,
local body = table.concat(body_parts)
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083/slow-response-no-drain',
+ url = base_url .. '/slow-response-no-drain',
task = task,
method = 'post',
body = body,
for i = 1, 5 do
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083/immediate-close-413',
+ url = base_url .. '/immediate-close-413',
task = task,
method = 'post',
body = body,
end
rspamd_http.request({
- url = 'http://127.0.0.1:18083/block-and-reply',
+ url = base_url .. '/block-and-reply',
task = task,
method = 'post',
body = huge_body,
local huge_body = string.rep("Y", 512 * 1024)
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083/block-and-reply',
+ url = base_url .. '/block-and-reply',
task = task,
method = 'post',
body = huge_body,
local huge_body = string.rep("Z", 1024 * 1024)
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083/block-and-reply-slow',
+ url = base_url .. '/block-and-reply-slow',
task = task,
method = 'post',
body = huge_body,
local huge_body = string.rep("Z", 512 * 1024)
local err, response = rspamd_http.request({
- url = 'http://127.0.0.1:18083/instant-reply',
+ url = base_url .. '/instant-reply',
task = task,
method = 'post',
body = huge_body,
local logger = require "rspamd_logger"
local tcp_sync = require "lua_tcp_sync"
+-- dummy_http port comes from the test harness. This script runs under
+-- `rspamadm lua` (not the rspamd config loader), so prefer the exported
+-- RSPAMD_PORT_DUMMY_HTTP env var, then rspamd_env, then the historical
+-- literal for ad-hoc runs.
+local http_port = tonumber(os.getenv('RSPAMD_PORT_DUMMY_HTTP'))
+ or tonumber(rspamd_env and rspamd_env.PORT_DUMMY_HTTP) or 18080
+
local is_ok, connection = tcp_sync.connect {
config = rspamd_config,
ev_base = rspamadm_ev_base,
session = rspamadm_session,
host = '127.0.0.1',
timeout = 20,
- port = 18080,
+ port = http_port,
}
if not is_ok then
logger.errx(rspamd_config, 'connect error: %1', connection)
local logger = require "rspamd_logger"
local tcp_sync = require "lua_tcp_sync"
+-- dummy_http / dummy_https ports come from the test harness; rspamd_env
+-- strips the RSPAMD_ prefix so PORT_DUMMY_HTTP/HTTPS carry the per-pabot
+-- worker slot value. Default to the historical literals for ad-hoc runs.
+local http_port = tonumber(rspamd_env and rspamd_env.PORT_DUMMY_HTTP) or 18080
+local https_port = tonumber(rspamd_env and rspamd_env.PORT_DUMMY_HTTPS) or 18081
+
-- [[ old fashioned callback api ]]
local function http_simple_tcp_async_symbol(task)
logger.errx(task, 'http_tcp_symbol: begin')
end
local function http_read_cb(err, data, conn)
logger.errx(task, 'http_read_cb: got reply: %s, error: %s, conn: %s', data, err, conn)
- conn:add_write(http_read_post_cb, "POST /request2 HTTP/1.1\r\nHost: 127.0.0.1:18080\r\n\r\n")
+ conn:add_write(http_read_post_cb, string.format("POST /request2 HTTP/1.1\r\nHost: 127.0.0.1:%d\r\n\r\n", http_port))
task:insert_result('HTTP_ASYNC_RESPONSE', 1.0, data or err)
end
rspamd_tcp:request({
task = task,
callback = http_read_cb,
host = '127.0.0.1',
- data = {'GET /request HTTP/1.1\r\nHost: 127.0.0.1:18080\r\nConnection: keep-alive\r\n\r\n'},
+ data = {string.format('GET /request HTTP/1.1\r\nHost: 127.0.0.1:%d\r\nConnection: keep-alive\r\n\r\n', http_port)},
read = true,
- port = 18080,
+ port = http_port,
})
end
read = true,
ssl = true,
ssl_noverify = true,
- port = 18081,
+ port = https_port,
})
end
ssl = true,
stop_pattern = '\n',
ssl_noverify = true,
- port = 18081,
+ port = https_port,
timeout = 20,
})
else
task = task,
host = '127.0.0.1',
timeout = 20,
- port = 18080,
+ port = http_port,
}
if not is_ok then
logger.errx(task, 'connect_sync %1, %2', is_ok, tostring(connection))
- is_ok, err = connection:write('GET /request HTTP/1.1\r\nHost: 127.0.0.1:18080\r\nConnection: keep-alive\r\n\r\n')
+ is_ok, err = connection:write(string.format('GET /request HTTP/1.1\r\nHost: 127.0.0.1:%d\r\nConnection: keep-alive\r\n\r\n', http_port))
logger.errx(task, 'write %1, %2', is_ok, err)
if not is_ok then
task:insert_result('HTTP_SYNC_RESPONSE', 1.0, got_content)
- is_ok, err = connection:write("POST /request HTTP/1.1\r\nHost: 127.0.0.1:18080\r\n\r\n")
+ is_ok, err = connection:write(string.format("POST /request HTTP/1.1\r\nHost: 127.0.0.1:%d\r\n\r\n", http_port))
logger.errx(task, 'write[2] %1, %2', is_ok, err)
got_content = ''
task = task,
host = '127.0.0.1',
timeout = 20,
- port = 18080,
+ port = http_port,
}
logger.errx(task, 'connect_sync %1, %2', is_ok, tostring(connection))
return
end
- is_ok, err = connection:write(string.format('%s %s HTTP/1.1\r\nHost: 127.0.0.1:18080\r\nConnection: close\r\n\r\n', method:upper(), url))
+ is_ok, err = connection:write(string.format('%s %s HTTP/1.1\r\nHost: 127.0.0.1:%d\r\nConnection: close\r\n\r\n', method:upper(), url, http_port))
logger.errx(task, 'write %1, %2', is_ok, err)
if not is_ok then
task = task,
callback = read_cb,
host = '127.0.0.1',
- data = {'GET /request HTTP/1.1\r\nHost: 127.0.0.1:18080\r\nConnection: close\r\n\r\n'},
+ data = {string.format('GET /request HTTP/1.1\r\nHost: 127.0.0.1:%d\r\nConnection: close\r\n\r\n', http_port)},
read = true,
- port = 18080,
+ port = http_port,
connect_timeout = 2.0,
read_timeout = 2.0,
write_timeout = 2.0,
callback = read_cb,
on_error = err_cb,
host = '127.0.0.1',
- port = 18080,
+ port = http_port,
-- /timeout sleeps 4s before responding. read_timeout=0.5 forces the read
-- side to time out after the connect succeeds.
- data = {'GET /timeout HTTP/1.1\r\nHost: 127.0.0.1:18080\r\nConnection: close\r\n\r\n'},
+ data = {string.format('GET /timeout HTTP/1.1\r\nHost: 127.0.0.1:%d\r\nConnection: close\r\n\r\n', http_port)},
read = true,
stop_pattern = '\r\n\r\n',
connect_timeout = 2.0,
<html>
<body>
<p>Test message with redirect chains</p>
-<a href="http://127.0.0.1:18080/chain1">Chain 1</a>
-<a href="http://127.0.0.1:18080/redirect2">Redirect 2</a>
+<a href="http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/chain1">Chain 1</a>
+<a href="http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/redirect2">Redirect 2</a>
</body>
</html>
<html>
<body>
-<a href="http://127.0.0.1:18080/chain1">chain link</a>
+<a href="http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/chain1">chain link</a>
</body>
</html>
Content-type: text/plain
-bla http://127.0.0.1:18080/redirect2
+bla http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/redirect2
-lol http://127.0.0.1:18080/redirect3
+lol http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/redirect3
-Content-type: text/html\r
-\r
-<html>\r
-<body>\r
-<a href="http://127.0.0.1:18080/chain_intermediate_1">Call us via chain</a>\r
-</body>\r
+Content-type: text/html
+
+<html>
+<body>
+<a href="http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/chain_intermediate_1">Call us via chain</a>
+</body>
</html>
\ No newline at end of file
<html>
<body>
-<a href="http://127.0.0.1:18080/tel_redirect">Call us</a>
-<a href="http://127.0.0.1:18080/mailto_redirect">Email us</a>
+<a href="http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/tel_redirect">Call us</a>
+<a href="http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/mailto_redirect">Email us</a>
</body>
</html>
Content-type: text/html
-<a href="http://redir.example.net:18080/redir_to_example">http://www.example.com/</a>
+<a href="http://redir.example.net:${RSPAMD_PORT_DUMMY_HTTP}/redir_to_example">http://www.example.com/</a>
Content-type: text/plain
-click http://127.0.0.1:18080/combo_entry
+click http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/combo_entry
<html>
<body>
-<a href="http://127.0.0.1:18080/tel_redirect">Call us</a>
+<a href="http://127.0.0.1:${RSPAMD_PORT_DUMMY_HTTP}/tel_redirect">Call us</a>
</body>
</html>