25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Add more pubsub test cases

This commit is contained in:
Evgeniy Khramtsov 2013-06-26 03:00:27 +10:00
parent ae1af885ce
commit c05edabe58
4 changed files with 806 additions and 300 deletions

View File

@ -243,6 +243,10 @@ db_tests() ->
[roster_remove_master, [roster_remove_master,
roster_remove_slave]}]. roster_remove_slave]}].
%% db_tests() ->
%% [{single_user, [sequence],
%% [test_register, pubsub]}].
ldap_tests() -> ldap_tests() ->
[{ldap_tests, [sequence], [{ldap_tests, [sequence],
[test_auth, [test_auth,
@ -255,6 +259,9 @@ groups() ->
{mysql, [sequence], db_tests()}, {mysql, [sequence], db_tests()},
{pgsql, [sequence], db_tests()}]. {pgsql, [sequence], db_tests()}].
%% all() ->
%% [{group, mnesia}].
all() -> all() ->
[{group, ldap}, [{group, ldap},
{group, no_db}, {group, no_db},
@ -659,18 +666,23 @@ pubsub(Config) ->
Node = <<"presence">>, Node = <<"presence">>,
Item = #pubsub_item{id = ItemID, sub_els = [#presence{}]}, Item = #pubsub_item{id = ItemID, sub_els = [#presence{}]},
#iq{type = result, #iq{type = result,
sub_els = [#pubsub{publish = {<<"presence">>, sub_els = [#pubsub{publish = #pubsub_publish{
[#pubsub_item{id = ItemID}]}}]} = node = Node,
items = [#pubsub_item{id = ItemID}]}}]} =
send_recv(Config, send_recv(Config,
#iq{type = set, to = pubsub_jid(Config), #iq{type = set, to = pubsub_jid(Config),
sub_els = [#pubsub{publish = {Node, [Item]}}]}), sub_els = [#pubsub{publish = #pubsub_publish{
node = Node,
items = [Item]}}]}),
%% Subscribe to node "presence" %% Subscribe to node "presence"
I = send(Config, I1 = send(Config,
#iq{type = set, to = pubsub_jid(Config), #iq{type = set, to = pubsub_jid(Config),
sub_els = [#pubsub{subscribe = {Node, my_jid(Config)}}]}), sub_els = [#pubsub{subscribe = #pubsub_subscribe{
node = Node,
jid = my_jid(Config)}}]}),
?recv2( ?recv2(
#message{sub_els = [#pubsub_event{}, #delay{}]}, #message{sub_els = [#pubsub_event{}, #delay{}]},
#iq{type = result, id = I}), #iq{type = result, id = I1}),
%% Get subscriptions %% Get subscriptions
true = is_feature_advertised(Config, ?PUBSUB("retrieve-subscriptions")), true = is_feature_advertised(Config, ?PUBSUB("retrieve-subscriptions")),
#iq{type = result, #iq{type = result,
@ -687,6 +699,44 @@ pubsub(Config) ->
[#pubsub_affiliation{node = Node, type = owner}]}]} = [#pubsub_affiliation{node = Node, type = owner}]}]} =
send_recv(Config, #iq{type = get, to = pubsub_jid(Config), send_recv(Config, #iq{type = get, to = pubsub_jid(Config),
sub_els = [#pubsub{affiliations = []}]}), sub_els = [#pubsub{affiliations = []}]}),
%% Get subscription options
true = is_feature_advertised(Config, ?PUBSUB("subscription-options")),
#iq{type = result, sub_els = [#pubsub{options = #pubsub_options{
node = Node}}]} =
send_recv(Config,
#iq{type = get, to = pubsub_jid(Config),
sub_els = [#pubsub{options = #pubsub_options{
node = Node,
jid = my_jid(Config)}}]}),
%% Fetching published items from node "presence"
#iq{type = result,
sub_els = [#pubsub{items = #pubsub_items{
node = Node,
items = [Item]}}]} =
send_recv(Config,
#iq{type = get, to = pubsub_jid(Config),
sub_els = [#pubsub{items = #pubsub_items{node = Node}}]}),
%% Deleting the item from the node
true = is_feature_advertised(Config, ?PUBSUB("delete-items")),
I2 = send(Config,
#iq{type = set, to = pubsub_jid(Config),
sub_els = [#pubsub{retract = #pubsub_retract{
node = Node,
items = [#pubsub_item{id = ItemID}]}}]}),
?recv2(
#iq{type = result, id = I2, sub_els = []},
#message{sub_els = [#pubsub_event{
items = [#pubsub_event_items{
node = Node,
retract = [ItemID]}]},
#shim{headers = [{<<"Collection">>, Node}]}]}),
%% Unsubscribe from node "presence"
#iq{type = result, sub_els = []} =
send_recv(Config,
#iq{type = set, to = pubsub_jid(Config),
sub_els = [#pubsub{unsubscribe = #pubsub_unsubscribe{
node = Node,
jid = my_jid(Config)}}]}),
disconnect(Config). disconnect(Config).
auth_md5(Config) -> auth_md5(Config) ->

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,10 @@
host :: binary(), host :: binary(),
port = 1080 :: non_neg_integer()}). port = 1080 :: non_neg_integer()}).
-record(pubsub_unsubscribe, {node :: binary(),
jid :: any(),
subid :: binary()}).
-record(ping, {}). -record(ping, {}).
-record(delay, {stamp :: any(), -record(delay, {stamp :: any(),
@ -41,6 +45,9 @@
-record(pubsub_item, {id :: binary(), -record(pubsub_item, {id :: binary(),
sub_els = [] :: [any()]}). sub_els = [] :: [any()]}).
-record(pubsub_publish, {node :: binary(),
items = [] :: [#pubsub_item{}]}).
-record(roster_item, {jid :: any(), -record(roster_item, {jid :: any(),
name :: binary(), name :: binary(),
groups = [] :: [binary()], groups = [] :: [binary()],
@ -60,7 +67,7 @@
-record(stat, {name :: binary(), -record(stat, {name :: binary(),
units :: binary(), units :: binary(),
value :: binary(), value :: binary(),
error = [] :: [{integer(),binary()}]}). error = [] :: [{integer(),'undefined' | binary()}]}).
-record('see-other-host', {host :: binary()}). -record('see-other-host', {host :: binary()}).
@ -81,6 +88,9 @@
-record(sasl_response, {text :: any()}). -record(sasl_response, {text :: any()}).
-record(pubsub_subscribe, {node :: binary(),
jid :: any()}).
-record(sasl_auth, {mechanism :: binary(), -record(sasl_auth, {mechanism :: binary(),
text :: any()}). text :: any()}).
@ -116,6 +126,8 @@
subid :: binary(), subid :: binary(),
type :: 'none' | 'pending' | 'subscribed' | 'unconfigured'}). type :: 'none' | 'pending' | 'subscribed' | 'unconfigured'}).
-record(shim, {headers = [] :: [{binary(),'undefined' | binary()}]}).
-record(caps, {hash :: binary(), -record(caps, {hash :: binary(),
node :: binary(), node :: binary(),
ver :: any()}). ver :: any()}).
@ -127,11 +139,6 @@
-record(stats, {stat = [] :: [#stat{}]}). -record(stats, {stat = [] :: [#stat{}]}).
-record(pubsub, {subscriptions :: {binary(),[#pubsub_subscription{}]},
affiliations :: [#pubsub_affiliation{}],
publish :: {binary(),[#pubsub_item{}]},
subscribe :: {binary(),_}}).
-record(pubsub_items, {node :: binary(), -record(pubsub_items, {node :: binary(),
max_items :: non_neg_integer(), max_items :: non_neg_integer(),
subid :: binary(), subid :: binary(),
@ -150,6 +157,10 @@
x400 = false :: boolean(), x400 = false :: boolean(),
userid :: binary()}). userid :: binary()}).
-record(pubsub_retract, {node :: binary(),
notify = false :: any(),
items = [] :: [#pubsub_item{}]}).
-record(text, {lang :: binary(), -record(text, {lang :: binary(),
data :: binary()}). data :: binary()}).
@ -171,9 +182,9 @@
values = [] :: [binary()], values = [] :: [binary()],
options = [] :: [binary()]}). options = [] :: [binary()]}).
-record(version, {version_name :: binary(), -record(version, {name :: binary(),
version_ver :: binary(), ver :: binary(),
version_os :: binary()}). os :: binary()}).
-record(muc_invite, {reason :: binary(), -record(muc_invite, {reason :: binary(),
from :: any(), from :: any(),
@ -233,6 +244,7 @@
-record(identity, {category :: binary(), -record(identity, {category :: binary(),
type :: binary(), type :: binary(),
lang :: binary(),
name :: binary()}). name :: binary()}).
-record(bookmark_conference, {name :: binary(), -record(bookmark_conference, {name :: binary(),
@ -244,23 +256,23 @@
-record(register, {registered = false :: boolean(), -record(register, {registered = false :: boolean(),
remove = false :: boolean(), remove = false :: boolean(),
instructions :: binary(), instructions :: binary(),
username :: binary(), username :: 'none' | binary(),
nick :: binary(), nick :: 'none' | binary(),
password :: binary(), password :: 'none' | binary(),
name :: binary(), name :: 'none' | binary(),
first :: binary(), first :: 'none' | binary(),
last :: binary(), last :: 'none' | binary(),
email :: binary(), email :: 'none' | binary(),
address :: binary(), address :: 'none' | binary(),
city :: binary(), city :: 'none' | binary(),
state :: binary(), state :: 'none' | binary(),
zip :: binary(), zip :: 'none' | binary(),
phone :: binary(), phone :: 'none' | binary(),
url :: binary(), url :: 'none' | binary(),
date :: binary(), date :: 'none' | binary(),
misc :: binary(), misc :: 'none' | binary(),
text :: binary(), text :: 'none' | binary(),
key :: binary()}). key :: 'none' | binary()}).
-record(bookmark_url, {name :: binary(), -record(bookmark_url, {name :: binary(),
url :: binary()}). url :: binary()}).
@ -310,6 +322,20 @@
-record(muc_owner, {destroy :: #muc_owner_destroy{}, -record(muc_owner, {destroy :: #muc_owner_destroy{},
config :: #xdata{}}). config :: #xdata{}}).
-record(pubsub_options, {node :: binary(),
jid :: any(),
subid :: binary(),
xdata :: #xdata{}}).
-record(pubsub, {subscriptions :: {'none' | binary(),[#pubsub_subscription{}]},
affiliations :: [#pubsub_affiliation{}],
publish :: #pubsub_publish{},
subscribe :: #pubsub_subscribe{},
unsubscribe :: #pubsub_unsubscribe{},
options :: #pubsub_options{},
items :: #pubsub_items{},
retract :: #pubsub_retract{}}).
-record(disco_info, {node :: binary(), -record(disco_info, {node :: binary(),
identity = [] :: [#identity{}], identity = [] :: [#identity{}],
feature = [] :: [binary()], feature = [] :: [binary()],
@ -362,8 +388,8 @@
items = [] :: [#privacy_item{}]}). items = [] :: [#privacy_item{}]}).
-record(privacy, {lists = [] :: [#privacy_list{}], -record(privacy, {lists = [] :: [#privacy_list{}],
default :: binary(), default :: 'none' | binary(),
active :: binary()}). active :: 'none' | binary()}).
-record(stream_error, {reason :: atom() | #'see-other-host'{}, -record(stream_error, {reason :: atom() | #'see-other-host'{},
text :: #text{}}). text :: #text{}}).

View File

@ -29,12 +29,15 @@
{version, {version,
#elem{name = <<"query">>, #elem{name = <<"query">>,
xmlns = <<"jabber:iq:version">>, xmlns = <<"jabber:iq:version">>,
result = {version, '$version_name', '$version_ver', '$version_os'}, result = {version, '$name', '$ver', '$os'},
refs = [#ref{name = version_name, refs = [#ref{name = version_name,
label = '$name',
min = 0, max = 1}, min = 0, max = 1},
#ref{name = version_ver, #ref{name = version_ver,
label = '$ver',
min = 0, max = 1}, min = 0, max = 1},
#ref{name = version_os, #ref{name = version_os,
label = '$os',
min = 0, max = 1}]}}. min = 0, max = 1}]}}.
{roster_group, {roster_group,
@ -174,11 +177,13 @@
{disco_identity, {disco_identity,
#elem{name = <<"identity">>, #elem{name = <<"identity">>,
xmlns = <<"http://jabber.org/protocol/disco#info">>, xmlns = <<"http://jabber.org/protocol/disco#info">>,
result = {identity, '$category', '$type', '$name'}, result = {identity, '$category', '$type', '$lang', '$name'},
attrs = [#attr{name = <<"category">>, attrs = [#attr{name = <<"category">>,
required = true}, required = true},
#attr{name = <<"type">>, #attr{name = <<"type">>,
required = true}, required = true},
#attr{name = <<"xml:lang">>,
label = '$lang'},
#attr{name = <<"name">>}]}}. #attr{name = <<"name">>}]}}.
{disco_feature, {disco_feature,
@ -1665,35 +1670,93 @@
{pubsub_subscribe, {pubsub_subscribe,
#elem{name = <<"subscribe">>, #elem{name = <<"subscribe">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>, xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {'$node', '$jid'}, result = {pubsub_subscribe, '$node', '$jid'},
attrs = [#attr{name = <<"node">>}, attrs = [#attr{name = <<"node">>},
#attr{name = <<"jid">>, #attr{name = <<"jid">>,
required = true, required = true,
dec = {dec_jid, []}, dec = {dec_jid, []},
enc = {enc_jid, []}}]}}. enc = {enc_jid, []}}]}}.
{pubsub_unsubscribe,
#elem{name = <<"unsubscribe">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {pubsub_unsubscribe, '$node', '$jid', '$subid'},
attrs = [#attr{name = <<"node">>},
#attr{name = <<"subid">>},
#attr{name = <<"jid">>,
required = true,
dec = {dec_jid, []},
enc = {enc_jid, []}}]}}.
{pubsub_publish, {pubsub_publish,
#elem{name = <<"publish">>, #elem{name = <<"publish">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>, xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {'$node', '$items'}, result = {pubsub_publish, '$node', '$items'},
attrs = [#attr{name = <<"node">>, attrs = [#attr{name = <<"node">>,
required = true}], required = true}],
refs = [#ref{name = pubsub_item, label = '$items'}]}}. refs = [#ref{name = pubsub_item, label = '$items'}]}}.
{pubsub_options,
#elem{name = <<"options">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {pubsub_options, '$node', '$jid', '$subid', '$xdata'},
attrs = [#attr{name = <<"node">>},
#attr{name = <<"subid">>},
#attr{name = <<"jid">>,
required = true,
dec = {dec_jid, []},
enc = {enc_jid, []}}],
refs = [#ref{name = xdata, min = 0, max = 1,
label = '$xdata'}]}}.
{pubsub_retract,
#elem{name = <<"retract">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {pubsub_retract, '$node', '$notify', '$items'},
attrs = [#attr{name = <<"node">>,
required = true},
#attr{name = <<"notify">>,
default = false,
dec = {dec_bool, []},
enc = {enc_bool, []}}],
refs = [#ref{name = pubsub_item, label = '$items'}]}}.
{pubsub, {pubsub,
#elem{name = <<"pubsub">>, #elem{name = <<"pubsub">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>, xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {pubsub, '$subscriptions', '$affiliations', '$publish', result = {pubsub, '$subscriptions', '$affiliations', '$publish',
'$subscribe'}, '$subscribe', '$unsubscribe', '$options', '$items',
'$retract'},
refs = [#ref{name = pubsub_subscriptions, label = '$subscriptions', refs = [#ref{name = pubsub_subscriptions, label = '$subscriptions',
min = 0, max = 1}, min = 0, max = 1},
#ref{name = pubsub_affiliations, label = '$affiliations', #ref{name = pubsub_affiliations, label = '$affiliations',
min = 0, max = 1}, min = 0, max = 1},
#ref{name = pubsub_subscribe, label = '$subscribe', #ref{name = pubsub_subscribe, label = '$subscribe',
min = 0, max = 1}, min = 0, max = 1},
#ref{name = pubsub_unsubscribe, label = '$unsubscribe',
min = 0, max = 1},
#ref{name = pubsub_options, label = '$options',
min = 0, max = 1},
#ref{name = pubsub_items, label = '$items',
min = 0, max = 1},
#ref{name = pubsub_retract, label = '$retract',
min = 0, max = 1},
#ref{name = pubsub_publish, label = '$publish', #ref{name = pubsub_publish, label = '$publish',
min = 0, max = 1}]}}. min = 0, max = 1}]}}.
{shim_header,
#elem{name = <<"header">>,
xmlns = <<"http://jabber.org/protocol/shim">>,
result = {'$name', '$cdata'},
attrs = [#attr{name = <<"name">>,
required = true}]}}.
{shim_headers,
#elem{name = <<"headers">>,
xmlns = <<"http://jabber.org/protocol/shim">>,
result = {shim, '$headers'},
refs = [#ref{name = shim_header, label = '$headers'}]}}.
{delay, {delay,
#elem{name = <<"delay">>, #elem{name = <<"delay">>,
xmlns = <<"urn:xmpp:delay">>, xmlns = <<"urn:xmpp:delay">>,