Skip to content

Commit

Permalink
Validate setting permissions works
Browse files Browse the repository at this point in the history
in order to troubleshoot the flake described in
#12413 (comment)
```
Node: rabbit_shard2@localhost
Case: amqp_system_SUITE:access_failure
Reason: {error,{{badmatch,{error,134,
                                 "Unhandled exception. System.Exception: expected exception not received\n
                                 at Program.Test.accessFailure(String uri) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 477\n
                                 at Program.main(String[] argv) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 509\n"}},
                [{amqp_system_SUITE,run_dotnet_test,2,
                                    [{file,"amqp_system_SUITE.erl"},
                                     {line,257}]},
```
  • Loading branch information
ansd committed Oct 24, 2024
1 parent 8c046c7 commit 0c905f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
36 changes: 20 additions & 16 deletions deps/rabbit/test/amqp_system_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -219,28 +219,32 @@ auth_failure(Config) ->

access_failure(Config) ->
User = atom_to_binary(?FUNCTION_NAME),
rabbit_ct_broker_helpers:add_user(Config, User, <<"boo">>),
rabbit_ct_broker_helpers:set_permissions(Config, User, <<"/">>,
<<".*">>, %% configure
<<"^banana.*">>, %% write
<<"^banana.*">> %% read
),
run(Config, [ {dotnet, "access_failure"} ]).
ok = rabbit_ct_broker_helpers:add_user(Config, User, <<"boo">>),
ok = rabbit_ct_broker_helpers:set_permissions(Config, User, <<"/">>,
<<".*">>, %% configure
<<"^banana.*">>, %% write
<<"^banana.*">> %% read
),
run(Config, [ {dotnet, "access_failure"} ]),
ok = rabbit_ct_broker_helpers:delete_user(Config, User).


access_failure_not_allowed(Config) ->
User = atom_to_binary(?FUNCTION_NAME),
rabbit_ct_broker_helpers:add_user(Config, User, <<"boo">>),
run(Config, [ {dotnet, "access_failure_not_allowed"} ]).
ok = rabbit_ct_broker_helpers:add_user(Config, User, <<"boo">>),
run(Config, [ {dotnet, "access_failure_not_allowed"} ]),
ok = rabbit_ct_broker_helpers:delete_user(Config, User).

access_failure_send(Config) ->
User = atom_to_binary(?FUNCTION_NAME),
rabbit_ct_broker_helpers:add_user(Config, User, <<"boo">>),
rabbit_ct_broker_helpers:set_permissions(Config, User, <<"/">>,
<<".*">>, %% configure
<<"^banana.*">>, %% write
<<"^banana.*">> %% read
),
run(Config, [ {dotnet, "access_failure_send"} ]).
ok = rabbit_ct_broker_helpers:add_user(Config, User, <<"boo">>),
ok = rabbit_ct_broker_helpers:set_permissions(Config, User, <<"/">>,
<<".*">>, %% configure
<<"^banana.*">>, %% write
<<"^banana.*">> %% read
),
run(Config, [ {dotnet, "access_failure_send"} ]),
ok = rabbit_ct_broker_helpers:delete_user(Config, User).

run(Config, Flavors) ->
ClientLibrary = ?config(amqp_client_library, Config),
Expand Down
18 changes: 9 additions & 9 deletions deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ module Test =

let invalidRoutes uri =

for dest, cond in
for addr, cond in
["/exchanges/missing", "amqp:not-found"
"/fruit/orange", "amqp:invalid-field"] do
use ac = connectAnon uri
Expand All @@ -428,11 +428,11 @@ module Test =
let attached = new OnAttached (fun _ _ -> trySet mre)

let sender = new SenderLink(ac.Session, "test-sender",
Target(Address = dest), attached);
Target(Address = addr), attached);
mre.WaitOne() |> ignore

try
let receiver = ReceiverLink(ac.Session, "test-receiver", dest)
let receiver = ReceiverLink(ac.Session, "test-receiver", addr)
receiver.Close()
with
| :? Amqp.AmqpException as ae ->
Expand All @@ -454,11 +454,11 @@ module Test =
let u = Uri uri
let uri = sprintf "amqp://access_failure:boo@%s:%i" u.Host u.Port
use ac = connect uri
let dest = "/queues/test"
let target = "/queues/test"
ac.Session.add_Closed (
new ClosedCallback (fun _ err -> printfn "session err %A" err.Condition
))
let sender = new SenderLink(ac.Session, "test-sender", dest)
let sender = new SenderLink(ac.Session, "test-sender", target)
sender.Send(new Message "hi", TimeSpan.FromSeconds 15.)
failwith "expected exception not received"
with
Expand All @@ -471,8 +471,8 @@ module Test =
let u = Uri uri
let uri = sprintf "amqp://access_failure:boo@%s:%i" u.Host u.Port
use ac = connect uri
let dest = "/queues/test"
let receiver = ReceiverLink(ac.Session, "test-receiver", dest)
let src = "/queues/test"
let receiver = ReceiverLink(ac.Session, "test-receiver", src)
receiver.Close()
failwith "expected exception not received"
with
Expand All @@ -485,8 +485,8 @@ module Test =
let u = Uri uri
let uri = sprintf "amqp://access_failure_not_allowed:boo@%s:%i" u.Host u.Port
use ac = connect uri
let dest = "/queues/test"
let receiver = ReceiverLink(ac.Session, "test-receiver", dest)
let src = "/queues/test"
let receiver = ReceiverLink(ac.Session, "test-receiver", src)
receiver.Close()
failwith "expected exception not received"
with
Expand Down

0 comments on commit 0c905f9

Please sign in to comment.