mirror of
https://github.com/processone/ejabberd
synced 2025-10-06 03:50:15 +02:00
mod_antispam: test whitelisted domain
This commit is contained in:
parent
7a6e409879
commit
10ec128b94
5 changed files with 46 additions and 1 deletions
|
@ -58,7 +58,8 @@ single_cases() ->
|
||||||
single_test(block_domain_in_vhost),
|
single_test(block_domain_in_vhost),
|
||||||
single_test(unblock_domain_in_vhost2),
|
single_test(unblock_domain_in_vhost2),
|
||||||
single_test(jid_cache),
|
single_test(jid_cache),
|
||||||
single_test(rtbl_domains)]}.
|
single_test(rtbl_domains),
|
||||||
|
single_test(rtbl_domains_whitelisted)]}.
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
||||||
|
@ -200,6 +201,46 @@ rtbl_domains(Config) ->
|
||||||
{result, _} = mod_pubsub:delete_node(RTBLHost, RTBLDomainsNode, Owner),
|
{result, _} = mod_pubsub:delete_node(RTBLHost, RTBLDomainsNode, Owner),
|
||||||
disconnect(Config).
|
disconnect(Config).
|
||||||
|
|
||||||
|
rtbl_domains_whitelisted(Config) ->
|
||||||
|
Host = ?config(server, Config),
|
||||||
|
RTBLHost =
|
||||||
|
jid:to_string(
|
||||||
|
suite:pubsub_jid(Config)),
|
||||||
|
RTBLDomainsNode = <<"spam_source_domains">>,
|
||||||
|
OldOpts = gen_mod:get_module_opts(Host, mod_antispam),
|
||||||
|
NewOpts =
|
||||||
|
maps:merge(OldOpts, #{rtbl_host => RTBLHost, rtbl_domains_node => RTBLDomainsNode}),
|
||||||
|
Owner = jid:make(?config(user, Config), ?config(server, Config), <<>>),
|
||||||
|
{result, _} =
|
||||||
|
mod_pubsub:create_node(RTBLHost,
|
||||||
|
?config(server, Config),
|
||||||
|
RTBLDomainsNode,
|
||||||
|
Owner,
|
||||||
|
<<"flat">>),
|
||||||
|
{result, _} =
|
||||||
|
mod_pubsub:publish_item(RTBLHost,
|
||||||
|
?config(server, Config),
|
||||||
|
RTBLDomainsNode,
|
||||||
|
Owner,
|
||||||
|
<<"whitelisted.domain">>,
|
||||||
|
[xmpp:encode(#ps_item{id = <<"whitelisted.domain">>,
|
||||||
|
sub_els = []})]),
|
||||||
|
mod_antispam:reload(Host, OldOpts, NewOpts),
|
||||||
|
{result, _} =
|
||||||
|
mod_pubsub:publish_item(RTBLHost,
|
||||||
|
?config(server, Config),
|
||||||
|
RTBLDomainsNode,
|
||||||
|
Owner,
|
||||||
|
<<"yetanother.domain">>,
|
||||||
|
[xmpp:encode(#ps_item{id = <<"yetanother.domain">>,
|
||||||
|
sub_els = []})]),
|
||||||
|
?retry(100, 10, ?match(true, (has_spam_domain(<<"yetanother.domain">>))(Host))),
|
||||||
|
%% we assume that the previous "whitelisted.domain" pubsub item has been consumed by now, so we
|
||||||
|
%% can check that it doesn't exist
|
||||||
|
?match(false, (has_spam_domain(<<"whitelisted.domain">>))(Host)),
|
||||||
|
{result, _} = mod_pubsub:delete_node(RTBLHost, RTBLDomainsNode, Owner),
|
||||||
|
disconnect(Config).
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
|
@ -11,6 +11,7 @@ define_macro:
|
||||||
spam_jids_file: spam_jids.txt
|
spam_jids_file: spam_jids.txt
|
||||||
spam_domains_file: spam_domains.txt
|
spam_domains_file: spam_domains.txt
|
||||||
spam_urls_file: spam_urls.txt
|
spam_urls_file: spam_urls.txt
|
||||||
|
whitelist_domains_file: whitelist_domains.txt
|
||||||
mod_blocking: []
|
mod_blocking: []
|
||||||
mod_caps:
|
mod_caps:
|
||||||
db_type: internal
|
db_type: internal
|
||||||
|
|
|
@ -12,6 +12,7 @@ define_macro:
|
||||||
spam_jids_file: spam_jids.txt
|
spam_jids_file: spam_jids.txt
|
||||||
spam_domains_file: spam_domains.txt
|
spam_domains_file: spam_domains.txt
|
||||||
spam_urls_file: spam_urls.txt
|
spam_urls_file: spam_urls.txt
|
||||||
|
whitelist_domains_file: whitelist_domains.txt
|
||||||
mod_blocking: []
|
mod_blocking: []
|
||||||
mod_caps:
|
mod_caps:
|
||||||
db_type: internal
|
db_type: internal
|
||||||
|
|
1
test/ejabberd_SUITE_data/whitelist_domains.txt
Normal file
1
test/ejabberd_SUITE_data/whitelist_domains.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
whitelisted.domain
|
|
@ -54,6 +54,7 @@ init_config(Config) ->
|
||||||
copy_file(Config, "spam_jids.txt"),
|
copy_file(Config, "spam_jids.txt"),
|
||||||
copy_file(Config, "spam_urls.txt"),
|
copy_file(Config, "spam_urls.txt"),
|
||||||
copy_file(Config, "spam_domains.txt"),
|
copy_file(Config, "spam_domains.txt"),
|
||||||
|
copy_file(Config, "whitelist_domains.txt"),
|
||||||
{ok, MacrosContentTpl} = file:read_file(MacrosPathTpl),
|
{ok, MacrosContentTpl} = file:read_file(MacrosPathTpl),
|
||||||
Password = <<"password!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>,
|
Password = <<"password!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>,
|
||||||
Backends = get_config_backends(),
|
Backends = get_config_backends(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue