summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Klishin <michael@clojurewerkz.org>2017-06-29 01:09:05 +0300
committerMichael Klishin <michael@clojurewerkz.org>2017-06-29 01:09:05 +0300
commit5a9c1af55537c1f42f120bf410c09c7331164e3e (patch)
treed2aa0aecbf0a7518d5738b5685a4826e9d4b22cf /test
parentc599c190bfe936e25ec3e93e6e53fe77ee075893 (diff)
parenta5cfa9dba58ae6d31c1444ad535ba6e3d256d236 (diff)
downloadrabbitmq-server-git-5a9c1af55537c1f42f120bf410c09c7331164e3e.tar.gz
Merge branch 'master' into rabbitmq-server-1246-master
Diffstat (limited to 'test')
-rw-r--r--test/rabbit_dummy_protocol_connection_info.erl28
-rw-r--r--test/term_to_binary_compat_prop_SUITE.erl33
-rw-r--r--test/unit_SUITE.erl56
-rw-r--r--test/unit_inbroker_parallel_SUITE.erl20
4 files changed, 106 insertions, 31 deletions
diff --git a/test/rabbit_dummy_protocol_connection_info.erl b/test/rabbit_dummy_protocol_connection_info.erl
new file mode 100644
index 0000000000..3da963e057
--- /dev/null
+++ b/test/rabbit_dummy_protocol_connection_info.erl
@@ -0,0 +1,28 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is GoPivotal, Inc.
+%% Copyright (c) 2017 Pivotal Software, Inc. All rights reserved.
+%%
+
+%% Dummy module to test rabbit_direct:extract_extra_auth_props
+
+-module(rabbit_dummy_protocol_connection_info).
+
+%% API
+-export([additional_authn_params/4]).
+
+additional_authn_params(_Creds, _VHost, Pid, _Infos) ->
+ case Pid of
+ -1 -> throw(error);
+ _ -> [{client_id, <<"DummyClientId">>}]
+ end.
diff --git a/test/term_to_binary_compat_prop_SUITE.erl b/test/term_to_binary_compat_prop_SUITE.erl
index 69aa63433d..ba5069860a 100644
--- a/test/term_to_binary_compat_prop_SUITE.erl
+++ b/test/term_to_binary_compat_prop_SUITE.erl
@@ -27,7 +27,7 @@
all() ->
[
- pre_3_6_11_works,
+ ensure_term_to_binary_defaults_to_version_1,
term_to_binary_latin_atom,
queue_name_to_binary
].
@@ -47,19 +47,32 @@ end_per_suite(Config) ->
init_per_testcase(Testcase, Config) ->
rabbit_ct_helpers:testcase_started(Config, Testcase).
-%% If this test fails - the erlang version is not supported in
-%% RabbitMQ-3.6.10 and earlier.
-pre_3_6_11_works(Config) ->
- Property = fun () -> prop_pre_3_6_11_works(Config) end,
- rabbit_ct_proper_helpers:run_proper(Property, [],
- ?ITERATIONS_TO_RUN_UNTIL_CONFIDENT).
-
-prop_pre_3_6_11_works(_Config) ->
+%% R16B03 defaults term_to_binary version to 0, this test would always fail
+ensure_term_to_binary_defaults_to_version_1(Config) ->
+ CurrentERTS = erlang:system_info(version),
+ MinimumTestedERTS = "6.0",
+ case rabbit_misc:version_compare(CurrentERTS, MinimumTestedERTS, gte) of
+ true ->
+ Property = fun () ->
+ prop_ensure_term_to_binary_defaults_to_version_1(Config)
+ end,
+ rabbit_ct_proper_helpers:run_proper(
+ Property, [],
+ ?ITERATIONS_TO_RUN_UNTIL_CONFIDENT);
+ false ->
+ ct:pal(
+ ?LOW_IMPORTANCE,
+ "This test require ERTS ~p or above, running on ~p~n"
+ "Skipping test...",
+ [MinimumTestedERTS, CurrentERTS])
+ end.
+
+prop_ensure_term_to_binary_defaults_to_version_1(_Config) ->
?FORALL(Term, any(),
begin
Current = term_to_binary(Term),
Compat = term_to_binary_compat:term_to_binary_1(Term),
- binary_to_term(Current) =:= binary_to_term(Compat)
+ Current =:= Compat
end).
term_to_binary_latin_atom(Config) ->
diff --git a/test/unit_SUITE.erl b/test/unit_SUITE.erl
index 3e92158595..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,
@@ -49,6 +50,7 @@ groups() ->
pmerge,
plmerge,
priority_queue,
+ rabbit_direct_extract_extra_auth_props,
{resource_monitor, [parallel], [
parse_information_unit
]},
@@ -464,7 +466,25 @@ rabbitmqctl_encode_encrypt_decrypt(Secret) ->
)
.
-
+rabbit_direct_extract_extra_auth_props(_Config) ->
+ % no protocol to extract
+ [] = rabbit_direct:extract_extra_auth_props(
+ {<<"guest">>, <<"guest">>}, <<"/">>, 1,
+ [{name,<<"127.0.0.1:52366 -> 127.0.0.1:1883">>}]),
+ % protocol to extract, but no module to call
+ [] = rabbit_direct:extract_extra_auth_props(
+ {<<"guest">>, <<"guest">>}, <<"/">>, 1,
+ [{protocol, {'PROTOCOL_WITHOUT_MODULE', "1.0"}}]),
+ % see rabbit_dummy_protocol_connection_info module
+ % protocol to extract, module that returns a client ID
+ [{client_id, <<"DummyClientId">>}] = rabbit_direct:extract_extra_auth_props(
+ {<<"guest">>, <<"guest">>}, <<"/">>, 1,
+ [{protocol, {'DUMMY_PROTOCOL', "1.0"}}]),
+ % protocol to extract, but error thrown in module
+ [] = rabbit_direct:extract_extra_auth_props(
+ {<<"guest">>, <<"guest">>}, <<"/">>, -1,
+ [{protocol, {'DUMMY_PROTOCOL', "1.0"}}]),
+ ok.
%% -------------------------------------------------------------------
%% pg_local.
@@ -1002,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.
diff --git a/test/unit_inbroker_parallel_SUITE.erl b/test/unit_inbroker_parallel_SUITE.erl
index 9c274ab525..453f4b2e72 100644
--- a/test/unit_inbroker_parallel_SUITE.erl
+++ b/test/unit_inbroker_parallel_SUITE.erl
@@ -337,26 +337,6 @@ override_group_leader() ->
{group_leader, Leader} = erlang:process_info(whereis(rabbit), group_leader),
erlang:group_leader(Leader, self()).
-empty_files(Files) ->
- [case file:read_file_info(File) of
- {ok, FInfo} -> FInfo#file_info.size == 0;
- Error -> Error
- end || File <- Files].
-
-non_empty_files(Files) ->
- [case EmptyFile of
- {error, Reason} -> {error, Reason};
- _ -> not(EmptyFile)
- end || EmptyFile <- empty_files(Files)].
-
-test_logs_working(MainLogFile, SaslLogFile) ->
- ok = rabbit_log:error("Log a test message~n"),
- ok = error_logger:error_report(crash_report, [fake_crash_report, ?MODULE]),
- %% give the error loggers some time to catch up
- timer:sleep(100),
- [true, true] = non_empty_files([MainLogFile, SaslLogFile]),
- ok.
-
set_permissions(Path, Mode) ->
case file:read_file_info(Path) of
{ok, FInfo} -> file:write_file_info(