aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-27 14:24:32 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-27 14:24:32 +0100
commitb00b1fd84446879e68dc2ff4c3904c8058d25f30 (patch)
tree9a1febb1615d7f21c9970d33f6d1ef90163f1d33 /test/functional
parentc1c6c58ef594c80f3f6b488f33adfa3fb7647b9d (diff)
downloadrspamd-b00b1fd84446879e68dc2ff4c3904c8058d25f30.tar.gz
rspamd-b00b1fd84446879e68dc2ff4c3904c8058d25f30.zip
[Test] Added test for dns request from rspamadm
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/cases/151_rspamadm_async.robot22
-rw-r--r--test/functional/lua/rspamadm/test_dns_client.lua29
2 files changed, 50 insertions, 1 deletions
diff --git a/test/functional/cases/151_rspamadm_async.robot b/test/functional/cases/151_rspamadm_async.robot
index 31fa84245..10fa6bbe2 100644
--- a/test/functional/cases/151_rspamadm_async.robot
+++ b/test/functional/cases/151_rspamadm_async.robot
@@ -9,7 +9,9 @@ Suite Teardown Terminate All Processes kill=True
*** Variables ***
${REDIS_SCOPE} Test
-
+${CONFIG} ${TESTDIR}/configs/plugins.conf
+${URL_TLD} ${TESTDIR}/../lua/unit/test_tld.dat
+${PLUGIN_CONFIG}
*** Test Cases ***
Tcp client
@@ -24,6 +26,14 @@ Redis client
Should Be Equal As Integers ${result.rc} 0
Should Be Equal ${result.stdout} true\thello from lua on redis
+DNS client
+ ${tmpdir} = Prepare temp directory ${CONFIG}
+ Set test variable ${tmpdir}
+ ${result} = Run Process ${RSPAMADM} --var\=CONFDIR\=${tmpdir} lua -b ${TESTDIR}/lua/rspamadm/test_dns_client.lua
+ Should Be Equal As Integers ${result.rc} 0
+ Should Be Equal ${result.stdout} true\tk=ed25519; p=yi50DjK5O9pqbFpNHklsv9lqaS0ArSYu02qp1S0DW1Y=
+ Cleanup Temporary Directory ${tmpdir}
+
*** Keywords ***
Rspamadm test Setup
@@ -40,3 +50,13 @@ Run Dummy Http
[Arguments]
${result} = Start Process ${TESTDIR}/util/dummy_http.py
Wait Until Created /tmp/dummy_http.pid
+
+Prepare temp directory
+ [Arguments] ${CONFIG}
+ ${template} = Get File ${CONFIG}
+ ${tmpdir} = Make Temporary Directory
+ ${config} = Replace Variables ${template}
+ ${config} = Replace Variables ${config}
+ Log ${config}
+ Create File ${tmpdir}/rspamd.conf ${config}
+ [Return] ${tmpdir} \ No newline at end of file
diff --git a/test/functional/lua/rspamadm/test_dns_client.lua b/test/functional/lua/rspamadm/test_dns_client.lua
new file mode 100644
index 000000000..15b1d6044
--- /dev/null
+++ b/test/functional/lua/rspamadm/test_dns_client.lua
@@ -0,0 +1,29 @@
+local rspamd_dns = require "rspamd_dns"
+local logger = require "rspamd_logger"
+
+local _r,err = rspamd_config:load_ucl('/Users/mgalanin/build/robot-save/rspamd.conf.last')
+
+if not _r then
+ rspamd_logger.errx('cannot parse %s: %s', opts['config'], err)
+ os.exit(1)
+end
+
+_r,err = rspamd_config:parse_rcl({'logging', 'worker'})
+if not _r then
+ rspamd_logger.errx('cannot process %s: %s', opts['config'], err)
+ os.exit(1)
+end
+
+rspamd_config:init_subsystem('dns', rspamadm_ev_base)
+
+
+local is_ok, results = rspamd_dns.request({
+ config = rspamd_config,
+ session = rspamadm_session,
+
+ type = 'txt',
+ name = 'test._domainkey.example.com',
+ -- name = '_dmarc.google.com',
+ })
+
+print(is_ok, results[1])