summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-10-31 12:00:21 -0400
committerGeorge Goldberg <george@gberg.me>2017-10-31 16:00:21 +0000
commit06ec648cf30e3968c0fdb2514c8d59dff97c757c (patch)
treec801a9bbbdeca6704b91d5d093cb937db5cd9d00 /api
parent6886de04d4215ea45ae535b64a604a79292bff77 (diff)
downloadchat-06ec648cf30e3968c0fdb2514c8d59dff97c757c.tar.gz
chat-06ec648cf30e3968c0fdb2514c8d59dff97c757c.tar.bz2
chat-06ec648cf30e3968c0fdb2514c8d59dff97c757c.zip
PLT-7978 Add websocket event for user role update (#7745)
* Add websocket event for user role update * Fix tests * More test fixes
Diffstat (limited to 'api')
-rw-r--r--api/apitestlib.go4
-rw-r--r--api/oauth_test.go6
-rw-r--r--api/team_test.go2
-rw-r--r--api/user.go2
-rw-r--r--api/user_test.go2
5 files changed, 8 insertions, 8 deletions
diff --git a/api/apitestlib.go b/api/apitestlib.go
index 0548f7843..52e6f300e 100644
--- a/api/apitestlib.go
+++ b/api/apitestlib.go
@@ -115,7 +115,7 @@ func (me *TestHelper) InitBasic() *TestHelper {
me.BasicClient = me.CreateClient()
me.BasicUser = me.CreateUser(me.BasicClient)
- me.App.UpdateUserRoles(me.BasicUser.Id, model.ROLE_SYSTEM_USER.Id)
+ me.App.UpdateUserRoles(me.BasicUser.Id, model.ROLE_SYSTEM_USER.Id, false)
me.LoginBasic()
me.BasicTeam = me.CreateTeam(me.BasicClient)
me.LinkUserToTeam(me.BasicUser, me.BasicTeam)
@@ -142,7 +142,7 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
me.SystemAdminTeam = me.CreateTeam(me.SystemAdminClient)
me.LinkUserToTeam(me.SystemAdminUser, me.SystemAdminTeam)
me.SystemAdminClient.SetTeamId(me.SystemAdminTeam.Id)
- me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id)
+ me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id, false)
me.SystemAdminChannel = me.CreateChannel(me.SystemAdminClient, me.SystemAdminTeam)
return me
diff --git a/api/oauth_test.go b/api/oauth_test.go
index 0b18a4e47..395eaade7 100644
--- a/api/oauth_test.go
+++ b/api/oauth_test.go
@@ -78,7 +78,7 @@ func TestOAuthRegisterApp(t *testing.T) {
user := &model.User{Email: strings.ToLower("test+"+model.NewId()) + "@simulator.amazonses.com", Password: "hello1", Username: "n" + model.NewId(), EmailVerified: true}
ruser := Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
- th.App.UpdateUserRoles(ruser.Id, "")
+ th.App.UpdateUserRoles(ruser.Id, "", false)
Client.Logout()
Client.Login(user.Email, user.Password)
@@ -257,7 +257,7 @@ func TestOAuthGetAppsByUser(t *testing.T) {
user := &model.User{Email: strings.ToLower("test+"+model.NewId()) + "@simulator.amazonses.com", Password: "hello1", Username: "n" + model.NewId(), EmailVerified: true}
ruser := Client.Must(AdminClient.CreateUser(user, "")).Data.(*model.User)
- th.App.UpdateUserRoles(ruser.Id, "")
+ th.App.UpdateUserRoles(ruser.Id, "", false)
Client.Logout()
Client.Login(user.Email, user.Password)
@@ -480,7 +480,7 @@ func TestOAuthDeleteApp(t *testing.T) {
user := &model.User{Email: strings.ToLower("test+"+model.NewId()) + "@simulator.amazonses.com", Password: "hello1", Username: "n" + model.NewId(), EmailVerified: true}
ruser := Client.Must(AdminClient.CreateUser(user, "")).Data.(*model.User)
- th.App.UpdateUserRoles(ruser.Id, "")
+ th.App.UpdateUserRoles(ruser.Id, "", false)
Client.Logout()
Client.Login(user.Email, user.Password)
diff --git a/api/team_test.go b/api/team_test.go
index 680bd7ea7..8aa8a32de 100644
--- a/api/team_test.go
+++ b/api/team_test.go
@@ -395,7 +395,7 @@ func TestGetAllTeamListings(t *testing.T) {
}
}
- th.App.UpdateUserRoles(user.Id, model.ROLE_SYSTEM_ADMIN.Id)
+ th.App.UpdateUserRoles(user.Id, model.ROLE_SYSTEM_ADMIN.Id, false)
Client.Login(user.Email, "passwd1")
Client.SetTeamId(team.Id)
diff --git a/api/user.go b/api/user.go
index e1fa63bfa..4a3b52417 100644
--- a/api/user.go
+++ b/api/user.go
@@ -699,7 +699,7 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if _, err := c.App.UpdateUserRoles(userId, newRoles); err != nil {
+ if _, err := c.App.UpdateUserRoles(userId, newRoles, true); err != nil {
return
} else {
c.LogAuditWithUserId(userId, "roles="+newRoles)
diff --git a/api/user_test.go b/api/user_test.go
index 05b6a844f..27408f292 100644
--- a/api/user_test.go
+++ b/api/user_test.go
@@ -483,7 +483,7 @@ func TestGetUser(t *testing.T) {
t.Fatal("shouldn't have accss")
}
- th.App.UpdateUserRoles(ruser.Data.(*model.User).Id, model.ROLE_SYSTEM_ADMIN.Id)
+ th.App.UpdateUserRoles(ruser.Data.(*model.User).Id, model.ROLE_SYSTEM_ADMIN.Id, false)
Client.Login(user.Email, "passwd1")