Skip to content

Commit

Permalink
Update expected listener config options used in tests
Browse files Browse the repository at this point in the history
The paths are TOML ones, e.g. [listen, s2s]
The resulting path would be [listen] or, more precisely,
[listen, N] where N is the N-th element of the list.
However, this would make it impossible to disinguish the listener types.
  • Loading branch information
chrzaszcz committed Apr 15, 2022
1 parent 8346a21 commit 661ed64
Showing 1 changed file with 157 additions and 109 deletions.
266 changes: 157 additions & 109 deletions test/common/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ options("miscellaneous") ->
{hosts, [<<"localhost">>, <<"anonymous.localhost">>]},
{language, <<"en">>},
{listen,
[#{ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4, module => ejabberd_cowboy,
modules =>
[{"_", "/ws-xmpp", mod_websockets,
[{ejabberd_service, [{access, all},
{max_fsm_queue, 1000},
{password, "secret"},
{shaper_rule, fast}]}]}],
port => 5280, proto => tcp,
transport_options => [{max_connections, 1024}, {num_acceptors, 10}]}]},
[config([listen, http],
#{port => 5280,
handlers => [{"_", "/ws-xmpp", mod_websockets,
[{service, maps:merge(extra_service_listener_config(),
#{password => "secret",
shaper_rule => fast,
max_fsm_queue => 1000})}]
}],
transport => #{num_acceptors => 10, max_connections => 1024}
})]},
{loglevel, warning},
{mongooseimctl_access_commands,
[{local, ["join_cluster"], [{node, "mongooseim@prime"}]}]},
Expand Down Expand Up @@ -129,104 +128,113 @@ options("mongooseim-pgsql") ->
[<<"localhost">>, <<"anonymous.localhost">>, <<"localhost.bis">>]},
{language, <<"en">>},
{listen,
[#{access => c2s, ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4, max_stanza_size => 65536, module => ejabberd_c2s,
port => 5222, proto => tcp, shaper => c2s_shaper,
tls => [{certfile, "priv/dc1.pem"}, {dhfile, "priv/dh.pem"}, starttls],
zlib => 10000},
#{access => c2s, ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4, max_stanza_size => 65536, module => ejabberd_c2s,
port => 5223, proto => tcp, shaper => c2s_shaper, zlib => 4096},
#{ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4, module => ejabberd_cowboy,
modules =>
[{"_", "/http-bind", mod_bosh, []},
{"_", "/ws-xmpp", mod_websockets,
[{ejabberd_service, [{access, all},
{password, "secret"},
{shaper_rule, fast}]}]}],
port => 5280, proto => tcp,
transport_options => [{max_connections, 1024}, {num_acceptors, 10}]},
#{ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4, module => ejabberd_cowboy,
modules =>
[{"_", "/http-bind", mod_bosh, []},
{"_", "/ws-xmpp", mod_websockets,
[{max_stanza_size, 100},
{ping_rate, 120000},
{timeout, infinity}]},
{"localhost", "/api", mongoose_api_admin,
[{auth, {<<"ala">>, <<"makotaipsa">>}}]},
{"localhost", "/api/contacts/{:jid}", mongoose_api_client, []}],
port => 5285, proto => tcp,
ssl =>
[{certfile, "priv/cert.pem"},
{keyfile, "priv/dc1.pem"},
{password, []}],
transport_options => [{max_connections, 1024}, {num_acceptors, 10}]},
#{ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
ip_version => 4, module => ejabberd_cowboy,
modules => [{"localhost", "/api", mongoose_api_admin, []}],
port => 8088, proto => tcp,
transport_options => [{max_connections, 1024}, {num_acceptors, 10}]},
#{ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4, module => ejabberd_cowboy,
modules =>
[{"_", "/api-docs/[...]", cowboy_static,
{priv_dir, cowboy_swagger, "swagger",
[{mimetypes, cow_mimetypes, all}]}},
{"_", "/api-docs/swagger.json", cowboy_swagger_json_handler, #{}},
{"_", "/api-docs", cowboy_swagger_redirect_handler, #{}},
{"_", "/api/sse", lasse_handler, [mongoose_client_api_sse]},
{"_", "/api/contacts/[:jid]", mongoose_client_api_contacts, []},
{"_", "/api/messages/[:with]", mongoose_client_api_messages, []},
{"_", "/api/rooms/[:id]", mongoose_client_api_rooms, []},
{"_", "/api/rooms/[:id]/config",
mongoose_client_api_rooms_config, []},
{"_", "/api/rooms/[:id]/messages",
mongoose_client_api_rooms_messages, []},
{"_", "/api/rooms/:id/users/[:user]",
mongoose_client_api_rooms_users, []}],
port => 8089, proto => tcp,
protocol_options => [{compress, true}],
ssl =>
[{certfile, "priv/cert.pem"},
{keyfile, "priv/dc1.pem"},
{password, []}],
transport_options => [{max_connections, 1024}, {num_acceptors, 10}]},
#{ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
ip_version => 4, module => ejabberd_cowboy,
modules =>
[{"localhost", "/api", mongoose_api,
[{handlers, [mongoose_api_metrics, mongoose_api_users]}]}],
port => 5288, proto => tcp,
transport_options => [{max_connections, 1024}, {num_acceptors, 10}]},
#{ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4, max_stanza_size => 131072,
module => ejabberd_s2s_in, port => 5269, proto => tcp,
shaper => s2s_shaper,
tls => [{dhfile, "priv/dh.pem"}]},
#{access => all, ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
ip_version => 4, module => ejabberd_service, password => "secret",
port => 8888, proto => tcp, shaper_rule => fast},
#{access => all, conflict_behaviour => kick_old,
ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
ip_version => 4, module => ejabberd_service, password => "secret",
port => 8666, proto => tcp, shaper_rule => fast},
#{access => all, hidden_components => true, ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
ip_version => 4, module => ejabberd_service, password => "secret",
port => 8189, proto => tcp, shaper_rule => fast}]},
[config([listen, c2s],
#{port => 5222,
access => c2s,
shaper => c2s_shaper,
max_stanza_size => 65536,
zlib => 10000,
tls => [{certfile, "priv/dc1.pem"}, {dhfile, "priv/dh.pem"}, starttls]
}),
config([listen, c2s],
#{port => 5223,
access => c2s,
shaper => c2s_shaper,
max_stanza_size => 65536,
zlib => 4096
}),
config([listen, http],
#{port => 5280,
handlers => [{"_", "/http-bind", mod_bosh, []},
{"_", "/ws-xmpp", mod_websockets,
[{service, maps:merge(extra_service_listener_config(),
#{password => "secret", shaper_rule => fast})}]
}],
transport => #{num_acceptors => 10, max_connections => 1024}
}),
config([listen, http],
#{port => 5285,
handlers => [{"_", "/http-bind", mod_bosh, []},
{"_", "/ws-xmpp", mod_websockets,
[{max_stanza_size, 100},
{ping_rate, 120000},
{timeout, infinity}]},
{"localhost", "/api", mongoose_api_admin,
[{auth, {<<"ala">>, <<"makotaipsa">>}}]},
{"localhost", "/api/contacts/{:jid}", mongoose_api_client, []}],
transport => #{num_acceptors => 10, max_connections => 1024},
tls => [{certfile, "priv/cert.pem"}, {keyfile, "priv/dc1.pem"}, {password, []}]
}),
config([listen, http],
#{ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
port => 8088,
transport => #{num_acceptors => 10, max_connections => 1024},
handlers => [{"localhost", "/api", mongoose_api_admin, []}]
}),
config([listen, http],
#{port => 8089,
handlers => [{"_", "/api-docs/[...]", cowboy_static,
{priv_dir, cowboy_swagger, "swagger",
[{mimetypes, cow_mimetypes, all}]}},
{"_", "/api-docs/swagger.json", cowboy_swagger_json_handler, #{}},
{"_", "/api-docs", cowboy_swagger_redirect_handler, #{}},
{"_", "/api/sse", lasse_handler, [mongoose_client_api_sse]},
{"_", "/api/contacts/[:jid]", mongoose_client_api_contacts, []},
{"_", "/api/messages/[:with]", mongoose_client_api_messages, []},
{"_", "/api/rooms/[:id]", mongoose_client_api_rooms, []},
{"_", "/api/rooms/[:id]/config",
mongoose_client_api_rooms_config, []},
{"_", "/api/rooms/[:id]/messages",
mongoose_client_api_rooms_messages, []},
{"_", "/api/rooms/:id/users/[:user]",
mongoose_client_api_rooms_users, []}],
protocol => #{compress => true},
transport => #{num_acceptors => 10, max_connections => 1024},
tls => [{certfile, "priv/cert.pem"}, {keyfile, "priv/dc1.pem"}, {password, []}]
}),
config([listen, http],
#{ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
port => 5288,
transport => #{num_acceptors => 10, max_connections => 1024},
handlers =>
[{"localhost", "/api", mongoose_api,
[{handlers, [mongoose_api_metrics, mongoose_api_users]}]}]
}),
config([listen, s2s],
#{port => 5269,
shaper => s2s_shaper,
max_stanza_size => 131072,
tls => [{dhfile, "priv/dh.pem"}]
}),
config([listen, service],
#{ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
port => 8888,
access => all,
shaper_rule => fast,
password => "secret"
}),
config([listen, service],
#{ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
port => 8666,
access => all,
shaper_rule => fast,
password => "secret",
conflict_behaviour => kick_old
}),
config([listen, service],
#{ip_address => "127.0.0.1",
ip_tuple => {127, 0, 0, 1},
port => 8189,
access => all,
shaper_rule => fast,
password => "secret",
hidden_components => true
})
]},
{loglevel, warning},
{max_fsm_queue, 1000},
{mongooseimctl_access_commands, []},
Expand Down Expand Up @@ -1045,6 +1053,46 @@ default_room_opts() ->
subject => <<>>,
subject_author => <<>>}.

