Skip to content

Commit 4251a71

Browse files
Fix unit test
1 parent 0183d9a commit 4251a71

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

deps/oauth2_client/src/oauth2_client.erl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ introspect_token(Token) ->
6666
Options = [],
6767
Response = httpc:request(post, {URL, Header, Type, Body}, HTTPOptions, Options),
6868
parse_access_token_response(Response);
69-
{error, Message} ->
70-
#unsuccessful_access_token_response{
71-
error = 500,
72-
error_description = binary_to_list(Message)
73-
}
69+
{error, _} = Error -> Error
7470
end.
7571

7672
build_introspect_request_parameters(Token, #introspect_token_request{
@@ -122,7 +118,7 @@ build_introspection_request() ->
122118
_ -> false
123119
end
124120
end
125-
end, get_env(oauth_providers))
121+
end, get_env(oauth_providers, #{}))
126122
end,
127123
case maps:size(Providers) of
128124
0 -> {error, not_found_introspection_endpoint};

deps/rabbitmq_auth_backend_oauth2/src/rabbit_auth_backend_oauth2.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ authenticate(_, AuthProps0) ->
154154
Token0 = token_from_context(AuthProps),
155155
TokenResult = case uaa_jwt_jwt:is_jwt_token(Token0) of
156156
true -> {ok, Token0};
157-
false -> oauth_client:introspect_token(Token0)
157+
false -> oauth2_client:introspect_token(Token0)
158158
end,
159159
case TokenResult of
160160
{ok, Token} ->
@@ -176,7 +176,7 @@ authenticate(_, AuthProps0) ->
176176
end
177177
end
178178
end;
179-
_ -> TokenResult
179+
{error, Error} -> {refused, "Unable to introspect token: ~p", [Error]}
180180
end.
181181

182182
-spec with_decoded_token(Token, Fun) -> Result

deps/rabbitmq_auth_backend_oauth2/src/uaa_jwt_jwt.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ get_aud(Token) ->
4343
{error, {invalid_token, Type, Err, Stacktrace}}
4444
end.
4545

46-
is_jwt_token(Token) ->
46+
is_jwt_token(Token) when is_binary(Token) ->
4747
case binary:split(Token, <<".">>, [global]) of
4848
[_, _, _] -> true;
4949
_ -> false
50-
end.
50+
end;
51+
is_jwt_token(_Token) -> true.

0 commit comments

Comments
 (0)