ソースを参照

fix: ignore unwanted results

EMQ-YangM 3 年 前
コミット
5b0ee30d72

+ 3 - 2
apps/emqx/src/emqx_authentication.erl

@@ -638,8 +638,9 @@ do_authenticate([#authenticator{id = ID, provider = Provider, state = State} | M
                 {ok, _} ->
                     emqx_plugin_libs_metrics:inc(authn_metrics, ID, success);
                 {error, _} ->
-                    emqx_plugin_libs_metrics:inc(authn_metrics, ID, failed)
-             end,
+                    emqx_plugin_libs_metrics:inc(authn_metrics, ID, failed);
+                _ -> ok
+            end,
             {stop, Result}
     catch
         Class:Reason:Stacktrace ->

+ 6 - 6
apps/emqx_authn/test/emqx_authn_api_SUITE.erl

@@ -326,9 +326,9 @@ test_authenticator_users(PathPrefix) ->
              } = jiffy:decode(PageData0, [return_maps]);
         ["listeners",'tcp:default'] ->
             #{ <<"metrics">> := #{
-                                  <<"matched">> := 3,
-                                  <<"success">> := 1,
-                                  <<"ignore">> := 2
+                                  <<"matched">> := 1,
+                                  <<"success">> := 0,
+                                  <<"ignore">> := 1
                                  }
              } = jiffy:decode(PageData0, [return_maps])
     end,
@@ -380,9 +380,9 @@ test_authenticator_users(PathPrefix) ->
              } = jiffy:decode(PageData01, [return_maps]);
         ["listeners",'tcp:default'] ->
             #{ <<"metrics">> := #{
-                                  <<"matched">> := 4,
-                                  <<"success">> := 2,
-                                  <<"ignore">> := 2
+                                  <<"matched">> := 2,
+                                  <<"success">> := 1,
+                                  <<"ignore">> := 1
                                  }
              } = jiffy:decode(PageData01, [return_maps])
     end,