summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit_SUITE.erl35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit_SUITE.erl b/test/unit_SUITE.erl
index 3e92158595..11af196449 100644
--- a/test/unit_SUITE.erl
+++ b/test/unit_SUITE.erl
@@ -32,6 +32,7 @@ groups() ->
[
{parallel_tests, [parallel], [
arguments_parser,
+ auth_backend_internal_expand_topic_permission,
{basic_header_handling, [parallel], [
write_table_with_invalid_existing_type,
invalid_existing_headers,
@@ -1002,3 +1003,37 @@ listing_plugins_from_multiple_directories(Config) ->
exit({wrong_plugins_list, Got})
end,
ok.
+
+auth_backend_internal_expand_topic_permission(_Config) ->
+ ExpandMap = #{<<"username">> => <<"guest">>, <<"vhost">> => <<"default">>},
+ %% simple case
+ <<"services/default/accounts/guest/notifications">> =
+ rabbit_auth_backend_internal:expand_topic_permission(
+ <<"services/{vhost}/accounts/{username}/notifications">>,
+ ExpandMap
+ ),
+ %% replace variable twice
+ <<"services/default/accounts/default/guest/notifications">> =
+ rabbit_auth_backend_internal:expand_topic_permission(
+ <<"services/{vhost}/accounts/{vhost}/{username}/notifications">>,
+ ExpandMap
+ ),
+ %% nothing to replace
+ <<"services/accounts/notifications">> =
+ rabbit_auth_backend_internal:expand_topic_permission(
+ <<"services/accounts/notifications">>,
+ ExpandMap
+ ),
+ %% the expand map isn't defined
+ <<"services/{vhost}/accounts/{username}/notifications">> =
+ rabbit_auth_backend_internal:expand_topic_permission(
+ <<"services/{vhost}/accounts/{username}/notifications">>,
+ undefined
+ ),
+ %% the expand map is empty
+ <<"services/{vhost}/accounts/{username}/notifications">> =
+ rabbit_auth_backend_internal:expand_topic_permission(
+ <<"services/{vhost}/accounts/{username}/notifications">>,
+ #{}
+ ),
+ ok.