From 77895f2555e944712d5409ddf81d0b21ac8faded Mon Sep 17 00:00:00 2001 From: Ilya Averyanov Date: Fri, 7 Jul 2023 16:20:55 +0300 Subject: [PATCH] feat(authz): fix typos and style for Retain & QoS authz feature Co-authored-by: Thales Macedo Garitezi --- Makefile | 8 ++++---- apps/emqx/src/emqx_channel.erl | 2 +- apps/emqx_authz/include/emqx_authz.hrl | 24 ++++++++++++------------ apps/emqx_authz/src/emqx_authz.erl | 2 +- apps/emqx_authz/src/emqx_authz_rule.erl | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 7362cdac4..8c5eb3048 100644 --- a/Makefile +++ b/Makefile @@ -130,14 +130,14 @@ $(foreach app,$(APPS),$(eval $(call gen-app-prop-target,$(app)))) ct-suite: $(REBAR) merge-config clean-test-cluster-config ifneq ($(TESTCASE),) ifneq ($(GROUP),) - $(REBAR) ct -c -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) --case $(TESTCASE) --group $(GROUP) + $(REBAR) ct -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) --case $(TESTCASE) --group $(GROUP) else - $(REBAR) ct -c -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) --case $(TESTCASE) + $(REBAR) ct -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) --case $(TESTCASE) endif else ifneq ($(GROUP),) - $(REBAR) ct -c -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) --group $(GROUP) + $(REBAR) ct -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) --group $(GROUP) else - $(REBAR) ct -c -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) + $(REBAR) ct -v --readable=$(CT_READABLE) --name $(CT_NODE_NAME) --suite $(SUITE) endif .PHONY: cover diff --git a/apps/emqx/src/emqx_channel.erl b/apps/emqx/src/emqx_channel.erl index 01af1a7b5..5e594d35f 100644 --- a/apps/emqx/src/emqx_channel.erl +++ b/apps/emqx/src/emqx_channel.erl @@ -1840,7 +1840,7 @@ check_pub_alias(_Packet, _Channel) -> ok. %%-------------------------------------------------------------------- -%% Athorization action +%% Authorization action authz_action(#mqtt_packet{ header = #mqtt_packet_header{qos = QoS, retain = Retain}, variable = #mqtt_packet_publish{} diff --git a/apps/emqx_authz/include/emqx_authz.hrl b/apps/emqx_authz/include/emqx_authz.hrl index 8676da134..5cab24fab 100644 --- a/apps/emqx_authz/include/emqx_authz.hrl +++ b/apps/emqx_authz/include/emqx_authz.hrl @@ -49,12 +49,12 @@ username => user1, rules => [ #{ - topic => <<"test/toopic/1">>, + topic => <<"test/topic/1">>, permission => <<"allow">>, action => <<"publish">> }, #{ - topic => <<"test/toopic/2">>, + topic => <<"test/topic/2">>, permission => <<"allow">>, action => <<"subscribe">> }, @@ -64,14 +64,14 @@ action => <<"all">> }, #{ - topic => <<"test/toopic/3">>, + topic => <<"test/topic/3">>, permission => <<"allow">>, action => <<"publish">>, qos => [<<"1">>], retain => <<"true">> }, #{ - topic => <<"test/toopic/4">>, + topic => <<"test/topic/4">>, permission => <<"allow">>, action => <<"publish">>, qos => [<<"0">>, <<"1">>, <<"2">>], @@ -83,12 +83,12 @@ clientid => client1, rules => [ #{ - topic => <<"test/toopic/1">>, + topic => <<"test/topic/1">>, permission => <<"allow">>, action => <<"publish">> }, #{ - topic => <<"test/toopic/2">>, + topic => <<"test/topic/2">>, permission => <<"allow">>, action => <<"subscribe">> }, @@ -98,14 +98,14 @@ action => <<"all">> }, #{ - topic => <<"test/toopic/3">>, + topic => <<"test/topic/3">>, permission => <<"allow">>, action => <<"publish">>, qos => [<<"1">>], retain => <<"true">> }, #{ - topic => <<"test/toopic/4">>, + topic => <<"test/topic/4">>, permission => <<"allow">>, action => <<"publish">>, qos => [<<"0">>, <<"1">>, <<"2">>], @@ -116,12 +116,12 @@ -define(ALL_RULES_EXAMPLE, #{ rules => [ #{ - topic => <<"test/toopic/1">>, + topic => <<"test/topic/1">>, permission => <<"allow">>, action => <<"publish">> }, #{ - topic => <<"test/toopic/2">>, + topic => <<"test/topic/2">>, permission => <<"allow">>, action => <<"subscribe">> }, @@ -131,14 +131,14 @@ action => <<"all">> }, #{ - topic => <<"test/toopic/3">>, + topic => <<"test/topic/3">>, permission => <<"allow">>, action => <<"publish">>, qos => [<<"1">>], retain => <<"true">> }, #{ - topic => <<"test/toopic/4">>, + topic => <<"test/topic/4">>, permission => <<"allow">>, action => <<"publish">>, qos => [<<"0">>, <<"1">>, <<"2">>], diff --git a/apps/emqx_authz/src/emqx_authz.erl b/apps/emqx_authz/src/emqx_authz.erl index 830db21b7..0419bcf72 100644 --- a/apps/emqx_authz/src/emqx_authz.erl +++ b/apps/emqx_authz/src/emqx_authz.erl @@ -525,7 +525,7 @@ read_acl_file(#{<<"path">> := Path} = Source) -> maps:remove(<<"path">>, Source#{<<"rules">> => Rules}). %%------------------------------------------------------------------------------ -%% Extednded Features +%% Extended Features %%------------------------------------------------------------------------------ -define(DEFAULT_RICH_ACTIONS, true). diff --git a/apps/emqx_authz/src/emqx_authz_rule.erl b/apps/emqx_authz/src/emqx_authz_rule.erl index a59679a8d..6e13cac91 100644 --- a/apps/emqx_authz/src/emqx_authz_rule.erl +++ b/apps/emqx_authz/src/emqx_authz_rule.erl @@ -60,7 +60,7 @@ -type rule() :: {permission(), who_condition(), action_condition(), topic_condition()}. --type qos() :: 0..2. +-type qos() :: emqx_types:qos(). -type retain() :: boolean(). -type action() :: #{action_type := subscribe, qos := qos()}