[MM-22572] Modify get user by email route to accept the / character in the email (#13897)

Automatic Merge
Этот коммит содержится в:
Miguel de la Cruz
2020-03-01 19:52:16 +01:00
коммит произвёл GitHub
родитель 69b29476d5
Коммит 98ccc1ccf5
2 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@@ -133,7 +133,7 @@ func Init(configservice configservice.ConfigService, globalOptionsFunc app.AppOp
api.BaseRoutes.Users = api.BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter() api.BaseRoutes.Users = api.BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter()
api.BaseRoutes.User = api.BaseRoutes.ApiRoot.PathPrefix("/users/{user_id:[A-Za-z0-9]+}").Subrouter() api.BaseRoutes.User = api.BaseRoutes.ApiRoot.PathPrefix("/users/{user_id:[A-Za-z0-9]+}").Subrouter()
api.BaseRoutes.UserByUsername = api.BaseRoutes.Users.PathPrefix("/username/{username:[A-Za-z0-9\\_\\-\\.]+}").Subrouter() api.BaseRoutes.UserByUsername = api.BaseRoutes.Users.PathPrefix("/username/{username:[A-Za-z0-9\\_\\-\\.]+}").Subrouter()
api.BaseRoutes.UserByEmail = api.BaseRoutes.Users.PathPrefix("/email/{email}").Subrouter() api.BaseRoutes.UserByEmail = api.BaseRoutes.Users.PathPrefix("/email/{email:.+}").Subrouter()
api.BaseRoutes.Bots = api.BaseRoutes.ApiRoot.PathPrefix("/bots").Subrouter() api.BaseRoutes.Bots = api.BaseRoutes.ApiRoot.PathPrefix("/bots").Subrouter()
api.BaseRoutes.Bot = api.BaseRoutes.ApiRoot.PathPrefix("/bots/{bot_user_id:[A-Za-z0-9]+}").Subrouter() api.BaseRoutes.Bot = api.BaseRoutes.ApiRoot.PathPrefix("/bots/{bot_user_id:[A-Za-z0-9]+}").Subrouter()

Просмотреть файл

@@ -675,6 +675,21 @@ func TestGetUserByUsername(t *testing.T) {
require.NotEmpty(t, ruser.Email, "email should not be blank") require.NotEmpty(t, ruser.Email, "email should not be blank")
require.NotEmpty(t, ruser.FirstName, "first name should not be blank") require.NotEmpty(t, ruser.FirstName, "first name should not be blank")
require.NotEmpty(t, ruser.LastName, "last name should not be blank") require.NotEmpty(t, ruser.LastName, "last name should not be blank")
t.Run("Get user with a / character in the email", func(t *testing.T) {
user := &model.User{
Email: "email/with/slashes@example.com",
Username: GenerateTestUsername(),
Password: "Pa$$word11",
}
newUser, resp := th.SystemAdminClient.CreateUser(user)
require.Nil(t, resp.Error)
ruser, resp := th.SystemAdminClient.GetUserByEmail(user.Email, "")
require.Nil(t, resp.Error)
require.Equal(t, ruser.Id, newUser.Id)
})
} }
func TestGetUserByUsernameWithAcceptedTermsOfService(t *testing.T) { func TestGetUserByUsernameWithAcceptedTermsOfService(t *testing.T) {