Skip to content

Commit

Permalink
Handle default opts for MUC in config_parser_SUITE
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Mar 8, 2022
1 parent 2aabeb1 commit f884434
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions test/common/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ all_modules() ->
#{host => <<"192.168.0.1">>, type => turn}]},
mod_csi => [{buffer_max, 40}],
mod_muc_log =>
(mod_muc_log:default_opts())
#{access_log => muc,
css_file => <<"path/to/css/file">>,
outdir => "www/muc",
Expand Down Expand Up @@ -626,9 +627,11 @@ all_modules() ->
#{backend => mnesia, inactivity => 20, max_wait => infinity,
server_acks => true, max_pause => 120},
mod_muc =>
(mod_muc:default_opts())
#{access => muc,
access_create => muc_create,
default_room =>
(mod_muc:default_room_opts())
#{affiliations =>
[{{<<"alice">>, <<"localhost">>, <<"resource1">>}, member},
{{<<"bob">>, <<"localhost">>, <<"resource2">>}, owner}],
Expand Down
17 changes: 12 additions & 5 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2266,8 +2266,9 @@ test_async_writer(ParentT, ParentP) ->
?errh(T(#{<<"enabled">> => <<"wrong">>})).

mod_muc(_Config) ->
DefOpts = mod_muc:default_opts(),
T = fun(Opts) -> #{<<"modules">> => #{<<"mod_muc">> => Opts}} end,
M = fun(Cfg) -> modopts(mod_muc, Cfg) end,
M = fun(Cfg) -> modopts(mod_muc, maps:merge(DefOpts, Cfg)) end,
?cfgh(M(#{host => {prefix, <<"conference.">>}}),
T(#{<<"host">> => <<"conference.@HOST@">>})),
?cfgh(M(#{host => {fqdn, <<"conference.test">>}}),
Expand Down Expand Up @@ -2344,9 +2345,11 @@ mod_muc(_Config) ->
?errh(T(#{<<"hibernated_room_timeout">> => false})).

mod_muc_default_room(_Config) ->
DefOpts = mod_muc:default_opts(),
DefRoomOpts = mod_muc:default_room_opts(),
T = fun(Opts) -> #{<<"modules">> =>
#{<<"mod_muc">> => #{<<"default_room">> => Opts}}} end,
M = fun(Cfg) -> modopts(mod_muc, #{default_room => Cfg}) end,
M = fun(Cfg) -> modopts(mod_muc, DefOpts#{default_room => maps:merge(DefRoomOpts, Cfg)}) end,
?cfgh(M(#{}), T(#{})),
?cfgh(M(#{title => <<"living room">>}),
T(#{<<"title">> => <<"living room">>})),
Expand Down Expand Up @@ -2421,10 +2424,12 @@ mod_muc_default_room(_Config) ->
?errh(T(#{<<"subject_author">> => 1})).

mod_muc_default_room_affiliations(_Config) ->
DefOpts = mod_muc:default_opts(),
DefRoomOpts = mod_muc:default_room_opts(),
T = fun(Opts) -> #{<<"modules">> =>
#{<<"mod_muc">> =>
#{<<"default_room">> => #{<<"affiliations">> => Opts}}}} end,
M = fun(Cfg) -> modopts(mod_muc, #{default_room => #{affiliations => Cfg}}) end,
M = fun(Cfg) -> modopts(mod_muc, DefOpts#{default_room => maps:merge(DefRoomOpts, #{affiliations => Cfg})}) end,
RequiredOpts = #{<<"user">> => <<"alice">>,
<<"server">> => <<"localhost">>,
<<"resource">> => <<"phone">>,
Expand All @@ -2439,8 +2444,9 @@ mod_muc_default_room_affiliations(_Config) ->
?errh(T([RequiredOpts#{<<"affiliation">> := <<>>}])).

mod_muc_log(_Config) ->
DefOpts = mod_muc_log:default_opts(),
T = fun(Opts) -> #{<<"modules">> => #{<<"mod_muc_log">> => Opts}} end,
M = fun(Cfg) -> modopts(mod_muc_log, Cfg) end,
M = fun(Cfg) -> modopts(mod_muc_log, maps:merge(DefOpts, Cfg)) end,
?cfgh(M(#{outdir => "www/muc"}),
T(#{<<"outdir">> => <<"www/muc">>})),
?cfgh(M(#{access_log => muc_admin}),
Expand All @@ -2467,8 +2473,9 @@ mod_muc_log(_Config) ->
?errh(T(#{<<"spam_prevention">> => <<"spam and eggs and spam">>})).

mod_muc_log_top_link(_Config) ->
DefOpts = mod_muc_log:default_opts(),
T = fun(Opts) -> #{<<"modules">> => #{<<"mod_muc_log">> => #{<<"top_link">> => Opts}}} end,
M = fun(Cfg) -> modopts(mod_muc_log, #{top_link => Cfg}) end,
M = fun(Cfg) -> modopts(mod_muc_log, DefOpts#{top_link => Cfg}) end,
RequiredOpts = #{<<"target">> => <<"https://esl.github.io/MongooseDocs/">>,
<<"text">> => <<"Docs">>},
ExpectedCfg = {"https://esl.github.io/MongooseDocs/", "Docs"},
Expand Down

0 comments on commit f884434

Please sign in to comment.