Skip to content

Commit 28576a6

Browse files
Fix test case
1 parent 101918a commit 28576a6

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

deps/oauth2_client/src/oauth2_client.erl

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,7 @@ get_openid_configuration(DiscoverEndpoint, TLSOptions) ->
109109

110110
-spec merge_openid_configuration(openid_configuration(), oauth_provider()) ->
111111
oauth_provider().
112-
merge_openid_configuration(OpendIdConfiguration, OAuthProvider) ->
113-
OAuthProvider0 = case OpendIdConfiguration#openid_configuration.issuer of
114-
undefined -> OAuthProvider;
115-
Issuer ->
116-
OAuthProvider#oauth_provider{issuer = Issuer}
117-
end,
112+
merge_openid_configuration(OpendIdConfiguration, OAuthProvider0) ->
118113
OAuthProvider1 = case OpendIdConfiguration#openid_configuration.token_endpoint of
119114
undefined -> OAuthProvider0;
120115
TokenEndpoint ->
@@ -280,7 +275,7 @@ unlock(LockId) ->
280275
get_oauth_provider(ListOfRequiredAttributes) ->
281276
case get_env(default_oauth_provider) of
282277
undefined -> get_oauth_provider_from_keyconfig(ListOfRequiredAttributes);
283-
{ok, DefaultOauthProviderId} ->
278+
DefaultOauthProviderId ->
284279
rabbit_log:debug("Using default_oauth_provider ~p", [DefaultOauthProviderId]),
285280
get_oauth_provider(DefaultOauthProviderId, ListOfRequiredAttributes)
286281
end.
@@ -292,12 +287,12 @@ get_oauth_provider_from_keyconfig(ListOfRequiredAttributes) ->
292287
[] ->
293288
{ok, OAuthProvider};
294289
_ = MissingAttributes ->
295-
rabbit_log:debug("OauthProvider has following missing attributes ~p", [MissingAttributes]),
296-
Result2 = case OAuthProvider#oauth_provider.issuer of
290+
rabbit_log:debug("Looking up missing attributes ~p ...", [MissingAttributes]),
291+
Result2 = case OAuthProvider#oauth_provider.discovery_endpoint of
297292
undefined -> {error, {missing_oauth_provider_attributes, [issuer]}};
298-
Issuer ->
299-
rabbit_log:debug("Downloading oauth_provider using issuer ~p", [Issuer]),
300-
case get_openid_configuration(Issuer, get_ssl_options_if_any(OAuthProvider)) of
293+
URL ->
294+
rabbit_log:debug("Downloading oauth_provider using ~p ", [URL]),
295+
case get_openid_configuration(URL, get_ssl_options_if_any(OAuthProvider)) of
301296
{ok, OpenIdConfiguration} ->
302297
{ok, update_oauth_provider_endpoints_configuration(
303298
merge_openid_configuration(OpenIdConfiguration, OAuthProvider))};
@@ -341,12 +336,12 @@ get_oauth_provider(OAuthProviderId, ListOfRequiredAttributes) when is_binary(OAu
341336
{ok, OAuthProvider};
342337
_ = MissingAttributes ->
343338
rabbit_log:debug("OauthProvider has following missing attributes ~p", [MissingAttributes]),
344-
Result2 = case OAuthProvider#oauth_provider.issuer of
339+
Result2 = case OAuthProvider#oauth_provider.discovery_endpoint of
345340
undefined -> {error, {missing_oauth_provider_attributes, [issuer]}};
346-
Issuer ->
347-
rabbit_log:debug("Downloading oauth_provider ~p using issuer ~p",
348-
[OAuthProviderId, Issuer]),
349-
case get_openid_configuration(Issuer, get_ssl_options_if_any(OAuthProvider)) of
341+
URL ->
342+
rabbit_log:debug("Downloading oauth_provider ~p using ~p ...",
343+
[OAuthProviderId, URL]),
344+
case get_openid_configuration(URL, get_ssl_options_if_any(OAuthProvider)) of
350345
{ok, OpenIdConfiguration} ->
351346
{ok, update_oauth_provider_endpoints_configuration(OAuthProviderId,
352347
merge_openid_configuration(OpenIdConfiguration, OAuthProvider))};
@@ -465,7 +460,7 @@ get_verify_or_peer_verification(Ssl_options, Default) ->
465460
lookup_oauth_provider_config(OAuth2ProviderId) ->
466461
case get_env(oauth_providers) of
467462
undefined -> {error, oauth_providers_not_found};
468-
{ok, MapOfProviders} when is_map(MapOfProviders) ->
463+
MapOfProviders when is_map(MapOfProviders) ->
469464
case maps:get(OAuth2ProviderId, MapOfProviders, undefined) of
470465
undefined ->
471466
{error, {oauth_provider_not_found, OAuth2ProviderId}};
@@ -617,11 +612,13 @@ format_oauth_provider_id(Id) -> binary_to_list(Id).
617612

618613
-spec format_oauth_provider(oauth_provider()) -> string().
619614
format_oauth_provider(OAuthProvider) ->
620-
lists:flatten(io_lib:format("{id: ~p, issuer: ~p, token_endpoint: ~p, " ++
615+
lists:flatten(io_lib:format("{id: ~p, issuer: ~p, discovery_endpoint: ~p, " ++
616+
" token_endpoint: ~p, " ++
621617
"authorization_endpoint: ~p, end_session_endpoint: ~p, " ++
622618
"jwks_uri: ~p, ssl_options: ~p }", [
623619
format_oauth_provider_id(OAuthProvider#oauth_provider.id),
624620
OAuthProvider#oauth_provider.issuer,
621+
OAuthProvider#oauth_provider.discovery_endpoint,
625622
OAuthProvider#oauth_provider.token_endpoint,
626623
OAuthProvider#oauth_provider.authorization_endpoint,
627624
OAuthProvider#oauth_provider.end_session_endpoint,

0 commit comments

Comments
 (0)