25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +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_slave]}].
%% db_tests() ->
%% [{single_user, [sequence],
%% [test_register, pubsub]}].
ldap_tests() ->
[{ldap_tests, [sequence],
[test_auth,
@ -255,6 +259,9 @@ groups() ->
{mysql, [sequence], db_tests()},
{pgsql, [sequence], db_tests()}].
%% all() ->
%% [{group, mnesia}].
all() ->
[{group, ldap},
{group, no_db},
@ -659,18 +666,23 @@ pubsub(Config) ->
Node = <<"presence">>,
Item = #pubsub_item{id = ItemID, sub_els = [#presence{}]},
#iq{type = result,
sub_els = [#pubsub{publish = {<<"presence">>,
[#pubsub_item{id = ItemID}]}}]} =
sub_els = [#pubsub{publish = #pubsub_publish{
node = Node,
items = [#pubsub_item{id = ItemID}]}}]} =
send_recv(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"
I = send(Config,
I1 = send(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(
#message{sub_els = [#pubsub_event{}, #delay{}]},
#iq{type = result, id = I}),
#iq{type = result, id = I1}),
%% Get subscriptions
true = is_feature_advertised(Config, ?PUBSUB("retrieve-subscriptions")),
#iq{type = result,
@ -687,6 +699,44 @@ pubsub(Config) ->
[#pubsub_affiliation{node = Node, type = owner}]}]} =
send_recv(Config, #iq{type = get, to = pubsub_jid(Config),
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).
auth_md5(Config) ->

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -29,12 +29,15 @@
{version,
#elem{name = <<"query">>,
xmlns = <<"jabber:iq:version">>,
result = {version, '$version_name', '$version_ver', '$version_os'},
result = {version, '$name', '$ver', '$os'},
refs = [#ref{name = version_name,
label = '$name',
min = 0, max = 1},
#ref{name = version_ver,
label = '$ver',
min = 0, max = 1},
#ref{name = version_os,
label = '$os',
min = 0, max = 1}]}}.
{roster_group,
@ -174,11 +177,13 @@
{disco_identity,
#elem{name = <<"identity">>,
xmlns = <<"http://jabber.org/protocol/disco#info">>,
result = {identity, '$category', '$type', '$name'},
result = {identity, '$category', '$type', '$lang', '$name'},
attrs = [#attr{name = <<"category">>,
required = true},
#attr{name = <<"type">>,
required = true},
#attr{name = <<"xml:lang">>,
label = '$lang'},
#attr{name = <<"name">>}]}}.
{disco_feature,
@ -1665,35 +1670,93 @@
{pubsub_subscribe,
#elem{name = <<"subscribe">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {'$node', '$jid'},
result = {pubsub_subscribe, '$node', '$jid'},
attrs = [#attr{name = <<"node">>},
#attr{name = <<"jid">>,
required = true,
dec = {dec_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,
#elem{name = <<"publish">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {'$node', '$items'},
result = {pubsub_publish, '$node', '$items'},
attrs = [#attr{name = <<"node">>,
required = true}],
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,
#elem{name = <<"pubsub">>,
xmlns = <<"http://jabber.org/protocol/pubsub">>,
result = {pubsub, '$subscriptions', '$affiliations', '$publish',
'$subscribe'},
'$subscribe', '$unsubscribe', '$options', '$items',
'$retract'},
refs = [#ref{name = pubsub_subscriptions, label = '$subscriptions',
min = 0, max = 1},
#ref{name = pubsub_affiliations, label = '$affiliations',
min = 0, max = 1},
#ref{name = pubsub_subscribe, label = '$subscribe',
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',
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,
#elem{name = <<"delay">>,
xmlns = <<"urn:xmpp:delay">>,