fix(gateway): fix test case error
This commit is contained in:
parent
527ea23ec8
commit
81a86e3202
|
@ -255,37 +255,37 @@ t_clients_api(_) ->
|
|||
Fun = fun(_Channel, _Token) ->
|
||||
ClientId = <<"client1">>,
|
||||
%% list
|
||||
{200, #{data := [Client1]}} = request(get, "/gateway/coap/clients"),
|
||||
{200, #{data := [Client1]}} = request(get, "/gateways/coap/clients"),
|
||||
#{clientid := ClientId} = Client1,
|
||||
%% searching
|
||||
{200, #{data := [Client2]}} =
|
||||
request(
|
||||
get,
|
||||
"/gateway/coap/clients",
|
||||
"/gateways/coap/clients",
|
||||
[{<<"clientid">>, ClientId}]
|
||||
),
|
||||
{200, #{data := [Client3]}} =
|
||||
request(
|
||||
get,
|
||||
"/gateway/coap/clients",
|
||||
"/gateways/coap/clients",
|
||||
[{<<"like_clientid">>, <<"cli">>}]
|
||||
),
|
||||
%% lookup
|
||||
{200, Client4} =
|
||||
request(get, "/gateway/coap/clients/client1"),
|
||||
request(get, "/gateways/coap/clients/client1"),
|
||||
%% assert
|
||||
Client1 = Client2 = Client3 = Client4,
|
||||
%% kickout
|
||||
{204, _} =
|
||||
request(delete, "/gateway/coap/clients/client1"),
|
||||
request(delete, "/gateways/coap/clients/client1"),
|
||||
timer:sleep(200),
|
||||
{200, #{data := []}} = request(get, "/gateway/coap/clients")
|
||||
{200, #{data := []}} = request(get, "/gateways/coap/clients")
|
||||
end,
|
||||
with_connection(Fun).
|
||||
|
||||
t_clients_subscription_api(_) ->
|
||||
Fun = fun(_Channel, _Token) ->
|
||||
Path = "/gateway/coap/clients/client1/subscriptions",
|
||||
Path = "/gateways/coap/clients/client1/subscriptions",
|
||||
%% list
|
||||
{200, []} = request(get, Path),
|
||||
%% create
|
||||
|
@ -312,7 +312,7 @@ t_clients_subscription_api(_) ->
|
|||
|
||||
t_clients_get_subscription_api(_) ->
|
||||
Fun = fun(Channel, Token) ->
|
||||
Path = "/gateway/coap/clients/client1/subscriptions",
|
||||
Path = "/gateways/coap/clients/client1/subscriptions",
|
||||
%% list
|
||||
{200, []} = request(get, Path),
|
||||
|
||||
|
@ -333,14 +333,14 @@ t_on_offline_event(_) ->
|
|||
emqx_hooks:add('client.connected', {emqx_sys, on_client_connected, []}, 1000),
|
||||
emqx_hooks:add('client.disconnected', {emqx_sys, on_client_disconnected, []}, 1000),
|
||||
|
||||
ConnectedSub = <<"$SYS/brokers/+/gateway/coap/clients/+/connected">>,
|
||||
ConnectedSub = <<"$SYS/brokers/+/gateways/coap/clients/+/connected">>,
|
||||
emqx_broker:subscribe(ConnectedSub),
|
||||
timer:sleep(100),
|
||||
|
||||
Token = connection(Channel),
|
||||
?assertMatch(#message{}, receive_deliver(500)),
|
||||
|
||||
DisconnectedSub = <<"$SYS/brokers/+/gateway/coap/clients/+/disconnected">>,
|
||||
DisconnectedSub = <<"$SYS/brokers/+/gateways/coap/clients/+/disconnected">>,
|
||||
emqx_broker:subscribe(DisconnectedSub),
|
||||
timer:sleep(100),
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ on_start_auth(authn_http) ->
|
|||
|
||||
%% set authn for gateway
|
||||
Setup = fun(Gateway) ->
|
||||
Path = io_lib:format("/gateway/~ts/authentication", [Gateway]),
|
||||
Path = io_lib:format("/gateways/~ts/authentication", [Gateway]),
|
||||
{204, _} = request(delete, Path),
|
||||
timer:sleep(200),
|
||||
{201, _} = request(post, Path, http_authn_config()),
|
||||
|
@ -198,7 +198,7 @@ on_start_auth(authz_http) ->
|
|||
|
||||
on_stop_auth(authn_http) ->
|
||||
Delete = fun(Gateway) ->
|
||||
Path = io_lib:format("/gateway/~ts/authentication", [Gateway]),
|
||||
Path = io_lib:format("/gateways/~ts/authentication", [Gateway]),
|
||||
{204, _} = request(delete, Path)
|
||||
end,
|
||||
lists:foreach(Delete, ?GATEWAYS),
|
||||
|
|
|
@ -2353,18 +2353,18 @@ case100_clients_api(Config) ->
|
|||
std_register(UdpSock, Epn, ObjectList, MsgId1, RespTopic),
|
||||
|
||||
%% list
|
||||
{200, #{data := [Client1]}} = request(get, "/gateway/lwm2m/clients"),
|
||||
{200, #{data := [Client1]}} = request(get, "/gateways/lwm2m/clients"),
|
||||
%% searching
|
||||
{200, #{data := [Client2]}} =
|
||||
request(
|
||||
get,
|
||||
"/gateway/lwm2m/clients",
|
||||
"/gateways/lwm2m/clients",
|
||||
[{<<"endpoint_name">>, list_to_binary(Epn)}]
|
||||
),
|
||||
{200, #{data := [Client3]}} =
|
||||
request(
|
||||
get,
|
||||
"/gateway/lwm2m/clients",
|
||||
"/gateways/lwm2m/clients",
|
||||
[
|
||||
{<<"like_endpoint_name">>, list_to_binary(Epn)},
|
||||
{<<"gte_lifetime">>, <<"1">>}
|
||||
|
@ -2373,14 +2373,14 @@ case100_clients_api(Config) ->
|
|||
%% lookup
|
||||
ClientId = maps:get(clientid, Client1),
|
||||
{200, Client4} =
|
||||
request(get, "/gateway/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
||||
request(get, "/gateways/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
||||
%% assert
|
||||
Client1 = Client2 = Client3 = Client4,
|
||||
%% kickout
|
||||
{204, _} =
|
||||
request(delete, "/gateway/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
||||
request(delete, "/gateways/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
||||
timer:sleep(100),
|
||||
{200, #{data := []}} = request(get, "/gateway/lwm2m/clients").
|
||||
{200, #{data := []}} = request(get, "/gateways/lwm2m/clients").
|
||||
|
||||
case100_subscription_api(Config) ->
|
||||
Epn = "urn:oma:lwm2m:oma:3",
|
||||
|
@ -2390,10 +2390,10 @@ case100_subscription_api(Config) ->
|
|||
RespTopic = list_to_binary("lwm2m/" ++ Epn ++ "/up/resp"),
|
||||
std_register(UdpSock, Epn, ObjectList, MsgId1, RespTopic),
|
||||
|
||||
{200, #{data := [Client1]}} = request(get, "/gateway/lwm2m/clients"),
|
||||
{200, #{data := [Client1]}} = request(get, "/gateways/lwm2m/clients"),
|
||||
ClientId = maps:get(clientid, Client1),
|
||||
Path =
|
||||
"/gateway/lwm2m/clients/" ++
|
||||
"/gateways/lwm2m/clients/" ++
|
||||
binary_to_list(ClientId) ++
|
||||
"/subscriptions",
|
||||
|
||||
|
|
|
@ -2198,15 +2198,15 @@ t_clients_api(_) ->
|
|||
send_connect_msg(Socket, ClientId),
|
||||
?assertEqual(<<3, ?SN_CONNACK, 0>>, receive_response(Socket)),
|
||||
%% list
|
||||
{200, #{data := [Client1]}} = request(get, "/gateway/mqttsn/clients"),
|
||||
{200, #{data := [Client1]}} = request(get, "/gateways/mqttsn/clients"),
|
||||
#{clientid := ClientId} = Client1,
|
||||
%% searching
|
||||
{200, #{data := [Client2]}} =
|
||||
request(get, "/gateway/mqttsn/clients", [{<<"clientid">>, ClientId}]),
|
||||
request(get, "/gateways/mqttsn/clients", [{<<"clientid">>, ClientId}]),
|
||||
{200, #{data := [Client3]}} =
|
||||
request(
|
||||
get,
|
||||
"/gateway/mqttsn/clients",
|
||||
"/gateways/mqttsn/clients",
|
||||
[
|
||||
{<<"like_clientid">>, <<"test1">>},
|
||||
{<<"proto_ver">>, <<"1.2">>},
|
||||
|
@ -2218,21 +2218,21 @@ t_clients_api(_) ->
|
|||
),
|
||||
%% lookup
|
||||
{200, Client4} =
|
||||
request(get, "/gateway/mqttsn/clients/client_id_test1"),
|
||||
request(get, "/gateways/mqttsn/clients/client_id_test1"),
|
||||
%% assert
|
||||
Client1 = Client2 = Client3 = Client4,
|
||||
%% kickout
|
||||
{204, _} =
|
||||
request(delete, "/gateway/mqttsn/clients/client_id_test1"),
|
||||
request(delete, "/gateways/mqttsn/clients/client_id_test1"),
|
||||
timer:sleep(100),
|
||||
{200, #{data := []}} = request(get, "/gateway/mqttsn/clients"),
|
||||
{200, #{data := []}} = request(get, "/gateways/mqttsn/clients"),
|
||||
|
||||
send_disconnect_msg(Socket, undefined),
|
||||
gen_udp:close(Socket).
|
||||
|
||||
t_clients_subscription_api(_) ->
|
||||
ClientId = <<"client_id_test1">>,
|
||||
Path = "/gateway/mqttsn/clients/client_id_test1/subscriptions",
|
||||
Path = "/gateways/mqttsn/clients/client_id_test1/subscriptions",
|
||||
{ok, Socket} = gen_udp:open(0, [binary]),
|
||||
send_connect_msg(Socket, ClientId),
|
||||
?assertEqual(<<3, ?SN_CONNACK, 0>>, receive_response(Socket)),
|
||||
|
|
|
@ -721,12 +721,12 @@ t_rest_clienit_info(_) ->
|
|||
_, _} = parse(Data),
|
||||
|
||||
%% client lists
|
||||
{200, Clients} = request(get, "/gateway/stomp/clients"),
|
||||
{200, Clients} = request(get, "/gateways/stomp/clients"),
|
||||
?assertEqual(1, length(maps:get(data, Clients))),
|
||||
StompClient = lists:nth(1, maps:get(data, Clients)),
|
||||
ClientId = maps:get(clientid, StompClient),
|
||||
ClientPath =
|
||||
"/gateway/stomp/clients/" ++
|
||||
"/gateways/stomp/clients/" ++
|
||||
binary_to_list(ClientId),
|
||||
{200, StompClient1} = request(get, ClientPath),
|
||||
?assertEqual(StompClient, StompClient1),
|
||||
|
@ -811,7 +811,7 @@ t_rest_clienit_info(_) ->
|
|||
% sync
|
||||
ignored = gen_server:call(emqx_cm, ignore, infinity),
|
||||
ok = emqx_pool:flush_async_tasks(),
|
||||
{200, Clients2} = request(get, "/gateway/stomp/clients"),
|
||||
{200, Clients2} = request(get, "/gateways/stomp/clients"),
|
||||
?assertEqual(0, length(maps:get(data, Clients2)))
|
||||
end).
|
||||
|
||||
|
|
Loading…
Reference in New Issue