common_xmpp_listener_config() ->
(common_listener_config())#{backlog => 100,
proxy_protocol => false,
hibernate_after => 0,
max_stanza_size => infinity,
num_acceptors => 100}.

common_listener_config() ->
#{ip_address => "0",
ip_tuple => {0, 0, 0, 0},
ip_version => 4,
proto => tcp}.

extra_service_listener_config() ->
#{access => all,
shaper_rule => none,
check_from => true,
hidden_components => false,
conflict_behaviour => disconnect}.

default_config([listen, http]) ->
(common_listener_config())#{module => ejabberd_cowboy,
transport => default_config([listen, http, transport]),
protocol => default_config([listen, http, protocol]),
handlers => []};
default_config([listen, http, transport]) ->
#{num_acceptors => 100,
max_connections => 1024};
default_config([listen, http, protocol]) ->
#{compress => false};
default_config([listen, c2s]) ->
(common_xmpp_listener_config())#{module => ejabberd_c2s,
access => all,
shaper => none};
default_config([listen, s2s]) ->
(common_xmpp_listener_config())#{module => ejabberd_s2s_in,
shaper => none};
default_config([listen, service]) ->
Extra = maps:merge(common_xmpp_listener_config(), extra_service_listener_config()),
Extra#{module => ejabberd_service};
default_config([modules, M]) ->
default_mod_config(M);
default_config([modules, mod_event_pusher, http]) ->
Expand Down

0 comments on commit 661ed64

Please sign in to comment.