diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2016-11-22 00:50:57 +0100 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-11-21 18:50:57 -0500 |
commit | d57ab7a81e295c0f1a731f1f4f5fa04d5cba398b (patch) | |
tree | 92c3505680dbecce1bc933d1257194fd0b6b6790 /api/user_test.go | |
parent | 82352e63633f95d546fc2d4b9f768a62cb4b6d58 (diff) | |
download | chat-d57ab7a81e295c0f1a731f1f4f5fa04d5cba398b.tar.gz chat-d57ab7a81e295c0f1a731f1f4f5fa04d5cba398b.tar.bz2 chat-d57ab7a81e295c0f1a731f1f4f5fa04d5cba398b.zip |
PLT-3762 - Add API call to get a user by their username (#4611)
* PLT-3762 - Add API call to get a user by their username
* fix lint
* update rote
* update per code review
* update per code review
* remove first/last name is not used in this test
Diffstat (limited to 'api/user_test.go')
-rw-r--r-- | api/user_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/api/user_test.go b/api/user_test.go index bc804ca11..a10cee961 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -2339,3 +2339,42 @@ func TestAutocompleteUsers(t *testing.T) { t.Fatal("should have errored - bad team id") } } + +func TestGetByUsername(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + + if result, err := Client.GetByUsername(th.BasicUser.Username, ""); err != nil { + t.Fatal("Failed to get user") + } else { + if result.Data.(*model.User).Password != "" { + t.Fatal("User shouldn't have any password data once set") + } + } + + emailPrivacy := utils.Cfg.PrivacySettings.ShowEmailAddress + namePrivacy := utils.Cfg.PrivacySettings.ShowFullName + defer func() { + utils.Cfg.PrivacySettings.ShowEmailAddress = emailPrivacy + utils.Cfg.PrivacySettings.ShowFullName = namePrivacy + }() + + utils.Cfg.PrivacySettings.ShowEmailAddress = false + utils.Cfg.PrivacySettings.ShowFullName = false + + if result, err := Client.GetByUsername(th.BasicUser2.Username, ""); err != nil { + t.Fatal(err) + } else { + u := result.Data.(*model.User) + if u.Password != "" { + t.Fatal("password must be empty") + } + if *u.AuthData != "" { + t.Fatal("auth data must be empty") + } + if u.Email != "" { + t.Fatal("email should be sanitized") + } + } + +} |