Skip to content

Commit 303fb29

Browse files
committed
Implement LDAP credentials validation via HTTP API
See discussion #14244 These changes will allow a user to make an HTTP API request to... ``` /api/ldap/validate/bind/USER ``` ...with an appropriate JSON body, and the plugin will attempt a connection to the specified LDAP server using the provided credentials. This allows validation that a connection can be made to an LDAP server from a RabbitMQ cluster environment.
1 parent c7f6cad commit 303fb29

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

deps/rabbitmq_auth_backend_ldap/test/system_SUITE.erl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
-include_lib("common_test/include/ct.hrl").
1212
-include_lib("eunit/include/eunit.hrl").
1313
-include_lib("amqp_client/include/amqp_client.hrl").
14+
-include_lib("rabbitmq_ct_helpers/include/rabbit_mgmt_test.hrl").
15+
16+
-import(rabbit_mgmt_test_util, [http_put/4]).
1417

1518
-define(ALICE_NAME, "Alice").
1619
-define(BOB_NAME, "Bob").
@@ -109,7 +112,8 @@ groups() ->
109112
topic_authorisation_publishing_ldap_only,
110113
topic_authorisation_consumption,
111114
match_bidirectional,
112-
match_bidirectional_gh_100
115+
match_bidirectional_gh_100,
116+
validate_ldap_configuration_via_api
113117
],
114118
[
115119
{non_parallel_tests, [], Tests
@@ -206,6 +210,10 @@ end_internal(Config) ->
206210
ok = control_action(Config, delete_user, [?BOB_NAME]),
207211
ok = control_action(Config, delete_user, [?PETER_NAME]).
208212

213+
214+
init_per_testcase(validate_ldap_configuration_via_api = Testcase, Config) ->
215+
_ = application:start(inets),
216+
rabbit_ct_helpers:testcase_started(Config, Testcase);
209217
init_per_testcase(Testcase, Config)
210218
when Testcase == ldap_and_internal;
211219
Testcase == internal_followed_ldap_and_internal ->
@@ -229,6 +237,9 @@ init_per_testcase(Testcase, Config)
229237
init_per_testcase(Testcase, Config) ->
230238
rabbit_ct_helpers:testcase_started(Config, Testcase).
231239

240+
end_per_testcase(validate_ldap_configuration_via_api = Testcase, Config) ->
241+
_ = application:stop(inets),
242+
rabbit_ct_helpers:testcase_finished(Config, Testcase);
232243
end_per_testcase(Testcase, Config)
233244
when Testcase == ldap_and_internal;
234245
Testcase == internal_followed_ldap_and_internal ->
@@ -270,6 +281,14 @@ end_per_testcase(Testcase, Config) ->
270281
%% Testsuite cases
271282
%% -------------------------------------------------------------------
272283

284+
validate_ldap_configuration_via_api(Config) ->
285+
LdapPort = ?config(ldap_port, Config),
286+
http_put(Config, io_lib:format("/ldap/validate/bind/~ts", [<<?ALICE_NAME>>]),
287+
#{
288+
'servers' => [<<"localhost">>],
289+
'port' => LdapPort
290+
}, ?OK).
291+
273292
purge_connection(Config) ->
274293
{ok, _} = rabbit_ct_broker_helpers:rpc(Config, 0,
275294
rabbit_auth_backend_ldap,

0 commit comments

Comments
 (0)