test(authn): fix test case

This commit is contained in:
zhouzb 2021-08-19 14:40:36 +08:00
parent d409cb83ff
commit 87051c0e53
4 changed files with 4 additions and 4 deletions

View File

@ -33,7 +33,7 @@ end_per_suite(_Config) ->
emqx_ct_helpers:stop_apps([]).
t_authenticate(_) ->
?assertMatch(ok, emqx_access_control:authenticate(clientinfo())).
?assertMatch({ok, _}, emqx_access_control:authenticate(clientinfo())).
t_authorize(_) ->
Publish = ?PUBLISH_PACKET(?QOS_0, <<"t">>, 1, <<"payload">>),

View File

@ -181,7 +181,7 @@ init_per_suite(Config) ->
%% Access Control Meck
ok = meck:new(emqx_access_control, [passthrough, no_history, no_link]),
ok = meck:expect(emqx_access_control, authenticate,
fun(_) -> ok end),
fun(_) -> {ok, #{superuser => false}} end),
ok = meck:expect(emqx_access_control, authorize, fun(_, _, _) -> allow end),
%% Broker Meck
ok = meck:new(emqx_broker, [passthrough, no_history, no_link]),

View File

@ -73,7 +73,7 @@ authenticate(_Ctx = #{auth := ChainId}, ClientInfo0) ->
chain_id => ChainId
},
case emqx_access_control:authenticate(ClientInfo) of
ok ->
{ok, _} ->
{ok, mountpoint(ClientInfo)};
{error, Reason} ->
{error, Reason}

View File

@ -87,7 +87,7 @@ init(CoapPid, EndpointName, Peername = {_Peerhost, _Port}, RegInfo = #{<<"lt">>
ClientInfo = clientinfo(Lwm2mState),
_ = run_hooks('client.connect', [conninfo(Lwm2mState)], undefined),
case emqx_access_control:authenticate(ClientInfo) of
ok ->
{ok, _} ->
_ = run_hooks('client.connack', [conninfo(Lwm2mState), success], undefined),
%% FIXME: