From 6b5c0bb5d25b9d89148c2338b0af7ffecbced089 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Wed, 22 Jul 2020 18:27:44 +0200 Subject: [PATCH] [MM-27170] Migrate verify user by id endpoint to local mode (#15091) * [MM-27170] Migrate verify user by id endpoint to local mode * Update api4/user_test.go Co-authored-by: Ibrahim Serdar Acikgoz Co-authored-by: Ibrahim Serdar Acikgoz --- api4/user_local.go | 1 + api4/user_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/api4/user_local.go b/api4/user_local.go index e94057dd2f..7102d89097 100644 --- a/api4/user_local.go +++ b/api4/user_local.go @@ -24,6 +24,7 @@ func (api *API) InitUserLocal() { api.BaseRoutes.User.Handle("/mfa", api.ApiLocal(updateUserMfa)).Methods("PUT") api.BaseRoutes.User.Handle("/active", api.ApiLocal(updateUserActive)).Methods("PUT") api.BaseRoutes.User.Handle("/convert_to_bot", api.ApiLocal(convertUserToBot)).Methods("POST") + api.BaseRoutes.User.Handle("/email/verify/member", api.ApiLocal(verifyUserEmailWithoutToken)).Methods("POST") api.BaseRoutes.UserByUsername.Handle("", api.ApiLocal(localGetUserByUsername)).Methods("GET") api.BaseRoutes.UserByEmail.Handle("", api.ApiLocal(localGetUserByEmail)).Methods("GET") diff --git a/api4/user_test.go b/api4/user_test.go index d3547c55a2..7fa46f6e1d 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -4913,22 +4913,22 @@ func TestVerifyUserEmailWithoutToken(t *testing.T) { th := Setup(t) defer th.TearDown() - t.Run("Should verify a new user", func(t *testing.T) { + th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { email := th.GenerateTestEmail() user := model.User{Email: email, Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_USER_ROLE_ID} ruser, _ := th.Client.CreateUser(&user) - vuser, resp := th.SystemAdminClient.VerifyUserEmailWithoutToken(ruser.Id) + vuser, resp := client.VerifyUserEmailWithoutToken(ruser.Id) require.Nil(t, resp.Error) require.Equal(t, ruser.Id, vuser.Id) - }) + }, "Should verify a new user") - t.Run("Should not be able to find user", func(t *testing.T) { - vuser, resp := th.SystemAdminClient.VerifyUserEmailWithoutToken("randomId") + th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { + vuser, resp := client.VerifyUserEmailWithoutToken("randomId") require.NotNil(t, resp.Error) CheckErrorMessage(t, resp, "api.context.invalid_url_param.app_error") require.Nil(t, vuser) - }) + }, "Should not be able to find user") t.Run("Should not be able to verify user due to permissions", func(t *testing.T) { user := th.CreateUser()