Updating user attributes on oauth login (#5324)

Moving update function to app package
Fixing duplicate userID on create user test
Этот коммит содержится в:
Poornima
2017-02-27 00:18:01 +05:30
коммит произвёл Joram Wilander
родитель 04f4545bbd
Коммит c0bb6f99f8
6 изменённых файлов: 237 добавлений и 4 удалений

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

@@ -4,10 +4,11 @@
package store
import (
"github.com/mattermost/platform/model"
"strings"
"testing"
"time"
"github.com/mattermost/platform/model"
)
func TestUserStoreSave(t *testing.T) {
@@ -103,6 +104,32 @@ func TestUserStoreUpdate(t *testing.T) {
if err := (<-store.User().Update(u2, false)).Err; err == nil {
t.Fatal("Update should have failed because you can't modify AD/LDAP fields")
}
u3 := &model.User{}
u3.Email = model.NewId()
oldEmail := u3.Email
u3.AuthService = "gitlab"
Must(store.User().Save(u3))
Must(store.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u3.Id}))
u3.Email = model.NewId()
if result := <-store.User().Update(u3, false); result.Err != nil {
t.Fatal("Update should not have failed")
} else {
newUser := result.Data.([2]*model.User)[0]
if newUser.Email != oldEmail {
t.Fatal("Email should not have been updated as the update is not trusted")
}
}
if result := <-store.User().Update(u3, true); result.Err != nil {
t.Fatal("Update should not have failed")
} else {
newUser := result.Data.([2]*model.User)[0]
if newUser.Email != u3.Email {
t.Fatal("Email should have been updated as the update is trusted")
}
}
}
func TestUserStoreUpdateUpdateAt(t *testing.T) {