25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Add mod_caps checks to the testing suite

This commit is contained in:
Evgeniy Khramtsov 2014-07-15 11:53:40 +04:00
parent 2d6a838905
commit fd298521e2
2 changed files with 41 additions and 4 deletions

View File

@ -400,11 +400,46 @@ presence(Config) ->
disconnect(Config).
presence_broadcast(Config) ->
send(Config, #presence{}),
Feature = <<"p1:tmp:", (randoms:get_string())/binary>>,
Ver = crypto:sha(["client", $/, "bot", $/, "en", $/,
"ejabberd_ct", $<, Feature, $<]),
B64Ver = base64:encode(Ver),
Node = <<(?EJABBERD_CT_URI)/binary, $#, B64Ver/binary>>,
Server = ?config(server, Config),
ServerJID = server_jid(Config),
Info = #disco_info{identities =
[#identity{category = <<"client">>,
type = <<"bot">>,
lang = <<"en">>,
name = <<"ejabberd_ct">>}],
node = Node, features = [Feature]},
Caps = #caps{hash = <<"sha-1">>, node = ?EJABBERD_CT_URI, ver = Ver},
send(Config, #presence{sub_els = [Caps]}),
JID = my_jid(Config),
%% We receive the welcome message and the presence broadcast
?recv2(#message{type = normal},
%% We receive:
%% 1) disco#info iq request for CAPS
%% 2) welcome message
%% 3) presence broadcast
{IQ, _, _} = ?recv3(#iq{type = get,
from = ServerJID,
sub_els = [#disco_info{node = Node}]},
#message{type = normal},
#presence{from = JID, to = JID}),
send(Config, #iq{type = result, id = IQ#iq.id,
to = ServerJID, sub_els = [Info]}),
%% We're trying to read our feature from ejabberd database
%% with exponential back-off as our IQ response may be delayed.
[Feature] =
lists:foldl(
fun(Time, []) ->
timer:sleep(Time),
mod_caps:get_features(
Server,
mod_caps:read_caps(
[xmpp_codec:encode(Caps)]));
(_, Acc) ->
Acc
end, [], [0, 100, 200, 2000, 5000, 10000]),
disconnect(Config).
ping(Config) ->

View File

@ -15,6 +15,8 @@
-define(PUBSUB(Node), <<(?NS_PUBSUB)/binary, "#", Node>>).
-define(EJABBERD_CT_URI, <<"http://www.process-one.net/en/ejabberd_ct/">>).
-define(recv2(P1, P2),
(fun() ->
case {R1 = recv(), R2 = recv()} of