MM-10007 Send an admin and regular WS events when a user is updated (#8588)
* Add user.DeepCopy() function * Add omit admins/non-admins to WS broadcast and use for updating users * Updates per feedback and adding unit test for ShouldSendEvent
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7987c95fcd
Коммит
283f34b9c6
@@ -8,6 +8,8 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPasswordHash(t *testing.T) {
|
||||
@@ -22,6 +24,36 @@ func TestPasswordHash(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserDeepCopy(t *testing.T) {
|
||||
id := NewId()
|
||||
authData := "authdata"
|
||||
mapKey := "key"
|
||||
mapValue := "key"
|
||||
|
||||
user := &User{Id: id, AuthData: NewString(authData), Props: map[string]string{}, NotifyProps: map[string]string{}, Timezone: map[string]string{}}
|
||||
user.Props[mapKey] = mapValue
|
||||
user.NotifyProps[mapKey] = mapValue
|
||||
user.Timezone[mapKey] = mapValue
|
||||
|
||||
copyUser := user.DeepCopy()
|
||||
copyUser.Id = "someid"
|
||||
*copyUser.AuthData = "changed"
|
||||
copyUser.Props[mapKey] = "changed"
|
||||
copyUser.NotifyProps[mapKey] = "changed"
|
||||
copyUser.Timezone[mapKey] = "changed"
|
||||
|
||||
assert.Equal(t, id, user.Id)
|
||||
assert.Equal(t, authData, *user.AuthData)
|
||||
assert.Equal(t, mapValue, user.Props[mapKey])
|
||||
assert.Equal(t, mapValue, user.NotifyProps[mapKey])
|
||||
assert.Equal(t, mapValue, user.Timezone[mapKey])
|
||||
|
||||
user = &User{Id: id}
|
||||
copyUser = user.DeepCopy()
|
||||
|
||||
assert.Equal(t, id, user.Id)
|
||||
}
|
||||
|
||||
func TestUserJson(t *testing.T) {
|
||||
user := User{Id: NewId(), Username: NewId()}
|
||||
json := user.ToJson()
|
||||
|
||||
Ссылка в новой задаче
Block a user