Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit b311457

Browse files
committed
Add failing test for #100
1 parent a4c44ee commit b311457

File tree

3 files changed

+54
-11
lines changed

3 files changed

+54
-11
lines changed

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# vi: set ft=ruby :
33

44
Vagrant.configure(2) do |config|
5-
config.vm.box = "ubuntu/trusty64"
5+
config.vm.box = 'ubuntu/xenial64'
66
config.vm.network "forwarded_port", guest: 389, host: 3890
77
config.vm.provision "shell", inline: "sudo apt-get -y update"
88
config.vm.provision "file", source: "example", destination: "~/example"

test/rabbit_ldap_seed.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ people() ->
6060
johndoe(),
6161
alice(),
6262
peter(),
63-
carol()
63+
carol(),
64+
jimmy()
6465
].
6566

6667
groups() ->
@@ -184,6 +185,15 @@ carol() ->
184185
{"loginShell", ["/bin/bash"]},
185186
{"userPassword", ["password"]}]}.
186187

188+
% rabbitmq/rabbitmq-auth-backend-ldap#100
189+
jimmy() ->
190+
{"cn=Jimmy,ou=people,dc=rabbitmq,dc=com",
191+
[{"objectClass", ["person"]},
192+
{"cn", ["Jimmy"]},
193+
{"sn", ["Makes"]},
194+
{"userPassword", ["password"]},
195+
{"description", ["^RMQ-foobar", "^RMQ-.*$"]}]}.
196+
187197
add(H, {A, B}) ->
188198
ok = eldap:add(H, A, B).
189199

test/system_SUITE.erl

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
-define(BOB_NAME, "Bob").
2626
-define(CAROL_NAME, "Carol").
2727
-define(PETER_NAME, "Peter").
28+
-define(JIMMY_NAME, "Jimmy").
2829

2930
-define(VHOST, "test").
3031
-define(DEFAULT_LDAP_PORT, "3890").
@@ -45,6 +46,10 @@
4546
password = <<"password">>,
4647
virtual_host = <<?VHOST>>}).
4748

49+
-define(JIMMY, #amqp_params_network{username = <<?JIMMY_NAME>>,
50+
password = <<"password">>,
51+
virtual_host = <<?VHOST>>}).
52+
4853
-define(BASE_CONF_RABBIT, {rabbit, [{default_vhost, <<"test">>}]}).
4954

5055
base_conf_ldap(LdapPort, IdleTimeout, PoolSize) ->
@@ -113,7 +118,8 @@ groups() ->
113118
invalid_and_clause_ldap_only,
114119
topic_authorisation_publishing_ldap_only,
115120
topic_authorisation_consumption,
116-
match_bidirectional
121+
match_bidirectional,
122+
match_bidirectional_gh_100
117123
],
118124
[
119125
{non_parallel_tests, [], Tests
@@ -475,10 +481,8 @@ topic_authorisation_consumption1(Config) ->
475481
false = rabbit_auth_backend_ldap:check_topic_access(Alice, Resource, read, #{routing_key => <<"b.c">>}),
476482
%% user KO, routing key OK, should fail
477483
false = rabbit_auth_backend_ldap:check_topic_access(Bob, Resource, read, #{routing_key => <<"a.b.c">>}),
478-
479484
ok.
480485

481-
482486
match_bidirectional(Config) ->
483487
ok = rabbit_ct_broker_helpers:rpc(Config, 0,
484488
application, set_env, [rabbit, auth_backends, [rabbit_auth_backend_ldap]]),
@@ -500,6 +504,25 @@ match_bidirectional(Config) ->
500504
end || ConfigurationFunction <- Configurations],
501505
ok.
502506

507+
match_bidirectional_gh_100(Config) ->
508+
ok = rabbit_ct_broker_helpers:rpc(Config, 0,
509+
application, set_env, [rabbit, auth_backends, [rabbit_auth_backend_ldap]]),
510+
511+
Configurations = [
512+
fun resource_access_query_match_gh_100/0,
513+
fun resource_access_query_match_query_is_string_gh_100/0
514+
],
515+
516+
[begin
517+
set_env(Config, ConfigurationFunction()),
518+
Q1 = [#'queue.declare'{queue = <<"Jimmy-queue">>}],
519+
Q2 = [#'queue.declare'{queue = <<"Jimmy">>}],
520+
P = #amqp_params_network{port = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp)},
521+
[test_resource(PTR) || PTR <- [{P?JIMMY, Q1, ok},
522+
{P?JIMMY, Q2, ok}]]
523+
end || ConfigurationFunction <- Configurations],
524+
ok.
525+
503526
%%--------------------------------------------------------------------
504527

505528
test_publish(Person, Exchange, RoutingKey, ExpectedResult) ->
@@ -646,6 +669,22 @@ vhost_access_query_and_in_group() ->
646669
vhost_access_query_nested_groups_env() ->
647670
[{vhost_access_query, {in_group_nested, "cn=admins,ou=groups,dc=rabbitmq,dc=com"}}].
648671

672+
vhost_access_query_base_env() ->
673+
[{vhost_access_query, vhost_access_query_base()}].
674+
675+
vhost_access_query_base() ->
676+
{exists, "ou=${vhost},ou=vhosts,dc=rabbitmq,dc=com"}.
677+
678+
resource_access_query_match_gh_100() ->
679+
[{resource_access_query,
680+
{match, {string, "RMQ-${vhost}"}, {attribute, "${user_dn}", "description"}}
681+
}].
682+
683+
resource_access_query_match_query_is_string_gh_100() ->
684+
[{resource_access_query,
685+
{match, "RMQ-${vhost}", {attribute, "${user_dn}", "description"}}
686+
}].
687+
649688
resource_access_query_match() ->
650689
[{resource_access_query, {match, {string, "${name}"},
651690
{string, "^${username}-"}}
@@ -666,12 +705,6 @@ resource_access_query_match_query_and_re_query_are_strings() ->
666705
"^${username}-"}
667706
}].
668707

669-
vhost_access_query_base_env() ->
670-
[{vhost_access_query, vhost_access_query_base()}].
671-
672-
vhost_access_query_base() ->
673-
{exists, "ou=${vhost},ou=vhosts,dc=rabbitmq,dc=com"}.
674-
675708
topic_access_query_base_env() ->
676709
[{topic_access_query, topic_access_query_base()}].
677710

0 commit comments

Comments
 (0)