瀏覽代碼

test(authn_api): move authn resource position

JimMoen 3 年之前
父節點
當前提交
2a866e7c91
共有 1 個文件被更改,包括 19 次插入2 次删除
  1. 19 2
      apps/emqx_authn/test/emqx_authn_api_SUITE.erl

+ 19 - 2
apps/emqx_authn/test/emqx_authn_api_SUITE.erl

@@ -347,7 +347,7 @@ test_authenticator_move(PathPrefix) ->
        ],
        ],
        PathPrefix ++ [?CONF_NS]),
        PathPrefix ++ [?CONF_NS]),
 
 
-    % Invalid moves
+    %% Invalid moves
 
 
     {ok, 400, _} = request(
     {ok, 400, _} = request(
                      post,
                      post,
@@ -374,8 +374,9 @@ test_authenticator_move(PathPrefix) ->
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
                      #{position => <<"before:password_based:redis">>}),
                      #{position => <<"before:password_based:redis">>}),
 
 
-    % Valid moves
+    %% Valid moves
 
 
+    %% test top
     {ok, 204, _} = request(
     {ok, 204, _} = request(
                      post,
                      post,
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
@@ -389,6 +390,7 @@ test_authenticator_move(PathPrefix) ->
        ],
        ],
        PathPrefix ++ [?CONF_NS]),
        PathPrefix ++ [?CONF_NS]),
 
 
+    %% test bottom
     {ok, 204, _} = request(
     {ok, 204, _} = request(
                      post,
                      post,
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
@@ -402,6 +404,7 @@ test_authenticator_move(PathPrefix) ->
        ],
        ],
        PathPrefix ++ [?CONF_NS]),
        PathPrefix ++ [?CONF_NS]),
 
 
+    %% test before
     {ok, 204, _} = request(
     {ok, 204, _} = request(
                      post,
                      post,
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
                      uri(PathPrefix ++ [?CONF_NS, "jwt", "move"]),
@@ -413,6 +416,20 @@ test_authenticator_move(PathPrefix) ->
         #{<<"mechanism">> := <<"jwt">>},
         #{<<"mechanism">> := <<"jwt">>},
         #{<<"mechanism">> := <<"password_based">>, <<"backend">> := <<"built_in_database">>}
         #{<<"mechanism">> := <<"password_based">>, <<"backend">> := <<"built_in_database">>}
        ],
        ],
+       PathPrefix ++ [?CONF_NS]),
+
+    %% test after
+    {ok, 204, _} = request(
+                     post,
+                     uri(PathPrefix ++ [?CONF_NS, "password_based%3Abuilt_in_database", "move"]),
+                     #{position => <<"after:password_based:http">>}),
+
+    ?assertAuthenticatorsMatch(
+       [
+         #{<<"mechanism">> := <<"password_based">>, <<"backend">> := <<"http">>},
+         #{<<"mechanism">> := <<"password_based">>, <<"backend">> := <<"built_in_database">>},
+         #{<<"mechanism">> := <<"jwt">>}
+       ],
        PathPrefix ++ [?CONF_NS]).
        PathPrefix ++ [?CONF_NS]).
 
 
 test_authenticator_import_users(PathPrefix) ->
 test_authenticator_import_users(PathPrefix) ->