fix(mgmt): add subscribe options into the result of the client subscriptions API
This commit is contained in:
parent
6b84016259
commit
8d01e8a697
|
@ -564,12 +564,14 @@ subscriptions(get, #{bindings := #{clientid := ClientID}}) ->
|
||||||
{Node, Subs} ->
|
{Node, Subs} ->
|
||||||
Formatter =
|
Formatter =
|
||||||
fun({Topic, SubOpts}) ->
|
fun({Topic, SubOpts}) ->
|
||||||
|
maps:merge(
|
||||||
#{
|
#{
|
||||||
node => Node,
|
node => Node,
|
||||||
clientid => ClientID,
|
clientid => ClientID,
|
||||||
topic => Topic,
|
topic => Topic
|
||||||
qos => maps:get(qos, SubOpts)
|
},
|
||||||
}
|
maps:with([qos, nl, rap, rh], SubOpts)
|
||||||
|
)
|
||||||
end,
|
end,
|
||||||
{200, lists:map(Formatter, Subs)}
|
{200, lists:map(Formatter, Subs)}
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -105,6 +105,32 @@ t_clients(_) ->
|
||||||
?assertEqual(AfterSubTopic, Topic),
|
?assertEqual(AfterSubTopic, Topic),
|
||||||
?assertEqual(AfterSubQos, Qos),
|
?assertEqual(AfterSubQos, Qos),
|
||||||
|
|
||||||
|
%% get /clients/:clientid/subscriptions
|
||||||
|
SubscriptionsPath = emqx_mgmt_api_test_util:api_path([
|
||||||
|
"clients",
|
||||||
|
binary_to_list(ClientId1),
|
||||||
|
"subscriptions"
|
||||||
|
]),
|
||||||
|
{ok, SubscriptionsRes} = emqx_mgmt_api_test_util:request_api(
|
||||||
|
get,
|
||||||
|
SubscriptionsPath,
|
||||||
|
"",
|
||||||
|
AuthHeader
|
||||||
|
),
|
||||||
|
[SubscriptionsData] = emqx_json:decode(SubscriptionsRes, [return_maps]),
|
||||||
|
?assertMatch(
|
||||||
|
#{
|
||||||
|
<<"clientid">> := ClientId1,
|
||||||
|
<<"nl">> := _,
|
||||||
|
<<"rap">> := _,
|
||||||
|
<<"rh">> := _,
|
||||||
|
<<"node">> := _,
|
||||||
|
<<"qos">> := Qos,
|
||||||
|
<<"topic">> := Topic
|
||||||
|
},
|
||||||
|
SubscriptionsData
|
||||||
|
),
|
||||||
|
|
||||||
%% post /clients/:clientid/unsubscribe
|
%% post /clients/:clientid/unsubscribe
|
||||||
UnSubscribePath = emqx_mgmt_api_test_util:api_path([
|
UnSubscribePath = emqx_mgmt_api_test_util:api_path([
|
||||||
"clients",
|
"clients",
|
||||||
|
|
Loading…
Reference in New Issue