|
19 | 19 | -include_lib("common_test/include/ct.hrl").
|
20 | 20 | -include_lib("kernel/include/file.hrl").
|
21 | 21 | -include_lib("amqp_client/include/amqp_client.hrl").
|
| 22 | +-include_lib("eunit/include/eunit.hrl"). |
22 | 23 |
|
23 | 24 | -compile(export_all).
|
24 | 25 |
|
@@ -47,6 +48,10 @@ groups() ->
|
47 | 48 | password_hashing,
|
48 | 49 | change_password
|
49 | 50 | ]},
|
| 51 | + {auth_backend_internal, [parallel], [ |
| 52 | + login_with_credentials_but_no_password, |
| 53 | + login_of_passwordless_user |
| 54 | + ]}, |
50 | 55 | {policy_validation, [parallel, {repeat, 20}], [
|
51 | 56 | ha_policy_validation,
|
52 | 57 | policy_validation,
|
@@ -684,9 +689,12 @@ user_management1(_Config) ->
|
684 | 689 | %% user authentication
|
685 | 690 | ok = control_action(authenticate_user,
|
686 | 691 | ["user_management-user", "user_management-newpassword"]),
|
687 |
| - {refused, _User, _Format, _Params} = |
| 692 | + ?assertMatch({refused, _User, _Format, _Params}, |
688 | 693 | control_action(authenticate_user,
|
689 |
| - ["user_management-user", "user_management-password"]), |
| 694 | + ["user_management-user", "user_management-password"])), |
| 695 | + ?assertMatch({refused, _User, _Format, _Params}, |
| 696 | + control_action(authenticate_user, |
| 697 | + ["user_management-user", ""])), |
690 | 698 |
|
691 | 699 | %% vhost creation
|
692 | 700 | ok = control_action(add_vhost,
|
@@ -748,6 +756,60 @@ user_management1(_Config) ->
|
748 | 756 |
|
749 | 757 | passed.
|
750 | 758 |
|
| 759 | + |
| 760 | +%% ------------------------------------------------------------------- |
| 761 | +%% rabbit_auth_backend_internal |
| 762 | +%% ------------------------------------------------------------------- |
| 763 | + |
| 764 | +login_with_credentials_but_no_password(Config) -> |
| 765 | + passed = rabbit_ct_broker_helpers:rpc(Config, 0, |
| 766 | + ?MODULE, login_with_credentials_but_no_password1, [Config]). |
| 767 | + |
| 768 | +login_with_credentials_but_no_password1(_Config) -> |
| 769 | + Username = "login_with_credentials_but_no_password-user", |
| 770 | + Password = "login_with_credentials_but_no_password-password", |
| 771 | + ok = control_action(add_user, [Username, Password]), |
| 772 | + |
| 773 | + try |
| 774 | + rabbit_auth_backend_internal:user_login_authentication(Username, |
| 775 | + [{key, <<"value">>}]), |
| 776 | + ?assert(false) |
| 777 | + catch exit:{unknown_auth_props, Username, [{key, <<"value">>}]} -> |
| 778 | + ok |
| 779 | + end, |
| 780 | + |
| 781 | + ok = control_action(delete_user, |
| 782 | + [Username]), |
| 783 | + |
| 784 | + passed. |
| 785 | + |
| 786 | +%% passwordless users are not supposed to be used with |
| 787 | +%% this backend (and PLAIN authentication mechanism in general) |
| 788 | +login_of_passwordless_user(Config) -> |
| 789 | + passed = rabbit_ct_broker_helpers:rpc(Config, 0, |
| 790 | + ?MODULE, login_of_passwordless_user1, [Config]). |
| 791 | + |
| 792 | +login_of_passwordless_user1(_Config) -> |
| 793 | + Username = "login_of_passwordless_user-user", |
| 794 | + Password = "", |
| 795 | + ok = control_action(add_user, [Username, Password]), |
| 796 | + |
| 797 | + ?assertMatch( |
| 798 | + {refused, _Message, [Username]}, |
| 799 | + rabbit_auth_backend_internal:user_login_authentication(Username, |
| 800 | + [{password, <<"">>}])), |
| 801 | + |
| 802 | + ?assertMatch( |
| 803 | + {refused, _Format, [Username]}, |
| 804 | + rabbit_auth_backend_internal:user_login_authentication(Username, |
| 805 | + [{password, ""}])), |
| 806 | + |
| 807 | + ok = control_action(delete_user, |
| 808 | + [Username]), |
| 809 | + |
| 810 | + passed. |
| 811 | + |
| 812 | + |
751 | 813 | runtime_parameters(Config) ->
|
752 | 814 | passed = rabbit_ct_broker_helpers:rpc(Config, 0,
|
753 | 815 | ?MODULE, runtime_parameters1, [Config]).
|
|
0 commit comments