summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Klishin <mklishin@pivotal.io>2017-06-26 22:01:24 +0300
committerMichael Klishin <mklishin@pivotal.io>2017-06-26 22:01:24 +0300
commit5f2ef64a751ee18f4e3d4b115f0a4331e453b733 (patch)
tree0464aa67e07b3a7cec811a658c648104fbfade19 /test
parent9d7b14e491443292196af87d3c4dcd2491c20ac5 (diff)
parent6381a2ed76c510329fabd0510d78018a93403097 (diff)
downloadrabbitmq-server-git-5f2ef64a751ee18f4e3d4b115f0a4331e453b733.tar.gz
Merge branch 'master' into rabbitmq-mqtt-139
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 b4813fe801..b3ad7e4fc3 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,
@@ -1021,3 +1022,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.