Skip to content

Commit

Permalink
[MM-27170] Migrate verify user by id endpoint to local mode (mattermo…
Browse files Browse the repository at this point in the history
…st#15091)

* [MM-27170] Migrate verify user by id endpoint to local mode

* Update api4/user_test.go

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
  • Loading branch information
mgdelacroix and isacikgoz committed Jul 22, 2020
1 parent 14aba9b commit 6b5c0bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions api4/user_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 6 additions & 6 deletions api4/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6b5c0bb

Please sign in to comment.