Fix test case
This commit is contained in:
		
							parent
							
								
									0de61a973c
								
							
						
					
					
						commit
						462c7e5546
					
				| 
						 | 
					@ -109,12 +109,7 @@ get_openid_configuration(DiscoverEndpoint, TLSOptions) ->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-spec merge_openid_configuration(openid_configuration(), oauth_provider()) ->
 | 
					-spec merge_openid_configuration(openid_configuration(), oauth_provider()) ->
 | 
				
			||||||
    oauth_provider().
 | 
					    oauth_provider().
 | 
				
			||||||
merge_openid_configuration(OpendIdConfiguration, OAuthProvider) ->
 | 
					merge_openid_configuration(OpendIdConfiguration, OAuthProvider0) ->    
 | 
				
			||||||
    OAuthProvider0 = case OpendIdConfiguration#openid_configuration.issuer of
 | 
					 | 
				
			||||||
        undefined -> OAuthProvider;
 | 
					 | 
				
			||||||
        Issuer ->
 | 
					 | 
				
			||||||
            OAuthProvider#oauth_provider{issuer = Issuer}
 | 
					 | 
				
			||||||
    end,
 | 
					 | 
				
			||||||
    OAuthProvider1 = case OpendIdConfiguration#openid_configuration.token_endpoint of
 | 
					    OAuthProvider1 = case OpendIdConfiguration#openid_configuration.token_endpoint of
 | 
				
			||||||
        undefined -> OAuthProvider0;
 | 
					        undefined -> OAuthProvider0;
 | 
				
			||||||
        TokenEndpoint ->
 | 
					        TokenEndpoint ->
 | 
				
			||||||
| 
						 | 
					@ -280,7 +275,7 @@ unlock(LockId) ->
 | 
				
			||||||
get_oauth_provider(ListOfRequiredAttributes) ->
 | 
					get_oauth_provider(ListOfRequiredAttributes) ->
 | 
				
			||||||
    case get_env(default_oauth_provider) of
 | 
					    case get_env(default_oauth_provider) of
 | 
				
			||||||
        undefined -> get_oauth_provider_from_keyconfig(ListOfRequiredAttributes);
 | 
					        undefined -> get_oauth_provider_from_keyconfig(ListOfRequiredAttributes);
 | 
				
			||||||
        {ok, DefaultOauthProviderId} ->
 | 
					        DefaultOauthProviderId ->
 | 
				
			||||||
            rabbit_log:debug("Using default_oauth_provider ~p", [DefaultOauthProviderId]),
 | 
					            rabbit_log:debug("Using default_oauth_provider ~p", [DefaultOauthProviderId]),
 | 
				
			||||||
            get_oauth_provider(DefaultOauthProviderId, ListOfRequiredAttributes)
 | 
					            get_oauth_provider(DefaultOauthProviderId, ListOfRequiredAttributes)
 | 
				
			||||||
    end.
 | 
					    end.
 | 
				
			||||||
| 
						 | 
					@ -292,12 +287,12 @@ get_oauth_provider_from_keyconfig(ListOfRequiredAttributes) ->
 | 
				
			||||||
        [] ->
 | 
					        [] ->
 | 
				
			||||||
            {ok, OAuthProvider};
 | 
					            {ok, OAuthProvider};
 | 
				
			||||||
        _ = MissingAttributes ->
 | 
					        _ = MissingAttributes ->
 | 
				
			||||||
            rabbit_log:debug("OauthProvider has following missing attributes ~p", [MissingAttributes]),
 | 
					            rabbit_log:debug("Looking up missing attributes ~p ...", [MissingAttributes]),
 | 
				
			||||||
            Result2 = case OAuthProvider#oauth_provider.issuer of
 | 
					            Result2 = case OAuthProvider#oauth_provider.discovery_endpoint of
 | 
				
			||||||
                undefined -> {error, {missing_oauth_provider_attributes, [issuer]}};
 | 
					                undefined -> {error, {missing_oauth_provider_attributes, [issuer]}};
 | 
				
			||||||
                Issuer ->
 | 
					                URL ->
 | 
				
			||||||
                    rabbit_log:debug("Downloading oauth_provider using issuer ~p", [Issuer]),
 | 
					                    rabbit_log:debug("Downloading oauth_provider using ~p ", [URL]),
 | 
				
			||||||
                    case get_openid_configuration(Issuer, get_ssl_options_if_any(OAuthProvider)) of
 | 
					                    case get_openid_configuration(URL, get_ssl_options_if_any(OAuthProvider)) of
 | 
				
			||||||
                        {ok, OpenIdConfiguration} ->
 | 
					                        {ok, OpenIdConfiguration} ->
 | 
				
			||||||
                            {ok, update_oauth_provider_endpoints_configuration(
 | 
					                            {ok, update_oauth_provider_endpoints_configuration(
 | 
				
			||||||
                                merge_openid_configuration(OpenIdConfiguration, OAuthProvider))};
 | 
					                                merge_openid_configuration(OpenIdConfiguration, OAuthProvider))};
 | 
				
			||||||
