Merge pull request #8823 from lafirest/fix/gateway_apis
fix(gateway): change the `/gateway` API path to plural form
This commit is contained in:
commit
7041378c80
|
@ -1,3 +1,9 @@
|
||||||
|
# 5.0.8
|
||||||
|
|
||||||
|
## Enhancements
|
||||||
|
|
||||||
|
* change the `/gateway` API path to plural form. [#8823](https://github.com/emqx/emqx/pull/8823)
|
||||||
|
|
||||||
# 5.0.7
|
# 5.0.7
|
||||||
|
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
-export([request/2]).
|
-export([request/2]).
|
||||||
|
|
||||||
-define(PREFIX, "/gateway/coap/clients/:clientid").
|
-define(PREFIX, "/gateways/coap/clients/:clientid").
|
||||||
|
|
||||||
-import(hoconsc, [mk/2, enum/1]).
|
-import(hoconsc, [mk/2, enum/1]).
|
||||||
-import(emqx_dashboard_swagger, [error_codes/2]).
|
-import(emqx_dashboard_swagger, [error_codes/2]).
|
||||||
|
@ -42,7 +42,7 @@ api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
[?PREFIX ++ "/request"].
|
emqx_gateway_utils:make_deprecated_paths([?PREFIX ++ "/request"]).
|
||||||
|
|
||||||
schema(?PREFIX ++ "/request") ->
|
schema(?PREFIX ++ "/request") ->
|
||||||
#{
|
#{
|
||||||
|
@ -60,7 +60,9 @@ schema(?PREFIX ++ "/request") ->
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.
|
};
|
||||||
|
schema(Path) ->
|
||||||
|
emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
|
||||||
|
|
||||||
request(post, #{body := Body, bindings := Bindings}) ->
|
request(post, #{body := Body, bindings := Bindings}) ->
|
||||||
ClientId = maps:get(clientid, Bindings, undefined),
|
ClientId = maps:get(clientid, Bindings, undefined),
|
||||||
|
|
|
@ -61,10 +61,10 @@ api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
[
|
emqx_gateway_utils:make_deprecated_paths([
|
||||||
"/gateway",
|
"/gateways",
|
||||||
"/gateway/:name"
|
"/gateways/:name"
|
||||||
].
|
]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% http handlers
|
%% http handlers
|
||||||
|
@ -159,7 +159,7 @@ gateway_insta(put, #{
|
||||||
%% Swagger defines
|
%% Swagger defines
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
schema("/gateway") ->
|
schema("/gateways") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => gateway,
|
'operationId' => gateway,
|
||||||
get =>
|
get =>
|
||||||
|
@ -185,7 +185,7 @@ schema("/gateway") ->
|
||||||
?STANDARD_RESP(#{201 => schema_gateways_conf()})
|
?STANDARD_RESP(#{201 => schema_gateways_conf()})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name") ->
|
schema("/gateways/:name") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => gateway_insta,
|
'operationId' => gateway_insta,
|
||||||
get =>
|
get =>
|
||||||
|
@ -210,7 +210,9 @@ schema("/gateway/:name") ->
|
||||||
responses =>
|
responses =>
|
||||||
?STANDARD_RESP(#{200 => schema_gateways_conf()})
|
?STANDARD_RESP(#{200 => schema_gateways_conf()})
|
||||||
}
|
}
|
||||||
}.
|
};
|
||||||
|
schema(Path) ->
|
||||||
|
emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% params defines
|
%% params defines
|
||||||
|
|
|
@ -60,11 +60,11 @@ api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
[
|
emqx_gateway_utils:make_deprecated_paths([
|
||||||
"/gateway/:name/authentication",
|
"/gateways/:name/authentication",
|
||||||
"/gateway/:name/authentication/users",
|
"/gateways/:name/authentication/users",
|
||||||
"/gateway/:name/authentication/users/:uid"
|
"/gateways/:name/authentication/users/:uid"
|
||||||
].
|
]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% http handlers
|
%% http handlers
|
||||||
|
@ -176,7 +176,7 @@ parse_qstring(Qs) ->
|
||||||
%% Swagger defines
|
%% Swagger defines
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
schema("/gateway/:name/authentication") ->
|
schema("/gateways/:name/authentication") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => authn,
|
'operationId' => authn,
|
||||||
get =>
|
get =>
|
||||||
|
@ -215,7 +215,7 @@ schema("/gateway/:name/authentication") ->
|
||||||
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/authentication/users") ->
|
schema("/gateways/:name/authentication/users") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => users,
|
'operationId' => users,
|
||||||
get =>
|
get =>
|
||||||
|
@ -253,7 +253,7 @@ schema("/gateway/:name/authentication/users") ->
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/authentication/users/:uid") ->
|
schema("/gateways/:name/authentication/users/:uid") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => users_insta,
|
'operationId' => users_insta,
|
||||||
get =>
|
get =>
|
||||||
|
@ -298,8 +298,9 @@ schema("/gateway/:name/authentication/users/:uid") ->
|
||||||
responses =>
|
responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"User Deleted">>})
|
?STANDARD_RESP(#{204 => <<"User Deleted">>})
|
||||||
}
|
}
|
||||||
}.
|
};
|
||||||
|
schema(Path) ->
|
||||||
|
emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% params defines
|
%% params defines
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,10 @@ api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => false}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => false}).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
[
|
emqx_gateway_utils:make_deprecated_paths([
|
||||||
"/gateway/:name/authentication/import_users",
|
"/gateways/:name/authentication/import_users",
|
||||||
"/gateway/:name/listeners/:id/authentication/import_users"
|
"/gateways/:name/listeners/:id/authentication/import_users"
|
||||||
].
|
]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% http handlers
|
%% http handlers
|
||||||
|
@ -117,7 +117,7 @@ import_listener_users(post, #{
|
||||||
%% Swagger defines
|
%% Swagger defines
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
schema("/gateway/:name/authentication/import_users") ->
|
schema("/gateways/:name/authentication/import_users") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => import_users,
|
'operationId' => import_users,
|
||||||
post =>
|
post =>
|
||||||
|
@ -129,7 +129,7 @@ schema("/gateway/:name/authentication/import_users") ->
|
||||||
?STANDARD_RESP(#{204 => <<"Imported">>})
|
?STANDARD_RESP(#{204 => <<"Imported">>})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/listeners/:id/authentication/import_users") ->
|
schema("/gateways/:name/listeners/:id/authentication/import_users") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => import_listener_users,
|
'operationId' => import_listener_users,
|
||||||
post =>
|
post =>
|
||||||
|
@ -141,8 +141,9 @@ schema("/gateway/:name/listeners/:id/authentication/import_users") ->
|
||||||
responses =>
|
responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Imported">>})
|
?STANDARD_RESP(#{204 => <<"Imported">>})
|
||||||
}
|
}
|
||||||
}.
|
};
|
||||||
|
schema(Path) ->
|
||||||
|
emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% params defines
|
%% params defines
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -67,12 +67,12 @@ api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
[
|
emqx_gateway_utils:make_deprecated_paths([
|
||||||
"/gateway/:name/clients",
|
"/gateways/:name/clients",
|
||||||
"/gateway/:name/clients/:clientid",
|
"/gateways/:name/clients/:clientid",
|
||||||
"/gateway/:name/clients/:clientid/subscriptions",
|
"/gateways/:name/clients/:clientid/subscriptions",
|
||||||
"/gateway/:name/clients/:clientid/subscriptions/:topic"
|
"/gateways/:name/clients/:clientid/subscriptions/:topic"
|
||||||
].
|
]).
|
||||||
|
|
||||||
-define(CLIENT_QSCHEMA, [
|
-define(CLIENT_QSCHEMA, [
|
||||||
{<<"node">>, atom},
|
{<<"node">>, atom},
|
||||||
|
@ -462,7 +462,7 @@ conn_state_to_connected(_) -> false.
|
||||||
%% Swagger defines
|
%% Swagger defines
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
schema("/gateway/:name/clients") ->
|
schema("/gateways/:name/clients") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => clients,
|
'operationId' => clients,
|
||||||
get =>
|
get =>
|
||||||
|
@ -473,7 +473,7 @@ schema("/gateway/:name/clients") ->
|
||||||
?STANDARD_RESP(#{200 => schema_client_list()})
|
?STANDARD_RESP(#{200 => schema_client_list()})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/clients/:clientid") ->
|
schema("/gateways/:name/clients/:clientid") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => clients_insta,
|
'operationId' => clients_insta,
|
||||||
get =>
|
get =>
|
||||||
|
@ -491,7 +491,7 @@ schema("/gateway/:name/clients/:clientid") ->
|
||||||
?STANDARD_RESP(#{204 => <<"Kicked">>})
|
?STANDARD_RESP(#{204 => <<"Kicked">>})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/clients/:clientid/subscriptions") ->
|
schema("/gateways/:name/clients/:clientid/subscriptions") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => subscriptions,
|
'operationId' => subscriptions,
|
||||||
get =>
|
get =>
|
||||||
|
@ -527,7 +527,7 @@ schema("/gateway/:name/clients/:clientid/subscriptions") ->
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/clients/:clientid/subscriptions/:topic") ->
|
schema("/gateways/:name/clients/:clientid/subscriptions/:topic") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => subscriptions,
|
'operationId' => subscriptions,
|
||||||
delete =>
|
delete =>
|
||||||
|
@ -537,7 +537,9 @@ schema("/gateway/:name/clients/:clientid/subscriptions/:topic") ->
|
||||||
responses =>
|
responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Unsubscribed">>})
|
?STANDARD_RESP(#{204 => <<"Unsubscribed">>})
|
||||||
}
|
}
|
||||||
}.
|
};
|
||||||
|
schema(Path) ->
|
||||||
|
emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
|
||||||
|
|
||||||
params_client_query() ->
|
params_client_query() ->
|
||||||
params_gateway_name_in_path() ++
|
params_gateway_name_in_path() ++
|
||||||
|
|
|
@ -68,13 +68,13 @@ api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
[
|
emqx_gateway_utils:make_deprecated_paths([
|
||||||
"/gateway/:name/listeners",
|
"/gateways/:name/listeners",
|
||||||
"/gateway/:name/listeners/:id",
|
"/gateways/:name/listeners/:id",
|
||||||
"/gateway/:name/listeners/:id/authentication",
|
"/gateways/:name/listeners/:id/authentication",
|
||||||
"/gateway/:name/listeners/:id/authentication/users",
|
"/gateways/:name/listeners/:id/authentication/users",
|
||||||
"/gateway/:name/listeners/:id/authentication/users/:uid"
|
"/gateways/:name/listeners/:id/authentication/users/:uid"
|
||||||
].
|
]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% http handlers
|
%% http handlers
|
||||||
|
@ -353,7 +353,7 @@ bind2str(Listener = #{<<"bind">> := Bind}) ->
|
||||||
%% Swagger defines
|
%% Swagger defines
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
schema("/gateway/:name/listeners") ->
|
schema("/gateways/:name/listeners") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => listeners,
|
'operationId' => listeners,
|
||||||
get =>
|
get =>
|
||||||
|
@ -391,7 +391,7 @@ schema("/gateway/:name/listeners") ->
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/listeners/:id") ->
|
schema("/gateways/:name/listeners/:id") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => listeners_insta,
|
'operationId' => listeners_insta,
|
||||||
get =>
|
get =>
|
||||||
|
@ -437,7 +437,7 @@ schema("/gateway/:name/listeners/:id") ->
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/listeners/:id/authentication") ->
|
schema("/gateways/:name/listeners/:id/authentication") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => listeners_insta_authn,
|
'operationId' => listeners_insta_authn,
|
||||||
get =>
|
get =>
|
||||||
|
@ -480,7 +480,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
?STANDARD_RESP(#{200 => <<"Deleted">>})
|
?STANDARD_RESP(#{200 => <<"Deleted">>})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/listeners/:id/authentication/users") ->
|
schema("/gateways/:name/listeners/:id/authentication/users") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => users,
|
'operationId' => users,
|
||||||
get =>
|
get =>
|
||||||
|
@ -519,7 +519,7 @@ schema("/gateway/:name/listeners/:id/authentication/users") ->
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
schema("/gateways/:name/listeners/:id/authentication/users/:uid") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => users_insta,
|
'operationId' => users_insta,
|
||||||
get =>
|
get =>
|
||||||
|
@ -567,8 +567,9 @@ schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
||||||
responses =>
|
responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
||||||
}
|
}
|
||||||
}.
|
};
|
||||||
|
schema(Path) ->
|
||||||
|
emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% params defines
|
%% params defines
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,9 @@
|
||||||
parse_listener_id/1,
|
parse_listener_id/1,
|
||||||
is_running/2,
|
is_running/2,
|
||||||
global_chain/1,
|
global_chain/1,
|
||||||
listener_chain/3
|
listener_chain/3,
|
||||||
|
make_deprecated_paths/1,
|
||||||
|
make_compatible_schema/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([stringfy/1]).
|
-export([stringfy/1]).
|
||||||
|
@ -538,3 +540,36 @@ default_subopts() ->
|
||||||
qos => 0,
|
qos => 0,
|
||||||
is_new => true
|
is_new => true
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
%% Since 5.0.8, the API path of the gateway has been changed from "gateway" to "gateways"
|
||||||
|
%% and we need to be compatible with the old path
|
||||||
|
get_compatible_path("/gateway") ->
|
||||||
|
"/gateways";
|
||||||
|
get_compatible_path("/gateway/" ++ Rest) ->
|
||||||
|
"/gateways/" ++ Rest.
|
||||||
|
|
||||||
|
get_deprecated_path("/gateways") ->
|
||||||
|
"/gateway";
|
||||||
|
get_deprecated_path("/gateways/" ++ Rest) ->
|
||||||
|
"/gateway/" ++ Rest.
|
||||||
|
|
||||||
|
make_deprecated_paths(Paths) ->
|
||||||
|
Paths ++ [get_deprecated_path(Path) || Path <- Paths].
|
||||||
|
|
||||||
|
make_compatible_schema(Path, SchemaFun) ->
|
||||||
|
OldPath = get_compatible_path(Path),
|
||||||
|
make_compatible_schema2(OldPath, SchemaFun).
|
||||||
|
|
||||||
|
make_compatible_schema2(Path, SchemaFun) ->
|
||||||
|
Schema = SchemaFun(Path),
|
||||||
|
maps:map(
|
||||||
|
fun(Key, Value) ->
|
||||||
|
case lists:member(Key, [get, delete, put, post]) of
|
||||||
|
true ->
|
||||||
|
Value#{deprecated => true};
|
||||||
|
_ ->
|
||||||
|
Value
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
Schema
|
||||||
|
).
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
-export([lookup/2, observe/2, read/2, write/2]).
|
-export([lookup/2, observe/2, read/2, write/2]).
|
||||||
|
|
||||||
-define(PATH(Suffix), "/gateway/lwm2m/clients/:clientid" Suffix).
|
-define(PATH(Suffix), "/gateways/lwm2m/clients/:clientid" Suffix).
|
||||||
-define(DATA_TYPE, ['Integer', 'Float', 'Time', 'String', 'Boolean', 'Opaque', 'Objlnk']).
|
-define(DATA_TYPE, ['Integer', 'Float', 'Time', 'String', 'Boolean', 'Opaque', 'Objlnk']).
|
||||||
|
|
||||||
-import(hoconsc, [mk/2, ref/1, ref/2]).
|
-import(hoconsc, [mk/2, ref/1, ref/2]).
|
||||||
|
@ -37,7 +37,9 @@ api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE).
|
emqx_dashboard_swagger:spec(?MODULE).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
[?PATH("/lookup"), ?PATH("/observe"), ?PATH("/read"), ?PATH("/write")].
|
emqx_gateway_utils:make_deprecated_paths([
|
||||||
|
?PATH("/lookup"), ?PATH("/observe"), ?PATH("/read"), ?PATH("/write")
|
||||||
|
]).
|
||||||
|
|
||||||
schema(?PATH("/lookup")) ->
|
schema(?PATH("/lookup")) ->
|
||||||
#{
|
#{
|
||||||
|
@ -118,7 +120,9 @@ schema(?PATH("/write")) ->
|
||||||
404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
|
404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.
|
};
|
||||||
|
schema(Path) ->
|
||||||
|
emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
|
||||||
|
|
||||||
fields(resource) ->
|
fields(resource) ->
|
||||||
[
|
[
|
||||||
|
|
|
@ -255,37 +255,37 @@ t_clients_api(_) ->
|
||||||
Fun = fun(_Channel, _Token) ->
|
Fun = fun(_Channel, _Token) ->
|
||||||
ClientId = <<"client1">>,
|
ClientId = <<"client1">>,
|
||||||
%% list
|
%% list
|
||||||
{200, #{data := [Client1]}} = request(get, "/gateway/coap/clients"),
|
{200, #{data := [Client1]}} = request(get, "/gateways/coap/clients"),
|
||||||
#{clientid := ClientId} = Client1,
|
#{clientid := ClientId} = Client1,
|
||||||
%% searching
|
%% searching
|
||||||
{200, #{data := [Client2]}} =
|
{200, #{data := [Client2]}} =
|
||||||
request(
|
request(
|
||||||
get,
|
get,
|
||||||
"/gateway/coap/clients",
|
"/gateways/coap/clients",
|
||||||
[{<<"clientid">>, ClientId}]
|
[{<<"clientid">>, ClientId}]
|
||||||
),
|
),
|
||||||
{200, #{data := [Client3]}} =
|
{200, #{data := [Client3]}} =
|
||||||
request(
|
request(
|
||||||
get,
|
get,
|
||||||
"/gateway/coap/clients",
|
"/gateways/coap/clients",
|
||||||
[{<<"like_clientid">>, <<"cli">>}]
|
[{<<"like_clientid">>, <<"cli">>}]
|
||||||
),
|
),
|
||||||
%% lookup
|
%% lookup
|
||||||
{200, Client4} =
|
{200, Client4} =
|
||||||
request(get, "/gateway/coap/clients/client1"),
|
request(get, "/gateways/coap/clients/client1"),
|
||||||
%% assert
|
%% assert
|
||||||
Client1 = Client2 = Client3 = Client4,
|
Client1 = Client2 = Client3 = Client4,
|
||||||
%% kickout
|
%% kickout
|
||||||
{204, _} =
|
{204, _} =
|
||||||
request(delete, "/gateway/coap/clients/client1"),
|
request(delete, "/gateways/coap/clients/client1"),
|
||||||
timer:sleep(200),
|
timer:sleep(200),
|
||||||
{200, #{data := []}} = request(get, "/gateway/coap/clients")
|
{200, #{data := []}} = request(get, "/gateways/coap/clients")
|
||||||
end,
|
end,
|
||||||
with_connection(Fun).
|
with_connection(Fun).
|
||||||
|
|
||||||
t_clients_subscription_api(_) ->
|
t_clients_subscription_api(_) ->
|
||||||
Fun = fun(_Channel, _Token) ->
|
Fun = fun(_Channel, _Token) ->
|
||||||
Path = "/gateway/coap/clients/client1/subscriptions",
|
Path = "/gateways/coap/clients/client1/subscriptions",
|
||||||
%% list
|
%% list
|
||||||
{200, []} = request(get, Path),
|
{200, []} = request(get, Path),
|
||||||
%% create
|
%% create
|
||||||
|
@ -312,7 +312,7 @@ t_clients_subscription_api(_) ->
|
||||||
|
|
||||||
t_clients_get_subscription_api(_) ->
|
t_clients_get_subscription_api(_) ->
|
||||||
Fun = fun(Channel, Token) ->
|
Fun = fun(Channel, Token) ->
|
||||||
Path = "/gateway/coap/clients/client1/subscriptions",
|
Path = "/gateways/coap/clients/client1/subscriptions",
|
||||||
%% list
|
%% list
|
||||||
{200, []} = request(get, Path),
|
{200, []} = request(get, Path),
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ end_per_suite(Config) ->
|
||||||
t_send_request_api(_) ->
|
t_send_request_api(_) ->
|
||||||
ClientId = start_client(),
|
ClientId = start_client(),
|
||||||
timer:sleep(200),
|
timer:sleep(200),
|
||||||
Path = emqx_mgmt_api_test_util:api_path(["gateway/coap/clients/client1/request"]),
|
Test = fun(API) ->
|
||||||
|
Path = emqx_mgmt_api_test_util:api_path([API]),
|
||||||
Token = <<"atoken">>,
|
Token = <<"atoken">>,
|
||||||
Payload = <<"simple echo this">>,
|
Payload = <<"simple echo this">>,
|
||||||
Req = #{
|
Req = #{
|
||||||
|
@ -92,7 +93,11 @@ t_send_request_api(_) ->
|
||||||
#{<<"token">> := RToken, <<"payload">> := RPayload} =
|
#{<<"token">> := RToken, <<"payload">> := RPayload} =
|
||||||
emqx_json:decode(Response, [return_maps]),
|
emqx_json:decode(Response, [return_maps]),
|
||||||
?assertEqual(Token, RToken),
|
?assertEqual(Token, RToken),
|
||||||
?assertEqual(Payload, RPayload),
|
?assertEqual(Payload, RPayload)
|
||||||
|
end,
|
||||||
|
Test("gateways/coap/clients/client1/request"),
|
||||||
|
timer:sleep(100),
|
||||||
|
Test("gateway/coap/clients/client1/request"),
|
||||||
erlang:exit(ClientId, kill),
|
erlang:exit(ClientId, kill),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,22 @@ end_per_suite(Conf) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
t_gateway(_) ->
|
t_gateway(_) ->
|
||||||
|
{200, Gateways} = request(get, "/gateways"),
|
||||||
|
lists:foreach(fun assert_gw_unloaded/1, Gateways),
|
||||||
|
{400, BadReq} = request(get, "/gateways/uname_gateway"),
|
||||||
|
assert_bad_request(BadReq),
|
||||||
|
{201, _} = request(post, "/gateways", #{name => <<"stomp">>}),
|
||||||
|
{200, StompGw1} = request(get, "/gateways/stomp"),
|
||||||
|
assert_feilds_apperence(
|
||||||
|
[name, status, enable, created_at, started_at],
|
||||||
|
StompGw1
|
||||||
|
),
|
||||||
|
{204, _} = request(delete, "/gateways/stomp"),
|
||||||
|
{200, StompGw2} = request(get, "/gateways/stomp"),
|
||||||
|
assert_gw_unloaded(StompGw2),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
t_deprecated_gateway(_) ->
|
||||||
{200, Gateways} = request(get, "/gateway"),
|
{200, Gateways} = request(get, "/gateway"),
|
||||||
lists:foreach(fun assert_gw_unloaded/1, Gateways),
|
lists:foreach(fun assert_gw_unloaded/1, Gateways),
|
||||||
{400, BadReq} = request(get, "/gateway/uname_gateway"),
|
{400, BadReq} = request(get, "/gateway/uname_gateway"),
|
||||||
|
@ -76,7 +92,7 @@ t_gateway(_) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
t_gateway_stomp(_) ->
|
t_gateway_stomp(_) ->
|
||||||
{200, Gw} = request(get, "/gateway/stomp"),
|
{200, Gw} = request(get, "/gateways/stomp"),
|
||||||
assert_gw_unloaded(Gw),
|
assert_gw_unloaded(Gw),
|
||||||
%% post
|
%% post
|
||||||
GwConf = #{
|
GwConf = #{
|
||||||
|
@ -90,18 +106,18 @@ t_gateway_stomp(_) ->
|
||||||
#{name => <<"def">>, type => <<"tcp">>, bind => <<"61613">>}
|
#{name => <<"def">>, type => <<"tcp">>, bind => <<"61613">>}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/stomp"),
|
{200, ConfResp} = request(get, "/gateways/stomp"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
%% put
|
%% put
|
||||||
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{frame => #{max_headers => 10}}),
|
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{frame => #{max_headers => 10}}),
|
||||||
{200, _} = request(put, "/gateway/stomp", maps:without([name, listeners], GwConf2)),
|
{200, _} = request(put, "/gateways/stomp", maps:without([name, listeners], GwConf2)),
|
||||||
{200, ConfResp2} = request(get, "/gateway/stomp"),
|
{200, ConfResp2} = request(get, "/gateways/stomp"),
|
||||||
assert_confs(GwConf2, ConfResp2),
|
assert_confs(GwConf2, ConfResp2),
|
||||||
{204, _} = request(delete, "/gateway/stomp").
|
{204, _} = request(delete, "/gateways/stomp").
|
||||||
|
|
||||||
t_gateway_mqttsn(_) ->
|
t_gateway_mqttsn(_) ->
|
||||||
{200, Gw} = request(get, "/gateway/mqttsn"),
|
{200, Gw} = request(get, "/gateways/mqttsn"),
|
||||||
assert_gw_unloaded(Gw),
|
assert_gw_unloaded(Gw),
|
||||||
%% post
|
%% post
|
||||||
GwConf = #{
|
GwConf = #{
|
||||||
|
@ -114,18 +130,18 @@ t_gateway_mqttsn(_) ->
|
||||||
#{name => <<"def">>, type => <<"udp">>, bind => <<"1884">>}
|
#{name => <<"def">>, type => <<"udp">>, bind => <<"1884">>}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/mqttsn"),
|
{200, ConfResp} = request(get, "/gateways/mqttsn"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
%% put
|
%% put
|
||||||
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{predefined => []}),
|
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{predefined => []}),
|
||||||
{200, _} = request(put, "/gateway/mqttsn", maps:without([name, listeners], GwConf2)),
|
{200, _} = request(put, "/gateways/mqttsn", maps:without([name, listeners], GwConf2)),
|
||||||
{200, ConfResp2} = request(get, "/gateway/mqttsn"),
|
{200, ConfResp2} = request(get, "/gateways/mqttsn"),
|
||||||
assert_confs(GwConf2, ConfResp2),
|
assert_confs(GwConf2, ConfResp2),
|
||||||
{204, _} = request(delete, "/gateway/mqttsn").
|
{204, _} = request(delete, "/gateways/mqttsn").
|
||||||
|
|
||||||
t_gateway_coap(_) ->
|
t_gateway_coap(_) ->
|
||||||
{200, Gw} = request(get, "/gateway/coap"),
|
{200, Gw} = request(get, "/gateways/coap"),
|
||||||
assert_gw_unloaded(Gw),
|
assert_gw_unloaded(Gw),
|
||||||
%% post
|
%% post
|
||||||
GwConf = #{
|
GwConf = #{
|
||||||
|
@ -136,18 +152,18 @@ t_gateway_coap(_) ->
|
||||||
#{name => <<"def">>, type => <<"udp">>, bind => <<"5683">>}
|
#{name => <<"def">>, type => <<"udp">>, bind => <<"5683">>}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/coap"),
|
{200, ConfResp} = request(get, "/gateways/coap"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
%% put
|
%% put
|
||||||
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{heartbeat => <<"10s">>}),
|
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{heartbeat => <<"10s">>}),
|
||||||
{200, _} = request(put, "/gateway/coap", maps:without([name, listeners], GwConf2)),
|
{200, _} = request(put, "/gateways/coap", maps:without([name, listeners], GwConf2)),
|
||||||
{200, ConfResp2} = request(get, "/gateway/coap"),
|
{200, ConfResp2} = request(get, "/gateways/coap"),
|
||||||
assert_confs(GwConf2, ConfResp2),
|
assert_confs(GwConf2, ConfResp2),
|
||||||
{204, _} = request(delete, "/gateway/coap").
|
{204, _} = request(delete, "/gateways/coap").
|
||||||
|
|
||||||
t_gateway_lwm2m(_) ->
|
t_gateway_lwm2m(_) ->
|
||||||
{200, Gw} = request(get, "/gateway/lwm2m"),
|
{200, Gw} = request(get, "/gateways/lwm2m"),
|
||||||
assert_gw_unloaded(Gw),
|
assert_gw_unloaded(Gw),
|
||||||
%% post
|
%% post
|
||||||
GwConf = #{
|
GwConf = #{
|
||||||
|
@ -168,18 +184,18 @@ t_gateway_lwm2m(_) ->
|
||||||
#{name => <<"def">>, type => <<"udp">>, bind => <<"5783">>}
|
#{name => <<"def">>, type => <<"udp">>, bind => <<"5783">>}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/lwm2m"),
|
{200, ConfResp} = request(get, "/gateways/lwm2m"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
%% put
|
%% put
|
||||||
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{qmode_time_window => <<"10s">>}),
|
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{qmode_time_window => <<"10s">>}),
|
||||||
{200, _} = request(put, "/gateway/lwm2m", maps:without([name, listeners], GwConf2)),
|
{200, _} = request(put, "/gateways/lwm2m", maps:without([name, listeners], GwConf2)),
|
||||||
{200, ConfResp2} = request(get, "/gateway/lwm2m"),
|
{200, ConfResp2} = request(get, "/gateways/lwm2m"),
|
||||||
assert_confs(GwConf2, ConfResp2),
|
assert_confs(GwConf2, ConfResp2),
|
||||||
{204, _} = request(delete, "/gateway/lwm2m").
|
{204, _} = request(delete, "/gateways/lwm2m").
|
||||||
|
|
||||||
t_gateway_exproto(_) ->
|
t_gateway_exproto(_) ->
|
||||||
{200, Gw} = request(get, "/gateway/exproto"),
|
{200, Gw} = request(get, "/gateways/exproto"),
|
||||||
assert_gw_unloaded(Gw),
|
assert_gw_unloaded(Gw),
|
||||||
%% post
|
%% post
|
||||||
GwConf = #{
|
GwConf = #{
|
||||||
|
@ -190,18 +206,18 @@ t_gateway_exproto(_) ->
|
||||||
#{name => <<"def">>, type => <<"tcp">>, bind => <<"7993">>}
|
#{name => <<"def">>, type => <<"tcp">>, bind => <<"7993">>}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/exproto"),
|
{200, ConfResp} = request(get, "/gateways/exproto"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
%% put
|
%% put
|
||||||
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{server => #{bind => <<"9200">>}}),
|
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{server => #{bind => <<"9200">>}}),
|
||||||
{200, _} = request(put, "/gateway/exproto", maps:without([name, listeners], GwConf2)),
|
{200, _} = request(put, "/gateways/exproto", maps:without([name, listeners], GwConf2)),
|
||||||
{200, ConfResp2} = request(get, "/gateway/exproto"),
|
{200, ConfResp2} = request(get, "/gateways/exproto"),
|
||||||
assert_confs(GwConf2, ConfResp2),
|
assert_confs(GwConf2, ConfResp2),
|
||||||
{204, _} = request(delete, "/gateway/exproto").
|
{204, _} = request(delete, "/gateways/exproto").
|
||||||
|
|
||||||
t_gateway_exproto_with_ssl(_) ->
|
t_gateway_exproto_with_ssl(_) ->
|
||||||
{200, Gw} = request(get, "/gateway/exproto"),
|
{200, Gw} = request(get, "/gateways/exproto"),
|
||||||
assert_gw_unloaded(Gw),
|
assert_gw_unloaded(Gw),
|
||||||
|
|
||||||
SslSvrOpts = ssl_server_opts(),
|
SslSvrOpts = ssl_server_opts(),
|
||||||
|
@ -221,8 +237,8 @@ t_gateway_exproto_with_ssl(_) ->
|
||||||
#{name => <<"def">>, type => <<"tcp">>, bind => <<"7993">>}
|
#{name => <<"def">>, type => <<"tcp">>, bind => <<"7993">>}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/exproto"),
|
{200, ConfResp} = request(get, "/gateways/exproto"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
%% put
|
%% put
|
||||||
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{
|
GwConf2 = emqx_map_lib:deep_merge(GwConf, #{
|
||||||
|
@ -231,50 +247,50 @@ t_gateway_exproto_with_ssl(_) ->
|
||||||
ssl_options => SslCliOpts
|
ssl_options => SslCliOpts
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
{200, _} = request(put, "/gateway/exproto", maps:without([name, listeners], GwConf2)),
|
{200, _} = request(put, "/gateways/exproto", maps:without([name, listeners], GwConf2)),
|
||||||
{200, ConfResp2} = request(get, "/gateway/exproto"),
|
{200, ConfResp2} = request(get, "/gateways/exproto"),
|
||||||
assert_confs(GwConf2, ConfResp2),
|
assert_confs(GwConf2, ConfResp2),
|
||||||
{204, _} = request(delete, "/gateway/exproto").
|
{204, _} = request(delete, "/gateways/exproto").
|
||||||
|
|
||||||
t_authn(_) ->
|
t_authn(_) ->
|
||||||
GwConf = #{name => <<"stomp">>},
|
GwConf = #{name => <<"stomp">>},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
ct:sleep(500),
|
ct:sleep(500),
|
||||||
{204, _} = request(get, "/gateway/stomp/authentication"),
|
{204, _} = request(get, "/gateways/stomp/authentication"),
|
||||||
|
|
||||||
AuthConf = #{
|
AuthConf = #{
|
||||||
mechanism => <<"password_based">>,
|
mechanism => <<"password_based">>,
|
||||||
backend => <<"built_in_database">>,
|
backend => <<"built_in_database">>,
|
||||||
user_id_type => <<"clientid">>
|
user_id_type => <<"clientid">>
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway/stomp/authentication", AuthConf),
|
{201, _} = request(post, "/gateways/stomp/authentication", AuthConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/stomp/authentication"),
|
{200, ConfResp} = request(get, "/gateways/stomp/authentication"),
|
||||||
assert_confs(AuthConf, ConfResp),
|
assert_confs(AuthConf, ConfResp),
|
||||||
|
|
||||||
AuthConf2 = maps:merge(AuthConf, #{user_id_type => <<"username">>}),
|
AuthConf2 = maps:merge(AuthConf, #{user_id_type => <<"username">>}),
|
||||||
{200, _} = request(put, "/gateway/stomp/authentication", AuthConf2),
|
{200, _} = request(put, "/gateways/stomp/authentication", AuthConf2),
|
||||||
|
|
||||||
{200, ConfResp2} = request(get, "/gateway/stomp/authentication"),
|
{200, ConfResp2} = request(get, "/gateways/stomp/authentication"),
|
||||||
assert_confs(AuthConf2, ConfResp2),
|
assert_confs(AuthConf2, ConfResp2),
|
||||||
|
|
||||||
{204, _} = request(delete, "/gateway/stomp/authentication"),
|
{204, _} = request(delete, "/gateways/stomp/authentication"),
|
||||||
{204, _} = request(get, "/gateway/stomp/authentication"),
|
{204, _} = request(get, "/gateways/stomp/authentication"),
|
||||||
{204, _} = request(delete, "/gateway/stomp").
|
{204, _} = request(delete, "/gateways/stomp").
|
||||||
|
|
||||||
t_authn_data_mgmt(_) ->
|
t_authn_data_mgmt(_) ->
|
||||||
GwConf = #{name => <<"stomp">>},
|
GwConf = #{name => <<"stomp">>},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
ct:sleep(500),
|
ct:sleep(500),
|
||||||
{204, _} = request(get, "/gateway/stomp/authentication"),
|
{204, _} = request(get, "/gateways/stomp/authentication"),
|
||||||
|
|
||||||
AuthConf = #{
|
AuthConf = #{
|
||||||
mechanism => <<"password_based">>,
|
mechanism => <<"password_based">>,
|
||||||
backend => <<"built_in_database">>,
|
backend => <<"built_in_database">>,
|
||||||
user_id_type => <<"clientid">>
|
user_id_type => <<"clientid">>
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway/stomp/authentication", AuthConf),
|
{201, _} = request(post, "/gateways/stomp/authentication", AuthConf),
|
||||||
ct:sleep(500),
|
ct:sleep(500),
|
||||||
{200, ConfResp} = request(get, "/gateway/stomp/authentication"),
|
{200, ConfResp} = request(get, "/gateways/stomp/authentication"),
|
||||||
assert_confs(AuthConf, ConfResp),
|
assert_confs(AuthConf, ConfResp),
|
||||||
|
|
||||||
User1 = #{
|
User1 = #{
|
||||||
|
@ -282,19 +298,19 @@ t_authn_data_mgmt(_) ->
|
||||||
password => <<"123456">>,
|
password => <<"123456">>,
|
||||||
is_superuser => false
|
is_superuser => false
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway/stomp/authentication/users", User1),
|
{201, _} = request(post, "/gateways/stomp/authentication/users", User1),
|
||||||
{200, #{data := [UserRespd1]}} = request(get, "/gateway/stomp/authentication/users"),
|
{200, #{data := [UserRespd1]}} = request(get, "/gateways/stomp/authentication/users"),
|
||||||
assert_confs(UserRespd1, User1),
|
assert_confs(UserRespd1, User1),
|
||||||
|
|
||||||
{200, UserRespd2} = request(
|
{200, UserRespd2} = request(
|
||||||
get,
|
get,
|
||||||
"/gateway/stomp/authentication/users/test"
|
"/gateways/stomp/authentication/users/test"
|
||||||
),
|
),
|
||||||
assert_confs(UserRespd2, User1),
|
assert_confs(UserRespd2, User1),
|
||||||
|
|
||||||
{200, UserRespd3} = request(
|
{200, UserRespd3} = request(
|
||||||
put,
|
put,
|
||||||
"/gateway/stomp/authentication/users/test",
|
"/gateways/stomp/authentication/users/test",
|
||||||
#{
|
#{
|
||||||
password => <<"654321">>,
|
password => <<"654321">>,
|
||||||
is_superuser => true
|
is_superuser => true
|
||||||
|
@ -304,19 +320,19 @@ t_authn_data_mgmt(_) ->
|
||||||
|
|
||||||
{200, UserRespd4} = request(
|
{200, UserRespd4} = request(
|
||||||
get,
|
get,
|
||||||
"/gateway/stomp/authentication/users/test"
|
"/gateways/stomp/authentication/users/test"
|
||||||
),
|
),
|
||||||
assert_confs(UserRespd4, User1#{is_superuser => true}),
|
assert_confs(UserRespd4, User1#{is_superuser => true}),
|
||||||
|
|
||||||
{204, _} = request(delete, "/gateway/stomp/authentication/users/test"),
|
{204, _} = request(delete, "/gateways/stomp/authentication/users/test"),
|
||||||
|
|
||||||
{200, #{data := []}} = request(
|
{200, #{data := []}} = request(
|
||||||
get,
|
get,
|
||||||
"/gateway/stomp/authentication/users"
|
"/gateways/stomp/authentication/users"
|
||||||
),
|
),
|
||||||
|
|
||||||
ImportUri = emqx_dashboard_api_test_helpers:uri(
|
ImportUri = emqx_dashboard_api_test_helpers:uri(
|
||||||
["gateway", "stomp", "authentication", "import_users"]
|
["gateways", "stomp", "authentication", "import_users"]
|
||||||
),
|
),
|
||||||
|
|
||||||
Dir = code:lib_dir(emqx_authn, test),
|
Dir = code:lib_dir(emqx_authn, test),
|
||||||
|
@ -332,38 +348,38 @@ t_authn_data_mgmt(_) ->
|
||||||
{filename, "user-credentials.csv", CSVData}
|
{filename, "user-credentials.csv", CSVData}
|
||||||
]),
|
]),
|
||||||
|
|
||||||
{204, _} = request(delete, "/gateway/stomp/authentication"),
|
{204, _} = request(delete, "/gateways/stomp/authentication"),
|
||||||
{204, _} = request(get, "/gateway/stomp/authentication"),
|
{204, _} = request(get, "/gateways/stomp/authentication"),
|
||||||
{204, _} = request(delete, "/gateway/stomp").
|
{204, _} = request(delete, "/gateways/stomp").
|
||||||
|
|
||||||
t_listeners_tcp(_) ->
|
t_listeners_tcp(_) ->
|
||||||
GwConf = #{name => <<"stomp">>},
|
GwConf = #{name => <<"stomp">>},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{404, _} = request(get, "/gateway/stomp/listeners"),
|
{404, _} = request(get, "/gateways/stomp/listeners"),
|
||||||
LisConf = #{
|
LisConf = #{
|
||||||
name => <<"def">>,
|
name => <<"def">>,
|
||||||
type => <<"tcp">>,
|
type => <<"tcp">>,
|
||||||
bind => <<"127.0.0.1:61613">>
|
bind => <<"127.0.0.1:61613">>
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway/stomp/listeners", LisConf),
|
{201, _} = request(post, "/gateways/stomp/listeners", LisConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/stomp/listeners"),
|
{200, ConfResp} = request(get, "/gateways/stomp/listeners"),
|
||||||
assert_confs([LisConf], ConfResp),
|
assert_confs([LisConf], ConfResp),
|
||||||
{200, ConfResp1} = request(get, "/gateway/stomp/listeners/stomp:tcp:def"),
|
{200, ConfResp1} = request(get, "/gateways/stomp/listeners/stomp:tcp:def"),
|
||||||
assert_confs(LisConf, ConfResp1),
|
assert_confs(LisConf, ConfResp1),
|
||||||
|
|
||||||
LisConf2 = maps:merge(LisConf, #{bind => <<"127.0.0.1:61614">>}),
|
LisConf2 = maps:merge(LisConf, #{bind => <<"127.0.0.1:61614">>}),
|
||||||
{200, _} = request(
|
{200, _} = request(
|
||||||
put,
|
put,
|
||||||
"/gateway/stomp/listeners/stomp:tcp:def",
|
"/gateways/stomp/listeners/stomp:tcp:def",
|
||||||
LisConf2
|
LisConf2
|
||||||
),
|
),
|
||||||
|
|
||||||
{200, ConfResp2} = request(get, "/gateway/stomp/listeners/stomp:tcp:def"),
|
{200, ConfResp2} = request(get, "/gateways/stomp/listeners/stomp:tcp:def"),
|
||||||
assert_confs(LisConf2, ConfResp2),
|
assert_confs(LisConf2, ConfResp2),
|
||||||
|
|
||||||
{204, _} = request(delete, "/gateway/stomp/listeners/stomp:tcp:def"),
|
{204, _} = request(delete, "/gateways/stomp/listeners/stomp:tcp:def"),
|
||||||
{404, _} = request(get, "/gateway/stomp/listeners/stomp:tcp:def"),
|
{404, _} = request(get, "/gateways/stomp/listeners/stomp:tcp:def"),
|
||||||
{204, _} = request(delete, "/gateway/stomp").
|
{204, _} = request(delete, "/gateways/stomp").
|
||||||
|
|
||||||
t_listeners_authn(_) ->
|
t_listeners_authn(_) ->
|
||||||
GwConf = #{
|
GwConf = #{
|
||||||
|
@ -376,9 +392,9 @@ t_listeners_authn(_) ->
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
ct:sleep(500),
|
ct:sleep(500),
|
||||||
{200, ConfResp} = request(get, "/gateway/stomp"),
|
{200, ConfResp} = request(get, "/gateways/stomp"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
|
|
||||||
AuthConf = #{
|
AuthConf = #{
|
||||||
|
@ -386,7 +402,7 @@ t_listeners_authn(_) ->
|
||||||
backend => <<"built_in_database">>,
|
backend => <<"built_in_database">>,
|
||||||
user_id_type => <<"clientid">>
|
user_id_type => <<"clientid">>
|
||||||
},
|
},
|
||||||
Path = "/gateway/stomp/listeners/stomp:tcp:def/authentication",
|
Path = "/gateways/stomp/listeners/stomp:tcp:def/authentication",
|
||||||
{201, _} = request(post, Path, AuthConf),
|
{201, _} = request(post, Path, AuthConf),
|
||||||
{200, ConfResp2} = request(get, Path),
|
{200, ConfResp2} = request(get, Path),
|
||||||
assert_confs(AuthConf, ConfResp2),
|
assert_confs(AuthConf, ConfResp2),
|
||||||
|
@ -400,7 +416,7 @@ t_listeners_authn(_) ->
|
||||||
{204, _} = request(delete, Path),
|
{204, _} = request(delete, Path),
|
||||||
%% FIXME: 204?
|
%% FIXME: 204?
|
||||||
{204, _} = request(get, Path),
|
{204, _} = request(get, Path),
|
||||||
{204, _} = request(delete, "/gateway/stomp").
|
{204, _} = request(delete, "/gateways/stomp").
|
||||||
|
|
||||||
t_listeners_authn_data_mgmt(_) ->
|
t_listeners_authn_data_mgmt(_) ->
|
||||||
GwConf = #{
|
GwConf = #{
|
||||||
|
@ -413,8 +429,8 @@ t_listeners_authn_data_mgmt(_) ->
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/stomp"),
|
{200, ConfResp} = request(get, "/gateways/stomp"),
|
||||||
assert_confs(GwConf, ConfResp),
|
assert_confs(GwConf, ConfResp),
|
||||||
|
|
||||||
AuthConf = #{
|
AuthConf = #{
|
||||||
|
@ -422,7 +438,7 @@ t_listeners_authn_data_mgmt(_) ->
|
||||||
backend => <<"built_in_database">>,
|
backend => <<"built_in_database">>,
|
||||||
user_id_type => <<"clientid">>
|
user_id_type => <<"clientid">>
|
||||||
},
|
},
|
||||||
Path = "/gateway/stomp/listeners/stomp:tcp:def/authentication",
|
Path = "/gateways/stomp/listeners/stomp:tcp:def/authentication",
|
||||||
{201, _} = request(post, Path, AuthConf),
|
{201, _} = request(post, Path, AuthConf),
|
||||||
{200, ConfResp2} = request(get, Path),
|
{200, ConfResp2} = request(get, Path),
|
||||||
assert_confs(AuthConf, ConfResp2),
|
assert_confs(AuthConf, ConfResp2),
|
||||||
|
@ -434,7 +450,7 @@ t_listeners_authn_data_mgmt(_) ->
|
||||||
},
|
},
|
||||||
{201, _} = request(
|
{201, _} = request(
|
||||||
post,
|
post,
|
||||||
"/gateway/stomp/listeners/stomp:tcp:def/authentication/users",
|
"/gateways/stomp/listeners/stomp:tcp:def/authentication/users",
|
||||||
User1
|
User1
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -474,7 +490,7 @@ t_listeners_authn_data_mgmt(_) ->
|
||||||
),
|
),
|
||||||
|
|
||||||
ImportUri = emqx_dashboard_api_test_helpers:uri(
|
ImportUri = emqx_dashboard_api_test_helpers:uri(
|
||||||
["gateway", "stomp", "listeners", "stomp:tcp:def", "authentication", "import_users"]
|
["gateways", "stomp", "listeners", "stomp:tcp:def", "authentication", "import_users"]
|
||||||
),
|
),
|
||||||
|
|
||||||
Dir = code:lib_dir(emqx_authn, test),
|
Dir = code:lib_dir(emqx_authn, test),
|
||||||
|
@ -490,31 +506,31 @@ t_listeners_authn_data_mgmt(_) ->
|
||||||
{filename, "user-credentials.csv", CSVData}
|
{filename, "user-credentials.csv", CSVData}
|
||||||
]),
|
]),
|
||||||
|
|
||||||
{204, _} = request(delete, "/gateway/stomp").
|
{204, _} = request(delete, "/gateways/stomp").
|
||||||
|
|
||||||
t_authn_fuzzy_search(_) ->
|
t_authn_fuzzy_search(_) ->
|
||||||
GwConf = #{name => <<"stomp">>},
|
GwConf = #{name => <<"stomp">>},
|
||||||
{201, _} = request(post, "/gateway", GwConf),
|
{201, _} = request(post, "/gateways", GwConf),
|
||||||
{204, _} = request(get, "/gateway/stomp/authentication"),
|
{204, _} = request(get, "/gateways/stomp/authentication"),
|
||||||
|
|
||||||
AuthConf = #{
|
AuthConf = #{
|
||||||
mechanism => <<"password_based">>,
|
mechanism => <<"password_based">>,
|
||||||
backend => <<"built_in_database">>,
|
backend => <<"built_in_database">>,
|
||||||
user_id_type => <<"clientid">>
|
user_id_type => <<"clientid">>
|
||||||
},
|
},
|
||||||
{201, _} = request(post, "/gateway/stomp/authentication", AuthConf),
|
{201, _} = request(post, "/gateways/stomp/authentication", AuthConf),
|
||||||
{200, ConfResp} = request(get, "/gateway/stomp/authentication"),
|
{200, ConfResp} = request(get, "/gateways/stomp/authentication"),
|
||||||
assert_confs(AuthConf, ConfResp),
|
assert_confs(AuthConf, ConfResp),
|
||||||
|
|
||||||
Checker = fun({User, Fuzzy}) ->
|
Checker = fun({User, Fuzzy}) ->
|
||||||
{200, #{data := [UserRespd]}} = request(
|
{200, #{data := [UserRespd]}} = request(
|
||||||
get, "/gateway/stomp/authentication/users", Fuzzy
|
get, "/gateways/stomp/authentication/users", Fuzzy
|
||||||
),
|
),
|
||||||
assert_confs(UserRespd, User)
|
assert_confs(UserRespd, User)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
Create = fun(User) ->
|
Create = fun(User) ->
|
||||||
{201, _} = request(post, "/gateway/stomp/authentication/users", User)
|
{201, _} = request(post, "/gateways/stomp/authentication/users", User)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
UserDatas = [
|
UserDatas = [
|
||||||
|
@ -535,9 +551,9 @@ t_authn_fuzzy_search(_) ->
|
||||||
lists:foreach(Create, UserDatas),
|
lists:foreach(Create, UserDatas),
|
||||||
lists:foreach(Checker, lists:zip(UserDatas, FuzzyDatas)),
|
lists:foreach(Checker, lists:zip(UserDatas, FuzzyDatas)),
|
||||||
|
|
||||||
{204, _} = request(delete, "/gateway/stomp/authentication"),
|
{204, _} = request(delete, "/gateways/stomp/authentication"),
|
||||||
{204, _} = request(get, "/gateway/stomp/authentication"),
|
{204, _} = request(get, "/gateways/stomp/authentication"),
|
||||||
{204, _} = request(delete, "/gateway/stomp").
|
{204, _} = request(delete, "/gateways/stomp").
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Asserts
|
%% Asserts
|
||||||
|
|
|
@ -141,7 +141,7 @@ on_start_auth(authn_http) ->
|
||||||
|
|
||||||
%% set authn for gateway
|
%% set authn for gateway
|
||||||
Setup = fun(Gateway) ->
|
Setup = fun(Gateway) ->
|
||||||
Path = io_lib:format("/gateway/~ts/authentication", [Gateway]),
|
Path = io_lib:format("/gateways/~ts/authentication", [Gateway]),
|
||||||
{204, _} = request(delete, Path),
|
{204, _} = request(delete, Path),
|
||||||
timer:sleep(200),
|
timer:sleep(200),
|
||||||
{201, _} = request(post, Path, http_authn_config()),
|
{201, _} = request(post, Path, http_authn_config()),
|
||||||
|
@ -198,7 +198,7 @@ on_start_auth(authz_http) ->
|
||||||
|
|
||||||
on_stop_auth(authn_http) ->
|
on_stop_auth(authn_http) ->
|
||||||
Delete = fun(Gateway) ->
|
Delete = fun(Gateway) ->
|
||||||
Path = io_lib:format("/gateway/~ts/authentication", [Gateway]),
|
Path = io_lib:format("/gateways/~ts/authentication", [Gateway]),
|
||||||
{204, _} = request(delete, Path)
|
{204, _} = request(delete, Path)
|
||||||
end,
|
end,
|
||||||
lists:foreach(Delete, ?GATEWAYS),
|
lists:foreach(Delete, ?GATEWAYS),
|
||||||
|
|
|
@ -2353,18 +2353,18 @@ case100_clients_api(Config) ->
|
||||||
std_register(UdpSock, Epn, ObjectList, MsgId1, RespTopic),
|
std_register(UdpSock, Epn, ObjectList, MsgId1, RespTopic),
|
||||||
|
|
||||||
%% list
|
%% list
|
||||||
{200, #{data := [Client1]}} = request(get, "/gateway/lwm2m/clients"),
|
{200, #{data := [Client1]}} = request(get, "/gateways/lwm2m/clients"),
|
||||||
%% searching
|
%% searching
|
||||||
{200, #{data := [Client2]}} =
|
{200, #{data := [Client2]}} =
|
||||||
request(
|
request(
|
||||||
get,
|
get,
|
||||||
"/gateway/lwm2m/clients",
|
"/gateways/lwm2m/clients",
|
||||||
[{<<"endpoint_name">>, list_to_binary(Epn)}]
|
[{<<"endpoint_name">>, list_to_binary(Epn)}]
|
||||||
),
|
),
|
||||||
{200, #{data := [Client3]}} =
|
{200, #{data := [Client3]}} =
|
||||||
request(
|
request(
|
||||||
get,
|
get,
|
||||||
"/gateway/lwm2m/clients",
|
"/gateways/lwm2m/clients",
|
||||||
[
|
[
|
||||||
{<<"like_endpoint_name">>, list_to_binary(Epn)},
|
{<<"like_endpoint_name">>, list_to_binary(Epn)},
|
||||||
{<<"gte_lifetime">>, <<"1">>}
|
{<<"gte_lifetime">>, <<"1">>}
|
||||||
|
@ -2373,14 +2373,14 @@ case100_clients_api(Config) ->
|
||||||
%% lookup
|
%% lookup
|
||||||
ClientId = maps:get(clientid, Client1),
|
ClientId = maps:get(clientid, Client1),
|
||||||
{200, Client4} =
|
{200, Client4} =
|
||||||
request(get, "/gateway/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
request(get, "/gateways/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
||||||
%% assert
|
%% assert
|
||||||
Client1 = Client2 = Client3 = Client4,
|
Client1 = Client2 = Client3 = Client4,
|
||||||
%% kickout
|
%% kickout
|
||||||
{204, _} =
|
{204, _} =
|
||||||
request(delete, "/gateway/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
request(delete, "/gateways/lwm2m/clients/" ++ binary_to_list(ClientId)),
|
||||||
timer:sleep(100),
|
timer:sleep(100),
|
||||||
{200, #{data := []}} = request(get, "/gateway/lwm2m/clients").
|
{200, #{data := []}} = request(get, "/gateways/lwm2m/clients").
|
||||||
|
|
||||||
case100_subscription_api(Config) ->
|
case100_subscription_api(Config) ->
|
||||||
Epn = "urn:oma:lwm2m:oma:3",
|
Epn = "urn:oma:lwm2m:oma:3",
|
||||||
|
@ -2390,10 +2390,10 @@ case100_subscription_api(Config) ->
|
||||||
RespTopic = list_to_binary("lwm2m/" ++ Epn ++ "/up/resp"),
|
RespTopic = list_to_binary("lwm2m/" ++ Epn ++ "/up/resp"),
|
||||||
std_register(UdpSock, Epn, ObjectList, MsgId1, RespTopic),
|
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),
|
ClientId = maps:get(clientid, Client1),
|
||||||
Path =
|
Path =
|
||||||
"/gateway/lwm2m/clients/" ++
|
"/gateways/lwm2m/clients/" ++
|
||||||
binary_to_list(ClientId) ++
|
binary_to_list(ClientId) ++
|
||||||
"/subscriptions",
|
"/subscriptions",
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ t_observe(Config) ->
|
||||||
test_recv_mqtt_response(RespTopic),
|
test_recv_mqtt_response(RespTopic),
|
||||||
|
|
||||||
%% step2, call observe API
|
%% step2, call observe API
|
||||||
call_send_api(Epn, "observe", "path=/3/0/1&enable=false"),
|
call_deprecated_send_api(Epn, "observe", "path=/3/0/1&enable=false"),
|
||||||
timer:sleep(100),
|
timer:sleep(100),
|
||||||
#coap_message{type = Type, method = Method, options = Opts} = test_recv_coap_request(UdpSock),
|
#coap_message{type = Type, method = Method, options = Opts} = test_recv_coap_request(UdpSock),
|
||||||
?assertEqual(con, Type),
|
?assertEqual(con, Type),
|
||||||
|
@ -338,7 +338,7 @@ t_observe(Config) ->
|
||||||
%%% Internal Functions
|
%%% Internal Functions
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
call_lookup_api(ClientId, Path, Action) ->
|
call_lookup_api(ClientId, Path, Action) ->
|
||||||
ApiPath = emqx_mgmt_api_test_util:api_path(["gateway/lwm2m/clients", ClientId, "lookup"]),
|
ApiPath = emqx_mgmt_api_test_util:api_path(["gateways/lwm2m/clients", ClientId, "lookup"]),
|
||||||
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
Query = io_lib:format("path=~ts&action=~ts", [Path, Action]),
|
Query = io_lib:format("path=~ts&action=~ts", [Path, Action]),
|
||||||
{ok, Response} = emqx_mgmt_api_test_util:request_api(get, ApiPath, Query, Auth),
|
{ok, Response} = emqx_mgmt_api_test_util:request_api(get, ApiPath, Query, Auth),
|
||||||
|
@ -346,7 +346,13 @@ call_lookup_api(ClientId, Path, Action) ->
|
||||||
Response.
|
Response.
|
||||||
|
|
||||||
call_send_api(ClientId, Cmd, Query) ->
|
call_send_api(ClientId, Cmd, Query) ->
|
||||||
ApiPath = emqx_mgmt_api_test_util:api_path(["gateway/lwm2m/clients", ClientId, Cmd]),
|
call_send_api(ClientId, Cmd, Query, "gateways/lwm2m/clients").
|
||||||
|
|
||||||
|
call_deprecated_send_api(ClientId, Cmd, Query) ->
|
||||||
|
call_send_api(ClientId, Cmd, Query, "gateway/lwm2m/clients").
|
||||||
|
|
||||||
|
call_send_api(ClientId, Cmd, Query, API) ->
|
||||||
|
ApiPath = emqx_mgmt_api_test_util:api_path([API, ClientId, Cmd]),
|
||||||
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
Auth = emqx_mgmt_api_test_util:auth_header_(),
|
||||||
{ok, Response} = emqx_mgmt_api_test_util:request_api(post, ApiPath, Query, Auth),
|
{ok, Response} = emqx_mgmt_api_test_util:request_api(post, ApiPath, Query, Auth),
|
||||||
?LOGT("rest api response:~ts~n", [Response]),
|
?LOGT("rest api response:~ts~n", [Response]),
|
||||||
|
|
|
@ -2198,15 +2198,15 @@ t_clients_api(_) ->
|
||||||
send_connect_msg(Socket, ClientId),
|
send_connect_msg(Socket, ClientId),
|
||||||
?assertEqual(<<3, ?SN_CONNACK, 0>>, receive_response(Socket)),
|
?assertEqual(<<3, ?SN_CONNACK, 0>>, receive_response(Socket)),
|
||||||
%% list
|
%% list
|
||||||
{200, #{data := [Client1]}} = request(get, "/gateway/mqttsn/clients"),
|
{200, #{data := [Client1]}} = request(get, "/gateways/mqttsn/clients"),
|
||||||
#{clientid := ClientId} = Client1,
|
#{clientid := ClientId} = Client1,
|
||||||
%% searching
|
%% searching
|
||||||
{200, #{data := [Client2]}} =
|
{200, #{data := [Client2]}} =
|
||||||
request(get, "/gateway/mqttsn/clients", [{<<"clientid">>, ClientId}]),
|
request(get, "/gateways/mqttsn/clients", [{<<"clientid">>, ClientId}]),
|
||||||
{200, #{data := [Client3]}} =
|
{200, #{data := [Client3]}} =
|
||||||
request(
|
request(
|
||||||
get,
|
get,
|
||||||
"/gateway/mqttsn/clients",
|
"/gateways/mqttsn/clients",
|
||||||
[
|
[
|
||||||
{<<"like_clientid">>, <<"test1">>},
|
{<<"like_clientid">>, <<"test1">>},
|
||||||
{<<"proto_ver">>, <<"1.2">>},
|
{<<"proto_ver">>, <<"1.2">>},
|
||||||
|
@ -2218,21 +2218,21 @@ t_clients_api(_) ->
|
||||||
),
|
),
|
||||||
%% lookup
|
%% lookup
|
||||||
{200, Client4} =
|
{200, Client4} =
|
||||||
request(get, "/gateway/mqttsn/clients/client_id_test1"),
|
request(get, "/gateways/mqttsn/clients/client_id_test1"),
|
||||||
%% assert
|
%% assert
|
||||||
Client1 = Client2 = Client3 = Client4,
|
Client1 = Client2 = Client3 = Client4,
|
||||||
%% kickout
|
%% kickout
|
||||||
{204, _} =
|
{204, _} =
|
||||||
request(delete, "/gateway/mqttsn/clients/client_id_test1"),
|
request(delete, "/gateways/mqttsn/clients/client_id_test1"),
|
||||||
timer:sleep(100),
|
timer:sleep(100),
|
||||||
{200, #{data := []}} = request(get, "/gateway/mqttsn/clients"),
|
{200, #{data := []}} = request(get, "/gateways/mqttsn/clients"),
|
||||||
|
|
||||||
send_disconnect_msg(Socket, undefined),
|
send_disconnect_msg(Socket, undefined),
|
||||||
gen_udp:close(Socket).
|
gen_udp:close(Socket).
|
||||||
|
|
||||||
t_clients_subscription_api(_) ->
|
t_clients_subscription_api(_) ->
|
||||||
ClientId = <<"client_id_test1">>,
|
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]),
|
{ok, Socket} = gen_udp:open(0, [binary]),
|
||||||
send_connect_msg(Socket, ClientId),
|
send_connect_msg(Socket, ClientId),
|
||||||
?assertEqual(<<3, ?SN_CONNACK, 0>>, receive_response(Socket)),
|
?assertEqual(<<3, ?SN_CONNACK, 0>>, receive_response(Socket)),
|
||||||
|
|
|
@ -721,12 +721,12 @@ t_rest_clienit_info(_) ->
|
||||||
_, _} = parse(Data),
|
_, _} = parse(Data),
|
||||||
|
|
||||||
%% client lists
|
%% client lists
|
||||||
{200, Clients} = request(get, "/gateway/stomp/clients"),
|
{200, Clients} = request(get, "/gateways/stomp/clients"),
|
||||||
?assertEqual(1, length(maps:get(data, Clients))),
|
?assertEqual(1, length(maps:get(data, Clients))),
|
||||||
StompClient = lists:nth(1, maps:get(data, Clients)),
|
StompClient = lists:nth(1, maps:get(data, Clients)),
|
||||||
ClientId = maps:get(clientid, StompClient),
|
ClientId = maps:get(clientid, StompClient),
|
||||||
ClientPath =
|
ClientPath =
|
||||||
"/gateway/stomp/clients/" ++
|
"/gateways/stomp/clients/" ++
|
||||||
binary_to_list(ClientId),
|
binary_to_list(ClientId),
|
||||||
{200, StompClient1} = request(get, ClientPath),
|
{200, StompClient1} = request(get, ClientPath),
|
||||||
?assertEqual(StompClient, StompClient1),
|
?assertEqual(StompClient, StompClient1),
|
||||||
|
@ -811,7 +811,7 @@ t_rest_clienit_info(_) ->
|
||||||
% sync
|
% sync
|
||||||
ignored = gen_server:call(emqx_cm, ignore, infinity),
|
ignored = gen_server:call(emqx_cm, ignore, infinity),
|
||||||
ok = emqx_pool:flush_async_tasks(),
|
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)))
|
?assertEqual(0, length(maps:get(data, Clients2)))
|
||||||
end).
|
end).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue