summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store_test.go
diff options
context:
space:
mode:
authorPoornima <mpoornima@users.noreply.github.com>2017-02-27 00:18:01 +0530
committerJoram Wilander <jwawilander@gmail.com>2017-02-26 13:48:01 -0500
commitc0bb6f99f89259f6728856ace23d5dd505494b26 (patch)
tree024fb446bef25eb74763da14f8e98a6685807af6 /store/sql_user_store_test.go
parent04f4545bbd6c9a1f85071483e96e29684871d547 (diff)
downloadchat-c0bb6f99f89259f6728856ace23d5dd505494b26.tar.gz
chat-c0bb6f99f89259f6728856ace23d5dd505494b26.tar.bz2
chat-c0bb6f99f89259f6728856ace23d5dd505494b26.zip
Updating user attributes on oauth login (#5324)
Moving update function to app package Fixing duplicate userID on create user test
Diffstat (limited to 'store/sql_user_store_test.go')
-rw-r--r--store/sql_user_store_test.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go
index c46a32ec1..e509653c1 100644
--- a/store/sql_user_store_test.go
+++ b/store/sql_user_store_test.go
@@ -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) {