| 
						 | 
					@ -341,12 +336,12 @@ get_oauth_provider(OAuthProviderId, ListOfRequiredAttributes) when is_binary(OAu
 | 
				
			||||||
                    {ok, OAuthProvider};
 | 
					                    {ok, OAuthProvider};
 | 
				
			||||||
                _ = MissingAttributes ->
 | 
					                _ = MissingAttributes ->
 | 
				
			||||||
                    rabbit_log:debug("OauthProvider has following missing attributes ~p", [MissingAttributes]),
 | 
					                    rabbit_log:debug("OauthProvider has following missing attributes ~p", [MissingAttributes]),
 | 
				
			||||||
                    Result2 = case OAuthProvider#oauth_provider.issuer of
 | 
					                    Result2 = case OAuthProvider#oauth_provider.discovery_endpoint of
 | 
				
			||||||
                        undefined -> {error, {missing_oauth_provider_attributes, [issuer]}};
 | 
					                        undefined -> {error, {missing_oauth_provider_attributes, [issuer]}};
 | 
				
			||||||
                        Issuer ->
 | 
					                        URL ->
 | 
				
			||||||
                            rabbit_log:debug("Downloading oauth_provider ~p using issuer ~p",
 | 
					                            rabbit_log:debug("Downloading oauth_provider ~p using ~p ...",
 | 
				
			||||||
                                [OAuthProviderId, Issuer]),
 | 
					                                [OAuthProviderId, URL]),
 | 
				
			||||||
                            case get_openid_configuration(Issuer, get_ssl_options_if_any(OAuthProvider)) of
 | 
					                            case get_openid_configuration(URL, get_ssl_options_if_any(OAuthProvider)) of
 | 
				
			||||||
                                {ok, OpenIdConfiguration} ->
 | 
					                                {ok, OpenIdConfiguration} ->
 | 
				
			||||||
                                    {ok, update_oauth_provider_endpoints_configuration(OAuthProviderId,
 | 
					                                    {ok, update_oauth_provider_endpoints_configuration(OAuthProviderId,
 | 
				
			||||||
                                        merge_openid_configuration(OpenIdConfiguration, OAuthProvider))};
 | 
					                                        merge_openid_configuration(OpenIdConfiguration, OAuthProvider))};
 | 
				
			||||||
| 
						 | 
					@ -465,7 +460,7 @@ get_verify_or_peer_verification(Ssl_options, Default) ->
 | 
				
			||||||
lookup_oauth_provider_config(OAuth2ProviderId) ->
 | 
					lookup_oauth_provider_config(OAuth2ProviderId) ->
 | 
				
			||||||
    case get_env(oauth_providers) of
 | 
					    case get_env(oauth_providers) of
 | 
				
			||||||
        undefined -> {error, oauth_providers_not_found};
 | 
					        undefined -> {error, oauth_providers_not_found};
 | 
				
			||||||
        {ok, MapOfProviders} when is_map(MapOfProviders) ->
 | 
					        MapOfProviders when is_map(MapOfProviders) ->
 | 
				
			||||||
            case maps:get(OAuth2ProviderId, MapOfProviders, undefined) of
 | 
					            case maps:get(OAuth2ProviderId, MapOfProviders, undefined) of
 | 
				
			||||||
                undefined ->
 | 
					                undefined ->
 | 
				
			||||||
                    {error, {oauth_provider_not_found, OAuth2ProviderId}};
 | 
					                    {error, {oauth_provider_not_found, OAuth2ProviderId}};
 | 
				
			||||||
| 
						 | 
					@ -617,11 +612,13 @@ format_oauth_provider_id(Id) -> binary_to_list(Id).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-spec format_oauth_provider(oauth_provider()) -> string().
 | 
					-spec format_oauth_provider(oauth_provider()) -> string().
 | 
				
			||||||
format_oauth_provider(OAuthProvider) ->
 | 
					format_oauth_provider(OAuthProvider) ->
 | 
				
			||||||
    lists:flatten(io_lib:format("{id: ~p, issuer: ~p, token_endpoint: ~p, " ++
 | 
					    lists:flatten(io_lib:format("{id: ~p, issuer: ~p, discovery_endpoint: ~p, " ++
 | 
				
			||||||
 | 
					        " token_endpoint: ~p, " ++
 | 
				
			||||||
        "authorization_endpoint: ~p, end_session_endpoint: ~p, " ++
 | 
					        "authorization_endpoint: ~p, end_session_endpoint: ~p, " ++
 | 
				
			||||||
        "jwks_uri: ~p, ssl_options: ~p }", [
 | 
					        "jwks_uri: ~p, ssl_options: ~p }", [
 | 
				
			||||||
        format_oauth_provider_id(OAuthProvider#oauth_provider.id),
 | 
					        format_oauth_provider_id(OAuthProvider#oauth_provider.id),
 | 
				
			||||||
        OAuthProvider#oauth_provider.issuer,
 | 
					        OAuthProvider#oauth_provider.issuer,
 | 
				
			||||||
 | 
					        OAuthProvider#oauth_provider.discovery_endpoint,
 | 
				
			||||||
        OAuthProvider#oauth_provider.token_endpoint,
 | 
					        OAuthProvider#oauth_provider.token_endpoint,
 | 
				
			||||||
        OAuthProvider#oauth_provider.authorization_endpoint,
 | 
					        OAuthProvider#oauth_provider.authorization_endpoint,
 | 
				
			||||||
        OAuthProvider#oauth_provider.end_session_endpoint,
 | 
					        OAuthProvider#oauth_provider.end_session_endpoint,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue