fix(client_attrs): fix client_attrs extraction loop
This commit is contained in:
parent
a88862ebe0
commit
1974ec15ec
|
@ -1636,7 +1636,7 @@ maybe_set_client_initial_attrs(ConnPkt, #{zone := Zone} = ClientInfo) ->
|
|||
initialize_client_attrs(Inits, ClientInfo) ->
|
||||
lists:foldl(
|
||||
fun(#{expression := Variform, set_as_attr := Name}, Acc) ->
|
||||
Attrs = maps:get(client_attrs, ClientInfo, #{}),
|
||||
Attrs = maps:get(client_attrs, Acc, #{}),
|
||||
case emqx_variform:render(Variform, ClientInfo) of
|
||||
{ok, <<>>} ->
|
||||
?SLOG(
|
||||
|
|
|
@ -422,6 +422,10 @@ t_client_attr_from_user_property(_Config) ->
|
|||
#{
|
||||
expression => Compiled,
|
||||
set_as_attr => <<"group">>
|
||||
},
|
||||
#{
|
||||
expression => Compiled,
|
||||
set_as_attr => <<"group2">>
|
||||
}
|
||||
]),
|
||||
SslConf = emqx_common_test_helpers:client_mtls('tlsv1.3'),
|
||||
|
@ -436,7 +440,7 @@ t_client_attr_from_user_property(_Config) ->
|
|||
{ok, _} = emqtt:connect(Client),
|
||||
%% assert only two chars are extracted
|
||||
?assertMatch(
|
||||
#{clientinfo := #{client_attrs := #{<<"group">> := <<"g1">>}}},
|
||||
#{clientinfo := #{client_attrs := #{<<"group">> := <<"g1">>, <<"group2">> := <<"g1">>}}},
|
||||
emqx_cm:get_chan_info(ClientId)
|
||||
),
|
||||
emqtt:disconnect(Client).
|
||||
|
|
|
@ -275,7 +275,7 @@ to_range_badarg_test_() ->
|
|||
].
|
||||
|
||||
iif_test_() ->
|
||||
%% if clientid has to words separated by a -, take the suffix, and append with `/#`
|
||||
%% if clientid has two words separated by a -, take the suffix, and append with `/#`
|
||||
Expr1 = "iif(nth(2,tokens(clientid,'-')),concat([nth(2,tokens(clientid,'-')),'/#']),'')",
|
||||
[
|
||||
?_assertEqual({ok, <<"yes-A">>}, render("iif(a,'yes-A','no-A')", #{a => <<"x">>})),
|
||||
|
|
Loading…
Reference in New Issue