1818 password => <<" Kocur" >>,
1919 expected_credentials => [username , password ],
2020 tags => [policymaker , monitoring ]}).
21+ -define (ALLOWED_USER_2 , #{username => <<" Ala3" >>,
22+ expected_credentials => [username ],
23+ tags => [policymaker , monitoring ]}).
2124-define (ALLOWED_USER_WITH_EXTRA_CREDENTIALS , #{username => <<" Ala2" >>,
2225 password => <<" Kocur" >>,
2326 client_id => <<" some_id" >>,
@@ -46,12 +49,14 @@ shared() ->
4649 grants_access_to_user_passing_additional_required_authprops ,
4750 grants_access_to_user_skipping_internal_authprops ,
4851 grants_access_to_user_with_credentials_in_rabbit_auth_backend_http ,
49- grants_access_to_user_with_credentials_in_rabbit_auth_backend_cache
52+ grants_access_to_user_with_credentials_in_rabbit_auth_backend_cache ,
53+ grants_access_to_ssl_user_without_a_password
5054 ].
5155
5256init_per_suite (Config ) ->
5357 rabbit_ct_helpers :run_setup_steps (Config ) ++
5458 [{allowed_user , ? ALLOWED_USER },
59+ {allowed_user_2 , ? ALLOWED_USER_2 },
5560 {allowed_user_with_extra_credentials , ? ALLOWED_USER_WITH_EXTRA_CREDENTIALS },
5661 {denied_user , ? DENIED_USER }].
5762
@@ -65,13 +70,21 @@ init_per_group(over_http, Config) ->
6570init_per_group (over_https , Config ) ->
6671 configure_http_auth_backend (" https" , Config ),
6772 {User1 , Tuple1 } = extractUserTuple (? ALLOWED_USER ),
68- {User2 , Tuple2 } = extractUserTuple (? ALLOWED_USER_WITH_EXTRA_CREDENTIALS ),
73+ {User2 , Tuple2 } = extractUserTuple (? ALLOWED_USER_2 ),
74+ {User3 , Tuple3 } = extractUserTuple (? ALLOWED_USER_WITH_EXTRA_CREDENTIALS ),
6975 CertsDir = ? config (rmq_certsdir , Config ),
70- start_https_auth_server (? AUTH_PORT , CertsDir , ? USER_PATH , #{User1 => Tuple1 , User2 => Tuple2 }),
71- Config .
76+ start_https_auth_server (? AUTH_PORT , CertsDir , ? USER_PATH , #{
77+ User1 => Tuple1 ,
78+ User3 => Tuple3 ,
79+ User2 => Tuple2 }),
80+ Config ++ [{group , over_https }].
7281
7382extractUserTuple (User ) ->
74- #{username := Username , password := Password , tags := Tags , expected_credentials := ExpectedCredentials } = User ,
83+ #{username := Username , tags := Tags , expected_credentials := ExpectedCredentials } = User ,
84+ Password = case maps :get (password , User , undefined ) of
85+ undefined -> none ;
86+ P -> P
87+ end ,
7588 {Username , {Password , Tags , ExpectedCredentials }}.
7689
7790end_per_suite (Config ) ->
@@ -91,6 +104,16 @@ grants_access_to_user(Config) ->
91104 ? assertMatch ({U , T , AuthProps },
92105 {User # auth_user .username , User # auth_user .tags , (User # auth_user .impl )()}).
93106
107+ grants_access_to_ssl_user_without_a_password (Config ) ->
108+ case ? config (group , Config ) of
109+ over_https ->
110+ #{username := U , tags := T } = ? config (allowed_user_2 , Config ),
111+ {ok , User } = rabbit_auth_backend_http :user_login_authentication (U , []),
112+ ? assertMatch ({U , T , []},
113+ {User # auth_user .username , User # auth_user .tags , (User # auth_user .impl )()});
114+ _ ->{skip , " Requires https" }
115+ end .
116+
94117denies_access_to_user (Config ) ->
95118 #{username := U , password := P } = ? config (denied_user , Config ),
96119 ? assertMatch ({refused , " Denied by the backing HTTP service" , []},
0 commit comments