fix(emqx_rule_api_schema): add rule events schema
This commit is contained in:
parent
4791c64b73
commit
ccc134d061
|
@ -73,6 +73,8 @@ fields("rule_test") ->
|
||||||
, ref("ctx_dropped")
|
, ref("ctx_dropped")
|
||||||
, ref("ctx_connected")
|
, ref("ctx_connected")
|
||||||
, ref("ctx_disconnected")
|
, ref("ctx_disconnected")
|
||||||
|
, ref("ctx_connack")
|
||||||
|
, ref("ctx_check_authz_complete")
|
||||||
, ref("ctx_bridge_mqtt")
|
, ref("ctx_bridge_mqtt")
|
||||||
]),
|
]),
|
||||||
#{desc => "The context of the event for testing",
|
#{desc => "The context of the event for testing",
|
||||||
|
@ -208,6 +210,31 @@ fields("ctx_disconnected") ->
|
||||||
desc => "The Time that this Client is Disconnected"})}
|
desc => "The Time that this Client is Disconnected"})}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
fields("ctx_connack") ->
|
||||||
|
[ {"event_type", sc(client_connack, #{desc => "Event Type", required => true})}
|
||||||
|
, {"reason_code", sc(binary(), #{desc => "The reason code"})}
|
||||||
|
, {"clientid", sc(binary(), #{desc => "The Client ID"})}
|
||||||
|
, {"clean_start", sc(boolean(), #{desc => "Clean Start", default => true})}
|
||||||
|
, {"username", sc(binary(), #{desc => "The User Name"})}
|
||||||
|
, {"peername", sc(binary(), #{desc => "The IP Address and Port of the Peer Client"})}
|
||||||
|
, {"sockname", sc(binary(), #{desc => "The IP Address and Port of the Local Listener"})}
|
||||||
|
, {"proto_name", sc(binary(), #{desc => "Protocol Name"})}
|
||||||
|
, {"proto_ver", sc(binary(), #{desc => "Protocol Version"})}
|
||||||
|
, {"keepalive", sc(integer(), #{desc => "KeepAlive"})}
|
||||||
|
, {"expiry_interval", sc(integer(), #{desc => "Expiry Interval"})}
|
||||||
|
, {"connected_at", sc(integer(), #{
|
||||||
|
desc => "The Time that this Client is Connected"})}
|
||||||
|
];
|
||||||
|
fields("ctx_check_authz_complete") ->
|
||||||
|
[ {"event_type", sc(client_check_authz_complete, #{desc => "Event Type", required => true})}
|
||||||
|
, {"clientid", sc(binary(), #{desc => "The Client ID"})}
|
||||||
|
, {"username", sc(binary(), #{desc => "The User Name"})}
|
||||||
|
, {"peerhost", sc(binary(), #{desc => "The IP Address of the Peer Client"})}
|
||||||
|
, {"topic", sc(binary(), #{desc => "Message Topic"})}
|
||||||
|
, {"action", sc(binary(), #{desc => "Publish or Subscribe"})}
|
||||||
|
, {"authz_source", sc(binary(), #{desc => "Cache, Plugs or Default"})}
|
||||||
|
, {"result", sc(binary(), #{desc => "Allow or Deny"})}
|
||||||
|
];
|
||||||
fields("ctx_bridge_mqtt") ->
|
fields("ctx_bridge_mqtt") ->
|
||||||
[ {"event_type", sc('$bridges/mqtt:*', #{desc => "Event Type", required => true})}
|
[ {"event_type", sc('$bridges/mqtt:*', #{desc => "Event Type", required => true})}
|
||||||
, {"id", sc(binary(), #{desc => "Message ID"})}
|
, {"id", sc(binary(), #{desc => "Message ID"})}
|
||||||
|
|
|
@ -576,16 +576,16 @@ test_columns('client.disconnected') ->
|
||||||
, {<<"reason">>, [<<"normal">>, <<"the reason for shutdown">>]}
|
, {<<"reason">>, [<<"normal">>, <<"the reason for shutdown">>]}
|
||||||
];
|
];
|
||||||
test_columns('client.connack') ->
|
test_columns('client.connack') ->
|
||||||
[ {<<"clientid">>, <<"c_emqx">>}
|
[ {<<"clientid">>, [<<"c_emqx">>, <<"the clientid if the client">>]}
|
||||||
, {<<"username">>, <<"u_emqx">>}
|
, {<<"username">>, [<<"u_emqx">>, <<"the username if the client">>]}
|
||||||
, {<<"reason_code">>, <<"sucess">>}
|
, {<<"reason_code">>, [<<"sucess">>, <<"the reason code">>]}
|
||||||
];
|
];
|
||||||
test_columns('client.check_authz_complete') ->
|
test_columns('client.check_authz_complete') ->
|
||||||
[ {<<"clientid">>, <<"c_emqx">>}
|
[ {<<"clientid">>, [<<"c_emqx">>, <<"the clientid if the client">>]}
|
||||||
, {<<"username">>, <<"u_emqx">>}
|
, {<<"username">>, [<<"u_emqx">>, <<"the username if the client">>]}
|
||||||
, {<<"topic">>, <<"t/1">>}
|
, {<<"topic">>, [<<"t/1">>, <<"the topic of the MQTT message">>]}
|
||||||
, {<<"action">>, <<"publish">>}
|
, {<<"action">>, [<<"publish">>, <<"the action of publish or subscribe">>]}
|
||||||
, {<<"result">>, <<"allow">>}
|
, {<<"result">>, [<<"allow">>,<<"the authz check complete result">>]}
|
||||||
];
|
];
|
||||||
test_columns('session.unsubscribed') ->
|
test_columns('session.unsubscribed') ->
|
||||||
test_columns('session.subscribed');
|
test_columns('session.subscribed');
|
||||||
|
|
|
@ -1703,7 +1703,6 @@ verify_event_fields('client.check_authz_complete', Fields) ->
|
||||||
?assert(lists:member(ClientId, [<<"c_event">>, <<"c_event2">>])),
|
?assert(lists:member(ClientId, [<<"c_event">>, <<"c_event2">>])),
|
||||||
?assert(lists:member(Username, [<<"u_event">>, <<"u_event2">>])).
|
?assert(lists:member(Username, [<<"u_event">>, <<"u_event2">>])).
|
||||||
|
|
||||||
|
|
||||||
verify_peername(PeerName) ->
|
verify_peername(PeerName) ->
|
||||||
case string:split(PeerName, ":") of
|
case string:split(PeerName, ":") of
|
||||||
[IPAddrS, PortS] ->
|
[IPAddrS, PortS] ->
|
||||||
|
|
Loading…
Reference in New Issue