Cherry-pick a fix for #122 to stable, resolve conflicts
This commit is contained in:
parent
59547c3142
commit
f54e2f986c
|
|
@ -28,7 +28,7 @@ overview_test() ->
|
|||
%% didn't blow up.
|
||||
true = 0 < length(pget(listeners, http_get("/overview"))),
|
||||
http_put("/users/myuser", [{password, <<"myuser">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_get("/overview", "myuser", "myuser", ?OK),
|
||||
http_delete("/users/myuser", ?NO_CONTENT),
|
||||
%% TODO uncomment when priv works in test
|
||||
|
|
@ -37,7 +37,7 @@ overview_test() ->
|
|||
|
||||
cluster_name_test() ->
|
||||
http_put("/users/myuser", [{password, <<"myuser">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/cluster-name", [{name, "foo"}], "myuser", "myuser", ?NOT_AUTHORISED),
|
||||
http_put("/cluster-name", [{name, "foo"}], ?NO_CONTENT),
|
||||
[{name, "foo"}] = http_get("/cluster-name", "myuser", "myuser", ?OK),
|
||||
|
|
@ -46,9 +46,9 @@ cluster_name_test() ->
|
|||
|
||||
nodes_test() ->
|
||||
http_put("/users/user", [{password, <<"user">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/monitor", [{password, <<"monitor">>},
|
||||
{tags, <<"monitoring">>}], ?NO_CONTENT),
|
||||
{tags, <<"monitoring">>}], [?CREATED, ?NO_CONTENT]),
|
||||
DiscNode = [{type, <<"disc">>}, {running, true}],
|
||||
assert_list([DiscNode], http_get("/nodes")),
|
||||
assert_list([DiscNode], http_get("/nodes", "monitor", "monitor", ?OK)),
|
||||
|
|
@ -64,7 +64,7 @@ nodes_test() ->
|
|||
|
||||
auth_test() ->
|
||||
http_put("/users/user", [{password, <<"user">>},
|
||||
{tags, <<"">>}], ?NO_CONTENT),
|
||||
{tags, <<"">>}], [?CREATED, ?NO_CONTENT]),
|
||||
test_auth(?NOT_AUTHORISED, []),
|
||||
test_auth(?NOT_AUTHORISED, [auth_header("user", "user")]),
|
||||
test_auth(?NOT_AUTHORISED, [auth_header("guest", "gust")]),
|
||||
|
|
@ -77,7 +77,7 @@ auth_test() ->
|
|||
vhosts_test() ->
|
||||
assert_list([[{name, <<"/">>}]], http_get("/vhosts")),
|
||||
%% Create a new one
|
||||
http_put("/vhosts/myvhost", none, ?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost", none, [?CREATED, ?NO_CONTENT]),
|
||||
%% PUT should be idempotent
|
||||
http_put("/vhosts/myvhost", none, ?NO_CONTENT),
|
||||
%% Check it's there
|
||||
|
|
@ -93,7 +93,7 @@ vhosts_test() ->
|
|||
http_delete("/vhosts/myvhost", ?NOT_FOUND).
|
||||
|
||||
vhosts_trace_test() ->
|
||||
http_put("/vhosts/myvhost", none, ?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost", none, [?CREATED, ?NO_CONTENT]),
|
||||
Disabled = [{name, <<"myvhost">>}, {tracing, false}],
|
||||
Enabled = [{name, <<"myvhost">>}, {tracing, true}],
|
||||
Disabled = http_get("/vhosts/myvhost"),
|
||||
|
|
@ -111,7 +111,7 @@ users_test() ->
|
|||
http_get("/users/myuser", ?NOT_FOUND),
|
||||
http_put_raw("/users/myuser", "Something not JSON", ?BAD_REQUEST),
|
||||
http_put("/users/myuser", [{flim, <<"flam">>}], ?BAD_REQUEST),
|
||||
http_put("/users/myuser", [{tags, <<"management">>}], ?NO_CONTENT),
|
||||
http_put("/users/myuser", [{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/myuser", [{password_hash, <<"not_hash">>}], ?BAD_REQUEST),
|
||||
http_put("/users/myuser", [{password_hash,
|
||||
<<"IECV6PZI/Invh0DL187KFpkO5Jc=">>},
|
||||
|
|
@ -143,8 +143,8 @@ users_test() ->
|
|||
ok.
|
||||
|
||||
users_legacy_administrator_test() ->
|
||||
http_put("/users/myuser1", [{administrator, <<"true">>}], ?NO_CONTENT),
|
||||
http_put("/users/myuser2", [{administrator, <<"false">>}], ?NO_CONTENT),
|
||||
http_put("/users/myuser1", [{administrator, <<"true">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/myuser2", [{administrator, <<"false">>}], [?CREATED, ?NO_CONTENT]),
|
||||
assert_item([{name, <<"myuser1">>}, {tags, <<"administrator">>}],
|
||||
http_get("/users/myuser1")),
|
||||
assert_item([{name, <<"myuser2">>}, {tags, <<"">>}],
|
||||
|
|
@ -172,16 +172,16 @@ permissions_list_test() ->
|
|||
http_get("/permissions"),
|
||||
|
||||
http_put("/users/myuser1", [{password, <<"">>}, {tags, <<"administrator">>}],
|
||||
?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/myuser2", [{password, <<"">>}, {tags, <<"administrator">>}],
|
||||
?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost1", none, ?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost2", none, ?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
http_put("/vhosts/myvhost1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/vhosts/myvhost2", none, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
Perms = [{configure, <<"foo">>}, {write, <<"foo">>}, {read, <<"foo">>}],
|
||||
http_put("/permissions/myvhost1/myuser1", Perms, ?NO_CONTENT),
|
||||
http_put("/permissions/myvhost2/myuser1", Perms, ?NO_CONTENT),
|
||||
http_put("/permissions/myvhost1/myuser2", Perms, ?NO_CONTENT),
|
||||
http_put("/permissions/myvhost1/myuser1", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/myvhost2/myuser1", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/myvhost1/myuser2", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
4 = length(http_get("/permissions")),
|
||||
2 = length(http_get("/users/myuser1/permissions")),
|
||||
|
|
@ -198,12 +198,12 @@ permissions_list_test() ->
|
|||
|
||||
permissions_test() ->
|
||||
http_put("/users/myuser", [{password, <<"myuser">>}, {tags, <<"administrator">>}],
|
||||
?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost", none, ?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
http_put("/vhosts/myvhost", none, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
http_put("/permissions/myvhost/myuser",
|
||||
[{configure, <<"foo">>}, {write, <<"foo">>}, {read, <<"foo">>}],
|
||||
?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
|
||||
Permission = [{user,<<"myuser">>},
|
||||
{vhost,<<"myvhost">>},
|
||||
|
|
@ -245,14 +245,14 @@ test_auth(Code, Headers) ->
|
|||
exchanges_test() ->
|
||||
%% Can pass booleans or strings
|
||||
Good = [{type, <<"direct">>}, {durable, <<"true">>}],
|
||||
http_put("/vhosts/myvhost", none, ?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_get("/exchanges/myvhost/foo", ?NOT_AUTHORISED),
|
||||
http_put("/exchanges/myvhost/foo", Good, ?NOT_AUTHORISED),
|
||||
http_put("/permissions/myvhost/guest",
|
||||
[{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
http_get("/exchanges/myvhost/foo", ?NOT_FOUND),
|
||||
http_put("/exchanges/myvhost/foo", Good, ?NO_CONTENT),
|
||||
http_put("/exchanges/myvhost/foo", Good, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/exchanges/myvhost/foo", Good, ?NO_CONTENT),
|
||||
http_get("/exchanges/%2f/foo", ?NOT_FOUND),
|
||||
assert_item([{name,<<"foo">>},
|
||||
|
|
@ -283,7 +283,7 @@ exchanges_test() ->
|
|||
queues_test() ->
|
||||
Good = [{durable, true}],
|
||||
http_get("/queues/%2f/foo", ?NOT_FOUND),
|
||||
http_put("/queues/%2f/foo", Good, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/foo", Good, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/foo", Good, ?NO_CONTENT),
|
||||
http_get("/queues/%2f/foo", ?OK),
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ queues_test() ->
|
|||
[{durable, false}],
|
||||
?BAD_REQUEST),
|
||||
|
||||
http_put("/queues/%2f/baz", Good, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/baz", Good, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
Queues = http_get("/queues/%2f"),
|
||||
Queue = http_get("/queues/%2f/foo"),
|
||||
|
|
@ -327,10 +327,10 @@ queues_test() ->
|
|||
bindings_test() ->
|
||||
XArgs = [{type, <<"direct">>}],
|
||||
QArgs = [],
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", QArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/myqueue", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
BArgs = [{routing_key, <<"routing">>}, {arguments, []}],
|
||||
http_post("/bindings/%2f/e/myexchange/q/myqueue", BArgs, ?CREATED),
|
||||
http_post("/bindings/%2f/e/myexchange/q/myqueue", BArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_get("/bindings/%2f/e/myexchange/q/myqueue/routing", ?OK),
|
||||
http_get("/bindings/%2f/e/myexchange/q/myqueue/rooting", ?NOT_FOUND),
|
||||
Binding =
|
||||
|
|
@ -369,13 +369,13 @@ bindings_post_test() ->
|
|||
XArgs = [{type, <<"direct">>}],
|
||||
QArgs = [],
|
||||
BArgs = [{routing_key, <<"routing">>}, {arguments, [{foo, <<"bar">>}]}],
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", QArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/myqueue", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/bindings/%2f/e/myexchange/q/badqueue", BArgs, ?NOT_FOUND),
|
||||
http_post("/bindings/%2f/e/badexchange/q/myqueue", BArgs, ?NOT_FOUND),
|
||||
Headers1 = http_post("/bindings/%2f/e/myexchange/q/myqueue", [], ?CREATED),
|
||||
Headers1 = http_post("/bindings/%2f/e/myexchange/q/myqueue", [], [?CREATED, ?NO_CONTENT]),
|
||||
"../../../../%2F/e/myexchange/q/myqueue/~" = pget("location", Headers1),
|
||||
Headers2 = http_post("/bindings/%2f/e/myexchange/q/myqueue", BArgs, ?CREATED),
|
||||
Headers2 = http_post("/bindings/%2f/e/myexchange/q/myqueue", BArgs, [?CREATED, ?NO_CONTENT]),
|
||||
PropertiesKey = "routing~V4mGFgnPNrdtRmluZIxTDA",
|
||||
PropertiesKeyBin = list_to_binary(PropertiesKey),
|
||||
"../../../../%2F/e/myexchange/q/myqueue/" ++ PropertiesKey =
|
||||
|
|
@ -398,7 +398,7 @@ bindings_e2e_test() ->
|
|||
BArgs = [{routing_key, <<"routing">>}, {arguments, []}],
|
||||
http_post("/bindings/%2f/e/amq.direct/e/badexchange", BArgs, ?NOT_FOUND),
|
||||
http_post("/bindings/%2f/e/badexchange/e/amq.fanout", BArgs, ?NOT_FOUND),
|
||||
Headers = http_post("/bindings/%2f/e/amq.direct/e/amq.fanout", BArgs, ?CREATED),
|
||||
Headers = http_post("/bindings/%2f/e/amq.direct/e/amq.fanout", BArgs, [?CREATED, ?NO_CONTENT]),
|
||||
"../../../../%2F/e/amq.direct/e/amq.fanout/routing" =
|
||||
pget("location", Headers),
|
||||
[{source,<<"amq.direct">>},
|
||||
|
|
@ -410,7 +410,7 @@ bindings_e2e_test() ->
|
|||
{properties_key,<<"routing">>}] =
|
||||
http_get("/bindings/%2f/e/amq.direct/e/amq.fanout/routing", ?OK),
|
||||
http_delete("/bindings/%2f/e/amq.direct/e/amq.fanout/routing", ?NO_CONTENT),
|
||||
http_post("/bindings/%2f/e/amq.direct/e/amq.headers", BArgs, ?CREATED),
|
||||
http_post("/bindings/%2f/e/amq.direct/e/amq.headers", BArgs, [?CREATED, ?NO_CONTENT]),
|
||||
Binding =
|
||||
[{source,<<"amq.direct">>},
|
||||
{vhost,<<"/">>},
|
||||
|
|
@ -432,9 +432,9 @@ bindings_e2e_test() ->
|
|||
|
||||
permissions_administrator_test() ->
|
||||
http_put("/users/isadmin", [{password, <<"isadmin">>},
|
||||
{tags, <<"administrator">>}], ?NO_CONTENT),
|
||||
{tags, <<"administrator">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/notadmin", [{password, <<"notadmin">>},
|
||||
{tags, <<"administrator">>}], ?NO_CONTENT),
|
||||
{tags, <<"administrator">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/notadmin", [{password, <<"notadmin">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
Test =
|
||||
|
|
@ -460,19 +460,19 @@ permissions_vhost_test() ->
|
|||
QArgs = [],
|
||||
PermArgs = [{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
http_put("/users/myuser", [{password, <<"myuser">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost1", none, ?NO_CONTENT),
|
||||
http_put("/vhosts/myvhost2", none, ?NO_CONTENT),
|
||||
http_put("/permissions/myvhost1/myuser", PermArgs, ?NO_CONTENT),
|
||||
http_put("/permissions/myvhost1/guest", PermArgs, ?NO_CONTENT),
|
||||
http_put("/permissions/myvhost2/guest", PermArgs, ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/vhosts/myvhost1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/vhosts/myvhost2", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/myvhost1/myuser", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/myvhost1/guest", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/myvhost2/guest", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
assert_list([[{name, <<"/">>}],
|
||||
[{name, <<"myvhost1">>}],
|
||||
[{name, <<"myvhost2">>}]], http_get("/vhosts", ?OK)),
|
||||
assert_list([[{name, <<"myvhost1">>}]],
|
||||
http_get("/vhosts", "myuser", "myuser", ?OK)),
|
||||
http_put("/queues/myvhost1/myqueue", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/myvhost2/myqueue", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/myvhost1/myqueue", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/myvhost2/myqueue", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
Test1 =
|
||||
fun(Path) ->
|
||||
Results = http_get(Path, "myuser", "myuser", ?OK),
|
||||
|
|
@ -514,8 +514,8 @@ permissions_amqp_test() ->
|
|||
PermArgs = [{configure, <<"foo.*">>}, {write, <<"foo.*">>},
|
||||
{read, <<"foo.*">>}],
|
||||
http_put("/users/myuser", [{password, <<"myuser">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
http_put("/permissions/%2f/myuser", PermArgs, ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/%2f/myuser", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/bar-queue", QArgs, "myuser", "myuser",
|
||||
?NOT_AUTHORISED),
|
||||
http_put("/queues/%2f/bar-queue", QArgs, "nonexistent", "nonexistent",
|
||||
|
|
@ -542,12 +542,12 @@ get_conn(Username, Password) ->
|
|||
permissions_connection_channel_consumer_test() ->
|
||||
PermArgs = [{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
http_put("/users/user", [{password, <<"user">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
http_put("/permissions/%2f/user", PermArgs, ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/%2f/user", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/monitor", [{password, <<"monitor">>},
|
||||
{tags, <<"monitoring">>}], ?NO_CONTENT),
|
||||
http_put("/permissions/%2f/monitor", PermArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test", [], ?NO_CONTENT),
|
||||
{tags, <<"monitoring">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/%2f/monitor", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/test", [], [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
{Conn1, UserConn, UserCh, UserConnCh} = get_conn("user", "user"),
|
||||
{Conn2, MonConn, MonCh, MonConnCh} = get_conn("monitor", "monitor"),
|
||||
|
|
@ -603,7 +603,7 @@ permissions_connection_channel_consumer_test() ->
|
|||
|
||||
|
||||
consumers_test() ->
|
||||
http_put("/queues/%2f/test", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test", [], [?CREATED, ?NO_CONTENT]),
|
||||
{Conn, _ConnPath, _ChPath, _ConnChPath} = get_conn("guest", "guest"),
|
||||
{ok, Ch} = amqp_connection:open_channel(Conn),
|
||||
amqp_channel:subscribe(
|
||||
|
|
@ -629,9 +629,9 @@ defs_v(Key, URI, CreateMethod, Args) ->
|
|||
defs(Key, Rep1(URI, "%2f"), CreateMethod, Rep2(Args, <<"/">>)),
|
||||
|
||||
%% Test against new vhost
|
||||
http_put("/vhosts/test", none, ?NO_CONTENT),
|
||||
http_put("/vhosts/test", none, [?CREATED, ?NO_CONTENT]),
|
||||
PermArgs = [{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
http_put("/permissions/test/guest", PermArgs, ?NO_CONTENT),
|
||||
http_put("/permissions/test/guest", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
defs(Key, Rep1(URI, "test"), CreateMethod, Rep2(Args, <<"test">>),
|
||||
fun(URI2) -> http_delete(URI2, ?NO_CONTENT),
|
||||
http_delete("/vhosts/test", ?NO_CONTENT) end).
|
||||
|
|
@ -639,9 +639,11 @@ defs_v(Key, URI, CreateMethod, Args) ->
|
|||
defs(Key, URI, CreateMethod, Args, DeleteFun) ->
|
||||
%% Create the item
|
||||
URI2 = case CreateMethod of
|
||||
put -> http_put(URI, Args, ?NO_CONTENT),
|
||||
put -> http_put(URI, Args, [?CREATED, ?NO_CONTENT]),
|
||||
URI;
|
||||
post -> Headers = http_post(URI, Args, ?CREATED),
|
||||
put_update -> http_put(URI, Args, ?NO_CONTENT),
|
||||
URI;
|
||||
post -> Headers = http_post(URI, Args, [?CREATED, ?NO_CONTENT]),
|
||||
rabbit_web_dispatch_util:unrelativise(
|
||||
URI, pget("location", Headers))
|
||||
end,
|
||||
|
|
@ -702,8 +704,7 @@ definitions_test() ->
|
|||
http_put("/permissions/%2f/guest",
|
||||
[{configure, <<".*">>},
|
||||
{write, <<".*">>},
|
||||
{read, <<".*">>}], ?NO_CONTENT),
|
||||
|
||||
{read, <<".*">>}], [?CREATED, ?NO_CONTENT]),
|
||||
BrokenConfig =
|
||||
[{users, []},
|
||||
{vhosts, []},
|
||||
|
|
@ -808,7 +809,7 @@ definitions_server_named_queue_test() ->
|
|||
Definitions = http_get("/definitions", ?OK),
|
||||
http_delete(Path, ?NO_CONTENT),
|
||||
http_get(Path, ?NOT_FOUND),
|
||||
http_post("/definitions", Definitions, ?CREATED),
|
||||
http_post("/definitions", Definitions, [?CREATED, ?NO_CONTENT]),
|
||||
http_get(Path, ?OK),
|
||||
http_delete(Path, ?NO_CONTENT),
|
||||
ok.
|
||||
|
|
@ -826,9 +827,9 @@ arguments_test() ->
|
|||
BArgs = [{routing_key, <<"">>},
|
||||
{arguments, [{'x-match', <<"all">>},
|
||||
{foo, <<"bar">>}]}],
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", QArgs, ?NO_CONTENT),
|
||||
http_post("/bindings/%2f/e/myexchange/q/myqueue", BArgs, ?CREATED),
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/myqueue", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/bindings/%2f/e/myexchange/q/myqueue", BArgs, [?CREATED, ?NO_CONTENT]),
|
||||
Definitions = http_get("/definitions", ?OK),
|
||||
http_delete("/exchanges/%2f/myexchange", ?NO_CONTENT),
|
||||
http_delete("/queues/%2f/myqueue", ?NO_CONTENT),
|
||||
|
|
@ -850,7 +851,7 @@ arguments_table_test() ->
|
|||
<<"amqp://localhost/%2f/upstream2">>]}],
|
||||
XArgs = [{type, <<"headers">>},
|
||||
{arguments, Args}],
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/%2f/myexchange", XArgs, [?CREATED, ?NO_CONTENT]),
|
||||
Definitions = http_get("/definitions", ?OK),
|
||||
http_delete("/exchanges/%2f/myexchange", ?NO_CONTENT),
|
||||
http_post("/definitions", Definitions, ?CREATED),
|
||||
|
|
@ -860,7 +861,7 @@ arguments_table_test() ->
|
|||
|
||||
queue_purge_test() ->
|
||||
QArgs = [],
|
||||
http_put("/queues/%2f/myqueue", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
{ok, Conn} = amqp_connection:start(#amqp_params_network{}),
|
||||
{ok, Ch} = amqp_connection:open_channel(Conn),
|
||||
Publish = fun() ->
|
||||
|
|
@ -887,7 +888,7 @@ queue_purge_test() ->
|
|||
ok.
|
||||
|
||||
queue_actions_test() ->
|
||||
http_put("/queues/%2f/q", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/q", [], [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/queues/%2f/q/actions", [{action, sync}], ?NO_CONTENT),
|
||||
http_post("/queues/%2f/q/actions", [{action, cancel_sync}], ?NO_CONTENT),
|
||||
http_post("/queues/%2f/q/actions", [{action, change_colour}], ?BAD_REQUEST),
|
||||
|
|
@ -963,13 +964,13 @@ connections_channels_pagination_test() ->
|
|||
exchanges_pagination_test() ->
|
||||
QArgs = [],
|
||||
PermArgs = [{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
http_put("/vhosts/vh1", none, ?NO_CONTENT),
|
||||
http_put("/permissions/vh1/guest", PermArgs, ?NO_CONTENT),
|
||||
http_put("/vhosts/vh1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/vh1/guest", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_get("/exchanges/vh1?page=1&page_size=2", ?OK),
|
||||
http_put("/exchanges/%2f/test0", QArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/vh1/test1", QArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/%2f/test2_reg", QArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/vh1/reg_test3", QArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/%2f/test0", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/exchanges/vh1/test1", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/exchanges/%2f/test2_reg", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/exchanges/vh1/reg_test3", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
PageOfTwo = http_get("/exchanges?page=1&page_size=2", ?OK),
|
||||
?assertEqual(19, proplists:get_value(total_count, PageOfTwo)),
|
||||
?assertEqual(19, proplists:get_value(filtered_count, PageOfTwo)),
|
||||
|
|
@ -1021,15 +1022,15 @@ exchanges_pagination_test() ->
|
|||
|
||||
exchanges_pagination_permissions_test() ->
|
||||
http_put("/users/admin", [{password, <<"admin">>},
|
||||
{tags, <<"administrator">>}], ?NO_CONTENT),
|
||||
{tags, <<"administrator">>}], [?CREATED, ?NO_CONTENT]),
|
||||
Perms = [{configure, <<".*">>},
|
||||
{write, <<".*">>},
|
||||
{read, <<".*">>}],
|
||||
http_put("/vhosts/vh1", none, ?NO_CONTENT),
|
||||
http_put("/permissions/vh1/admin", Perms, ?NO_CONTENT),
|
||||
http_put("/vhosts/vh1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/vh1/admin", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
QArgs = [],
|
||||
http_put("/exchanges/%2f/test0", QArgs, ?NO_CONTENT),
|
||||
http_put("/exchanges/vh1/test1", QArgs, "admin","admin", ?NO_CONTENT),
|
||||
http_put("/exchanges/%2f/test0", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/exchanges/vh1/test1", QArgs, "admin","admin", [?CREATED, ?NO_CONTENT]),
|
||||
FirstPage = http_get("/exchanges?page=1&name=test1","admin","admin", ?OK),
|
||||
?assertEqual(8, proplists:get_value(total_count, FirstPage)),
|
||||
?assertEqual(1, proplists:get_value(item_count, FirstPage)),
|
||||
|
|
@ -1048,15 +1049,15 @@ exchanges_pagination_permissions_test() ->
|
|||
queue_pagination_test() ->
|
||||
QArgs = [],
|
||||
PermArgs = [{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
http_put("/vhosts/vh1", none, ?NO_CONTENT),
|
||||
http_put("/permissions/vh1/guest", PermArgs, ?NO_CONTENT),
|
||||
http_put("/vhosts/vh1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/vh1/guest", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
http_get("/queues/vh1?page=1&page_size=2", ?OK),
|
||||
|
||||
http_put("/queues/%2f/test0", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/vh1/test1", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test2_reg", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/vh1/reg_test3", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test0", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/vh1/test1", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/test2_reg", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/vh1/reg_test3", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
PageOfTwo = http_get("/queues?page=1&page_size=2", ?OK),
|
||||
?assertEqual(4, proplists:get_value(total_count, PageOfTwo)),
|
||||
?assertEqual(4, proplists:get_value(filtered_count, PageOfTwo)),
|
||||
|
|
@ -1147,15 +1148,15 @@ queue_pagination_test() ->
|
|||
|
||||
queues_pagination_permissions_test() ->
|
||||
http_put("/users/admin", [{password, <<"admin">>},
|
||||
{tags, <<"administrator">>}], ?NO_CONTENT),
|
||||
{tags, <<"administrator">>}], [?CREATED, ?NO_CONTENT]),
|
||||
Perms = [{configure, <<".*">>},
|
||||
{write, <<".*">>},
|
||||
{read, <<".*">>}],
|
||||
http_put("/vhosts/vh1", none, ?NO_CONTENT),
|
||||
http_put("/permissions/vh1/admin", Perms, ?NO_CONTENT),
|
||||
http_put("/vhosts/vh1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/vh1/admin", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
QArgs = [],
|
||||
http_put("/queues/%2f/test0", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/vh1/test1", QArgs, "admin","admin", ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test0", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/vh1/test1", QArgs, "admin","admin", [?CREATED, ?NO_CONTENT]),
|
||||
FirstPage = http_get("/queues?page=1","admin","admin", ?OK),
|
||||
?assertEqual(1, proplists:get_value(total_count, FirstPage)),
|
||||
?assertEqual(1, proplists:get_value(item_count, FirstPage)),
|
||||
|
|
@ -1226,7 +1227,7 @@ samples_range_test() ->
|
|||
|
||||
%% Queues.
|
||||
|
||||
http_put("/queues/%2f/test0", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test0", [], [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
http_get("/queues/%2f?lengths_age=60&lengths_incr=1", ?OK),
|
||||
http_get("/queues/%2f?lengths_age=6000&lengths_incr=1", ?BAD_REQUEST),
|
||||
|
|
@ -1237,7 +1238,7 @@ samples_range_test() ->
|
|||
|
||||
%% Vhosts.
|
||||
|
||||
http_put("/vhosts/vh1", none, ?NO_CONTENT),
|
||||
http_put("/vhosts/vh1", none, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
http_get("/vhosts?lengths_age=60&lengths_incr=1", ?OK),
|
||||
http_get("/vhosts?lengths_age=6000&lengths_incr=1", ?BAD_REQUEST),
|
||||
|
|
@ -1251,12 +1252,12 @@ samples_range_test() ->
|
|||
sorting_test() ->
|
||||
QArgs = [],
|
||||
PermArgs = [{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
http_put("/vhosts/vh1", none, ?NO_CONTENT),
|
||||
http_put("/permissions/vh1/guest", PermArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test0", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/vh1/test1", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test2", QArgs, ?NO_CONTENT),
|
||||
http_put("/queues/vh1/test3", QArgs, ?NO_CONTENT),
|
||||
http_put("/vhosts/vh1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/vh1/guest", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/test0", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/vh1/test1", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/test2", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/vh1/test3", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
assert_list([[{name, <<"test0">>}],
|
||||
[{name, <<"test2">>}],
|
||||
[{name, <<"test1">>}],
|
||||
|
|
@ -1293,9 +1294,9 @@ sorting_test() ->
|
|||
format_output_test() ->
|
||||
QArgs = [],
|
||||
PermArgs = [{configure, <<".*">>}, {write, <<".*">>}, {read, <<".*">>}],
|
||||
http_put("/vhosts/vh1", none, ?NO_CONTENT),
|
||||
http_put("/permissions/vh1/guest", PermArgs, ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test0", QArgs, ?NO_CONTENT),
|
||||
http_put("/vhosts/vh1", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/vh1/guest", PermArgs, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/test0", QArgs, [?CREATED, ?NO_CONTENT]),
|
||||
assert_list([[{name, <<"test0">>},
|
||||
{consumer_utilisation, null},
|
||||
{exclusive_consumer_tag, null},
|
||||
|
|
@ -1306,7 +1307,7 @@ format_output_test() ->
|
|||
|
||||
columns_test() ->
|
||||
http_put("/queues/%2f/test", [{arguments, [{<<"foo">>, <<"bar">>}]}],
|
||||
?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
[[{name, <<"test">>}, {arguments, [{foo, <<"bar">>}]}]] =
|
||||
http_get("/queues?columns=arguments.foo,name", ?OK),
|
||||
[{name, <<"test">>}, {arguments, [{foo, <<"bar">>}]}] =
|
||||
|
|
@ -1320,7 +1321,7 @@ get_test() ->
|
|||
[{table,
|
||||
[{<<"uri">>, longstr,
|
||||
<<"amqp://localhost/%2f/upstream">>}]}]}],
|
||||
http_put("/queues/%2f/myqueue", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", [], [?CREATED, ?NO_CONTENT]),
|
||||
{ok, Conn} = amqp_connection:start(#amqp_params_network{}),
|
||||
{ok, Ch} = amqp_connection:open_channel(Conn),
|
||||
Publish = fun (Payload) ->
|
||||
|
|
@ -1363,7 +1364,7 @@ get_test() ->
|
|||
get_fail_test() ->
|
||||
http_put("/users/myuser", [{password, <<"password">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", [], [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/queues/%2f/myqueue/get",
|
||||
[{requeue, false},
|
||||
{count, 1},
|
||||
|
|
@ -1375,7 +1376,7 @@ get_fail_test() ->
|
|||
publish_test() ->
|
||||
Headers = [{'x-forwarding', [[{uri,<<"amqp://localhost/%2f/upstream">>}]]}],
|
||||
Msg = msg(<<"myqueue">>, Headers, <<"Hello world">>),
|
||||
http_put("/queues/%2f/myqueue", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", [], [?CREATED, ?NO_CONTENT]),
|
||||
?assertEqual([{routed, true}],
|
||||
http_post("/exchanges/%2f/amq.default/publish", Msg, ?OK)),
|
||||
[Msg2] = http_post("/queues/%2f/myqueue/get", [{requeue, false},
|
||||
|
|
@ -1393,7 +1394,7 @@ publish_test() ->
|
|||
publish_accept_json_test() ->
|
||||
Headers = [{'x-forwarding', [[{uri, <<"amqp://localhost/%2f/upstream">>}]]}],
|
||||
Msg = msg(<<"myqueue">>, Headers, <<"Hello world">>),
|
||||
http_put("/queues/%2f/myqueue", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", [], [?CREATED, ?NO_CONTENT]),
|
||||
?assertEqual([{routed, true}],
|
||||
http_post_accept_json("/exchanges/%2f/amq.default/publish",
|
||||
Msg, ?OK)),
|
||||
|
|
@ -1414,9 +1415,9 @@ publish_accept_json_test() ->
|
|||
|
||||
publish_fail_test() ->
|
||||
Msg = msg(<<"myqueue">>, [], <<"Hello world">>),
|
||||
http_put("/queues/%2f/myqueue", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", [], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/myuser", [{password, <<"password">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/exchanges/%2f/amq.default/publish", Msg, "myuser", "password",
|
||||
?NOT_AUTHORISED),
|
||||
Msg2 = [{exchange, <<"">>},
|
||||
|
|
@ -1447,7 +1448,7 @@ publish_base64_test() ->
|
|||
Msg = msg(<<"myqueue">>, [], <<"YWJjZA==">>, <<"base64">>),
|
||||
BadMsg1 = msg(<<"myqueue">>, [], <<"flibble">>, <<"base64">>),
|
||||
BadMsg2 = msg(<<"myqueue">>, [], <<"YWJjZA==">>, <<"base99">>),
|
||||
http_put("/queues/%2f/myqueue", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/myqueue", [], [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/exchanges/%2f/amq.default/publish", Msg, ?OK),
|
||||
http_post("/exchanges/%2f/amq.default/publish", BadMsg1, ?BAD_REQUEST),
|
||||
http_post("/exchanges/%2f/amq.default/publish", BadMsg2, ?BAD_REQUEST),
|
||||
|
|
@ -1464,9 +1465,9 @@ publish_unrouted_test() ->
|
|||
http_post("/exchanges/%2f/amq.default/publish", Msg, ?OK)).
|
||||
|
||||
if_empty_unused_test() ->
|
||||
http_put("/exchanges/%2f/test", [], ?NO_CONTENT),
|
||||
http_put("/queues/%2f/test", [], ?NO_CONTENT),
|
||||
http_post("/bindings/%2f/e/test/q/test", [], ?CREATED),
|
||||
http_put("/exchanges/%2f/test", [], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/queues/%2f/test", [], [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/bindings/%2f/e/test/q/test", [], [?CREATED, ?NO_CONTENT]),
|
||||
http_post("/exchanges/%2f/amq.default/publish",
|
||||
msg(<<"test">>, [], <<"Hello world">>), ?OK),
|
||||
http_delete("/queues/%2f/test?if-empty=true", ?BAD_REQUEST),
|
||||
|
|
@ -1486,8 +1487,8 @@ if_empty_unused_test() ->
|
|||
parameters_test() ->
|
||||
rabbit_runtime_parameters_test:register(),
|
||||
|
||||
http_put("/parameters/test/%2f/good", [{value, <<"ignore">>}], ?NO_CONTENT),
|
||||
http_put("/parameters/test/%2f/maybe", [{value, <<"good">>}], ?NO_CONTENT),
|
||||
http_put("/parameters/test/%2f/good", [{value, <<"ignore">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/parameters/test/%2f/maybe", [{value, <<"good">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/parameters/test/%2f/maybe", [{value, <<"bad">>}], ?BAD_REQUEST),
|
||||
http_put("/parameters/test/%2f/bad", [{value, <<"good">>}], ?BAD_REQUEST),
|
||||
http_put("/parameters/test/um/good", [{value, <<"ignore">>}], ?NOT_FOUND),
|
||||
|
|
@ -1536,11 +1537,11 @@ policy_test() ->
|
|||
http_put(
|
||||
"/policies/%2f/policy_pos",
|
||||
lists:keydelete(key, 1, PolicyPos),
|
||||
?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
http_put(
|
||||
"/policies/%2f/policy_even",
|
||||
lists:keydelete(key, 1, PolicyEven),
|
||||
?NO_CONTENT),
|
||||
[?CREATED, ?NO_CONTENT]),
|
||||
assert_item(PolicyPos, http_get("/policies/%2f/policy_pos", ?OK)),
|
||||
assert_item(PolicyEven, http_get("/policies/%2f/policy_even", ?OK)),
|
||||
List = [PolicyPos, PolicyEven],
|
||||
|
|
@ -1558,31 +1559,32 @@ policy_permissions_test() ->
|
|||
rabbit_runtime_parameters_test:register(),
|
||||
|
||||
http_put("/users/admin", [{password, <<"admin">>},
|
||||
{tags, <<"administrator">>}], ?NO_CONTENT),
|
||||
{tags, <<"administrator">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/mon", [{password, <<"monitor">>},
|
||||
{tags, <<"monitoring">>}], ?NO_CONTENT),
|
||||
{tags, <<"monitoring">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/policy", [{password, <<"policy">>},
|
||||
{tags, <<"policymaker">>}], ?NO_CONTENT),
|
||||
{tags, <<"policymaker">>}], [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/users/mgmt", [{password, <<"mgmt">>},
|
||||
{tags, <<"management">>}], ?NO_CONTENT),
|
||||
{tags, <<"management">>}], [?CREATED, ?NO_CONTENT]),
|
||||
Perms = [{configure, <<".*">>},
|
||||
{write, <<".*">>},
|
||||
{read, <<".*">>}],
|
||||
http_put("/vhosts/v", none, ?NO_CONTENT),
|
||||
http_put("/permissions/v/admin", Perms, ?NO_CONTENT),
|
||||
http_put("/permissions/v/mon", Perms, ?NO_CONTENT),
|
||||
http_put("/permissions/v/policy", Perms, ?NO_CONTENT),
|
||||
http_put("/permissions/v/mgmt", Perms, ?NO_CONTENT),
|
||||
http_put("/vhosts/v", none, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/v/admin", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/v/mon", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/v/policy", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/permissions/v/mgmt", Perms, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
Policy = [{pattern, <<".*">>},
|
||||
{definition, [{<<"ha-mode">>, <<"all">>}]}],
|
||||
Param = [{value, <<"">>}],
|
||||
|
||||
http_put("/policies/%2f/HA", Policy, ?NO_CONTENT),
|
||||
http_put("/parameters/test/%2f/good", Param, ?NO_CONTENT),
|
||||
http_put("/policies/%2f/HA", Policy, [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/parameters/test/%2f/good", Param, [?CREATED, ?NO_CONTENT]),
|
||||
|
||||
Pos = fun (U) ->
|
||||
http_put("/policies/v/HA", Policy, U, U, ?NO_CONTENT),
|
||||
Expected = case U of "admin" -> [?CREATED, ?NO_CONTENT]; _ -> ?NO_CONTENT end,
|
||||
http_put("/policies/v/HA", Policy, U, U, Expected),
|
||||
http_put(
|
||||
"/parameters/test/v/good", Param, U, U, ?NO_CONTENT),
|
||||
1 = length(http_get("/policies", U, U, ?OK)),
|
||||
|
|
@ -1621,7 +1623,7 @@ policy_permissions_test() ->
|
|||
[AlwaysNeg(U) || U <- ["mon", "mgmt", "admin", "policy"]],
|
||||
|
||||
%% This one is deliberately different between admin and policymaker.
|
||||
http_put("/parameters/test/v/admin", Param, "admin", "admin", ?NO_CONTENT),
|
||||
http_put("/parameters/test/v/admin", Param, "admin", "admin", [?CREATED, ?NO_CONTENT]),
|
||||
http_put("/parameters/test/v/admin", Param, "policy", "policy",
|
||||
?BAD_REQUEST),
|
||||
|
||||
|
|
@ -1733,6 +1735,14 @@ http_delete(Path, User, Pass, CodeExp) ->
|
|||
assert_code(CodeExp, CodeAct, "DELETE", Path, ResBody),
|
||||
decode(CodeExp, Headers, ResBody).
|
||||
|
||||
assert_code(CodesExpected, CodeAct, Type, Path, Body) when is_list(CodesExpected) ->
|
||||
case lists:member(CodeAct, CodesExpected) of
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
throw({expected, CodesExpected, got, CodeAct, type, Type,
|
||||
path, Path, body, Body})
|
||||
end;
|
||||
assert_code(CodeExp, CodeAct, Type, Path, Body) ->
|
||||
case CodeExp of
|
||||
CodeAct -> ok;
|
||||
|
|
|
|||
Loading…
Reference in New Issue