diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-27 19:06:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 19:06:18 +0100 |
commit | 4cf94ce5492657adf002920df2fa6f03c1f02f5f (patch) | |
tree | 7805e55370f06d2646d431eb02558a222513a5d5 /test | |
parent | 30365705c8a07abb207d5d867f00ca697a7e6e37 (diff) | |
parent | 023a17c1da5fa20491e2926e753f532f2a43d06f (diff) | |
download | rspamd-4cf94ce5492657adf002920df2fa6f03c1f02f5f.tar.gz rspamd-4cf94ce5492657adf002920df2fa6f03c1f02f5f.zip |
Merge pull request #2540 from negram/dns-sync-rspamadm
Dns sync rspamadm
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/cases/151_rspamadm_async.robot | 24 | ||||
-rw-r--r-- | test/functional/lua/rspamadm/test_dns_client.lua | 30 |
2 files changed, 53 insertions, 1 deletions
diff --git a/test/functional/cases/151_rspamadm_async.robot b/test/functional/cases/151_rspamadm_async.robot index 31fa84245..a496bf12a 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,16 @@ 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 + Log ${result.stdout} + Log ${result.stderr} + 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 +52,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..c54d59499 --- /dev/null +++ b/test/functional/lua/rspamadm/test_dns_client.lua @@ -0,0 +1,30 @@ +local rspamd_dns = require "rspamd_dns" +local logger = require "rspamd_logger" + +local config_path = rspamd_paths['CONFDIR'] .. '/rspamd.conf' +local _r,err = rspamd_config:load_ucl(config_path) + +if not _r then + logger.errx('cannot parse %s: %s (r=%s)', config_path, err, _r) + os.exit(1) +end + +_r,err = rspamd_config:parse_rcl({'logging', 'worker'}) +if not _r then + logger.errx('cannot process %s: %s (r=%s)', config_path, err, _r) + 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]) |