fix(sso): clear last error first before update && fix the `running`

This commit is contained in:
firest 2023-09-28 08:56:16 +08:00
parent afdda107af
commit 9dee2dc31e
2 changed files with 14 additions and 5 deletions

View File

@ -63,14 +63,22 @@ start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
running() ->
SSO = emqx:get_config(?MOD_KEY_PATH, #{}),
lists:filtermap(
fun
(#?MOD_TAB{backend = Backend, last_error = ?NO_ERROR}) ->
(#{backend := Backend, enable := true}) ->
case lookup(Backend) of
undefined ->
false;
#?MOD_TAB{last_error = ?NO_ERROR} ->
{true, Backend};
_ ->
false
end;
(_) ->
false
end,
ets:tab2list(?MOD_TAB)
maps:values(SSO)
).
get_backend_status(Backend, false) ->
@ -258,6 +266,7 @@ on_config_update({update, Backend, _RawConfig}, Config) ->
end
);
Data ->
update_last_error(Backend, ?NO_ERROR),
on_backend_updated(
Backend,
emqx_dashboard_sso:update(Provider, Config, Data#?MOD_TAB.state),

View File

@ -64,7 +64,7 @@ end_per_testcase(Case, _) ->
t_bad_create(_) ->
Path = uri(["sso", "ldap"]),
?assertMatch(
{ok, 200, _},
{ok, 400, _},
request(
put,
Path,
@ -168,7 +168,7 @@ t_next_login(_) ->
t_bad_update(_) ->
Path = uri(["sso", "ldap"]),
?assertMatch(
{ok, 200, _},
{ok, 400, _},
request(
put,
Path,