|
|
@@ -586,6 +586,47 @@ t_listeners_authn_data_mgmt(_) ->
|
|
|
|
|
|
ok.
|
|
|
|
|
|
+t_clients(_) ->
|
|
|
+ GwConf = #{
|
|
|
+ name => <<"mqttsn">>,
|
|
|
+ gateway_id => 1,
|
|
|
+ broadcast => true,
|
|
|
+ predefined => [#{id => 1, topic => <<"t/a">>}],
|
|
|
+ enable_qos3 => true,
|
|
|
+ listeners => [
|
|
|
+ #{name => <<"def">>, type => <<"udp">>, bind => <<"1884">>}
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ init_gw("mqttsn", GwConf),
|
|
|
+ Path = "/gateways/mqttsn/clients",
|
|
|
+ MyClient = Path ++ "/my_client",
|
|
|
+ MyClientSubscriptions = MyClient ++ "/subscriptions",
|
|
|
+ {200, NoClients} = request(get, Path),
|
|
|
+ ?assertMatch(#{data := []}, NoClients),
|
|
|
+
|
|
|
+ ClientSocket = emqx_gateway_test_utils:sn_client_connect(<<"my_client">>),
|
|
|
+ {200, _} = request(get, MyClient),
|
|
|
+ {200, Clients} = request(get, Path),
|
|
|
+ ?assertMatch(#{data := [#{clientid := <<"my_client">>}]}, Clients),
|
|
|
+
|
|
|
+ {201, _} = request(post, MyClientSubscriptions, #{topic => <<"test/topic">>}),
|
|
|
+ {200, Subscriptions} = request(get, MyClientSubscriptions),
|
|
|
+ ?assertMatch([#{topic := <<"test/topic">>}], Subscriptions),
|
|
|
+ {204, _} = request(delete, MyClientSubscriptions ++ "/test%2Ftopic"),
|
|
|
+ {200, []} = request(get, MyClientSubscriptions),
|
|
|
+ {404, _} = request(delete, MyClientSubscriptions ++ "/test%2Ftopic"),
|
|
|
+
|
|
|
+ {204, _} = request(delete, MyClient),
|
|
|
+ {404, _} = request(delete, MyClient),
|
|
|
+ {404, _} = request(get, MyClient),
|
|
|
+ {404, _} = request(get, MyClientSubscriptions),
|
|
|
+ {404, _} = request(post, MyClientSubscriptions, #{topic => <<"foo">>}),
|
|
|
+ {404, _} = request(delete, MyClientSubscriptions ++ "/topic"),
|
|
|
+ {200, NoClients2} = request(get, Path),
|
|
|
+ ?assertMatch(#{data := []}, NoClients2),
|
|
|
+ emqx_gateway_test_utils:sn_client_disconnect(ClientSocket),
|
|
|
+ ok.
|
|
|
+
|
|
|
t_authn_fuzzy_search(_) ->
|
|
|
init_gw("stomp"),
|
|
|
AuthConf = #{
|