summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Klishin <mklishin@pivotal.io>2018-01-05 16:22:43 +0300
committerMichael Klishin <mklishin@pivotal.io>2018-01-06 14:05:52 +0300
commit1aa3065cf8ad1c7ddbd870e3d362b649a652028b (patch)
tree0412d77774356ab1a63665040026f2cacd771220 /test
parentd1e52956bb415fd79ee19347504a10640213d829 (diff)
downloadrabbitmq-server-git-1aa3065cf8ad1c7ddbd870e3d362b649a652028b.tar.gz
Prevent internal authN backend from accepting blank passwords
Passwordless users were never meant to be used this way. Since the EXTERNAL authentication mechanism won't use this backend at all, this is a reasonable safeguard to put in place. [#153435857] (cherry picked from commit bd40475057446c841c9531515d452df532841ec0)
Diffstat (limited to 'test')
-rw-r--r--test/unit_inbroker_parallel_SUITE.erl59
1 files changed, 58 insertions, 1 deletions
diff --git a/test/unit_inbroker_parallel_SUITE.erl b/test/unit_inbroker_parallel_SUITE.erl
index 89fd8fc659..c4c8740b7a 100644
--- a/test/unit_inbroker_parallel_SUITE.erl
+++ b/test/unit_inbroker_parallel_SUITE.erl
@@ -19,6 +19,7 @@
-include_lib("common_test/include/ct.hrl").
-include_lib("kernel/include/file.hrl").
-include_lib("amqp_client/include/amqp_client.hrl").
+-include_lib("eunit/include/eunit.hrl").
-compile(export_all).
@@ -49,6 +50,10 @@ groups() ->
password_hashing,
change_password
]},
+ {auth_backend_internal, [parallel], [
+ login_with_credentials_but_no_password,
+ login_of_passwordless_user
+ ]},
set_disk_free_limit_command,
set_vm_memory_high_watermark_command,
topic_matching,
@@ -517,6 +522,58 @@ change_password1(_Config) ->
UserName, [{password, Password}]),
passed.
+
+%% -------------------------------------------------------------------
+%% rabbit_auth_backend_internal
+%% -------------------------------------------------------------------
+
+login_with_credentials_but_no_password(Config) ->
+ passed = rabbit_ct_broker_helpers:rpc(Config, 0,
+ ?MODULE, login_with_credentials_but_no_password1, [Config]).
+
+login_with_credentials_but_no_password1(_Config) ->
+ Username = <<"login_with_credentials_but_no_password-user">>,
+ Password = <<"login_with_credentials_but_no_password-password">>,
+ ok = rabbit_auth_backend_internal:add_user(Username, Password, <<"acting-user">>),
+
+ try
+ rabbit_auth_backend_internal:user_login_authentication(Username,
+ [{key, <<"value">>}]),
+ ?assert(false)
+ catch exit:{unknown_auth_props, Username, [{key, <<"value">>}]} ->
+ ok
+ end,
+
+ ok = rabbit_auth_backend_internal:delete_user(Username, <<"acting-user">>),
+
+ passed.
+
+%% passwordless users are not supposed to be used with
+%% this backend (and PLAIN authentication mechanism in general)
+login_of_passwordless_user(Config) ->
+ passed = rabbit_ct_broker_helpers:rpc(Config, 0,
+ ?MODULE, login_of_passwordless_user1, [Config]).
+
+login_of_passwordless_user1(_Config) ->
+ Username = <<"login_of_passwordless_user-user">>,
+ Password = <<"">>,
+ ok = rabbit_auth_backend_internal:add_user(Username, Password, <<"acting-user">>),
+
+ ?assertMatch(
+ {refused, _Message, [Username]},
+ rabbit_auth_backend_internal:user_login_authentication(Username,
+ [{password, <<"">>}])),
+
+ ?assertMatch(
+ {refused, _Format, [Username]},
+ rabbit_auth_backend_internal:user_login_authentication(Username,
+ [{password, ""}])),
+
+ ok = rabbit_auth_backend_internal:delete_user(Username, <<"acting-user">>),
+
+ passed.
+
+
%% -------------------------------------------------------------------
%% rabbitmqctl.
%% -------------------------------------------------------------------
@@ -1220,4 +1277,4 @@ expand_options(As, Bs) ->
flush() ->
receive _ -> flush()
after 10 -> ok
- end. \ No newline at end of file
+ end.