Skip to content

Commit

Permalink
Merge pull request #3886 from esl/hooks/auth_tokens_SUITE
Browse files Browse the repository at this point in the history
Refactored hook handlers in auth_tokend_SUITE
  • Loading branch information
NelsonVides authored Dec 1, 2022
2 parents b28a1cf + 8d04e95 commit c90358e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/auth_tokens_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,18 @@ mock_rdbms_backend() ->
ok.

mock_keystore() ->
ejabberd_hooks:add(get_key, host_type(), ?MODULE, mod_keystore_get_key, 50).
gen_hook:add_handler(get_key, host_type(), fun ?MODULE:mod_keystore_get_key/3, #{}, 50).

mock_gen_iq_handler() ->
meck:new(gen_iq_handler, []),
meck:expect(gen_iq_handler, add_iq_handler_for_domain, fun (_, _, _, _, _, _) -> ok end).

mod_keystore_get_key(_, {KeyName, _} = KeyID) ->
case KeyName of
mod_keystore_get_key(_, #{key_id := {KeyName, _} = KeyID}, _) ->
Acc = case KeyName of
token_secret -> [{KeyID, <<"access_or_refresh">>}];
provision_pre_shared -> [{KeyID, <<"provision">>}]
end.
end,
{ok, Acc}.

mock_tested_backend() ->
meck:new(mod_auth_token_backend, []),
Expand Down

0 comments on commit c90358e

Please sign in to comment.