Skip to content

Commit 3b53316

Browse files
Fix test
1 parent 8a4fca9 commit 3b53316

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

deps/rabbitmq_management/src/rabbit_mgmt_oauth_bootstrap.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ set_token_auth(AuthSettings, Req0) ->
4949
};
5050
_ ->
5151
Cookies = cowboy_req:parse_cookies(Req0),
52+
?LOG_DEBUG("parsing cookies ~p", [Cookies]),
5253
case lists:keyfind(?OAUTH2_ACCESS_TOKEN_COOKIE_NAME, 1, Cookies) of
5354
{_, Token} ->
5455
?LOG_DEBUG("set_token_auth cookie token ~p", [Token]),
@@ -80,15 +81,15 @@ set_token_auth(AuthSettings, Req0) ->
8081
case oauth2_client:is_jwt_token(Tk) of
8182
true ->
8283
{
83-
Req0,
84+
Req,
8485
["set_token_auth('", Tk, "');"]
8586
};
8687
false ->
8788
case map_opaque_to_jwt_token(Tk) of
8889
{ok, Tk1} ->
8990
?LOG_DEBUG("Successfully introspected token : ~p", [Tk1]),
9091
{
91-
Req0,
92+
Req,
9293
["set_token_auth('", Tk1, "');"]
9394
};
9495
{error, _} = Err1 ->

deps/rabbitmq_management/test/rabbit_mgmt_wm_auth_SUITE.erl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,20 +1032,23 @@ introspect_opaque_token_returns_401_from_auth_server(Config) ->
10321032

10331033
oauth_bootstrap_with_jwt_token_in_header(Config) ->
10341034
URI = rabbit_mgmt_test_util:uri_base_from(Config, 0, "") ++ "js/oidc-oauth/bootstrap.js",
1035-
Result = httpc:request(get, {URI, [{"Authorization", "bearer active"}]}, [], []),
1035+
Result = httpc:request(get, {URI, [{"Authorization", "bearer abc.dee.fff"}]}, [], []),
10361036
{ok, {{_HTTP, 200, _}, _Headers, ResBody}} = Result,
10371037
ct:log("resbody: ~p", [ResBody]),
1038-
case string:find(ResBody,"set_token_auth(") of
1038+
case string:find(ResBody,"set_token_auth('abc.dee.fff')") of
10391039
nomatch -> ct:fail("expected setting token");
1040-
Reminder ->
1041-
{match, [Token | _]} = re:run(Reminder, "'([^']*)'", [{capture, [1], list}]),
1042-
?assertEqual(true, oauth2_client:is_jwt_token(Token))
1040+
_ -> ok
10431041
end.
10441042

10451043
oauth_bootstrap_with_jwt_token_in_cookie(Config) ->
10461044
URI = rabbit_mgmt_test_util:uri_base_from(Config, 0, "") ++ "js/oidc-oauth/bootstrap.js",
1047-
Result = httpc:request(get, {URI, [{"Authorization", "bearer active"}]}, [], []),
1048-
ct:log("response idp: ~p ~p", [URI, Result]).
1045+
Result = httpc:request(get, {URI, [{"cookie", "access_token=abc.dee.fff"}]}, [], []),
1046+
{ok, {{_HTTP, 200, _}, _Headers, ResBody}} = Result,
1047+
ct:log("resbody: ~p", [ResBody]),
1048+
case string:find(ResBody,"set_token_auth('abc.dee.fff')") of
1049+
nomatch -> ct:fail("expected setting token");
1050+
_ -> ok
1051+
end.
10491052

10501053
oauth_bootstrap_with_opaque_token_in_cookie(Config) ->
10511054
URI = rabbit_mgmt_test_util:uri_base_from(Config, 0, "") ++ "js/oidc-oauth/bootstrap.js",

0 commit comments

Comments
 (0)