diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-02-27 23:25:28 +0900 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-02-27 09:25:28 -0500 |
commit | 71d010b7af3601b0690407af328ec2865e3a0efd (patch) | |
tree | cd8f6a3dce8846641e304d9396e8c098004049f5 /api4/user_test.go | |
parent | 19b753467d37209f2227567637e60138d05dd405 (diff) | |
download | chat-71d010b7af3601b0690407af328ec2865e3a0efd.tar.gz chat-71d010b7af3601b0690407af328ec2865e3a0efd.tar.bz2 chat-71d010b7af3601b0690407af328ec2865e3a0efd.zip |
APIv4: GET /users/{user_id}/image (#5526)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r-- | api4/user_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go index ee6cf079b..5cdab21f5 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -261,6 +261,39 @@ func TestGetUserByEmail(t *testing.T) { } } +func TestGetProfileImage(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + user := th.BasicUser + + data, resp := Client.GetProfileImage(user.Id, "") + CheckNoError(t, resp) + if data == nil || len(data) == 0 { + t.Fatal("Should not be empty") + } + + _, resp = Client.GetProfileImage(user.Id, resp.Etag) + if resp.StatusCode != http.StatusNotModified { + t.Fatal("Should have hit etag") + } + + _, resp = Client.GetProfileImage("junk", "") + CheckBadRequestStatus(t, resp) + + Client.Logout() + _, resp = Client.GetProfileImage(user.Id, "") + CheckUnauthorizedStatus(t, resp) + + _, resp = th.SystemAdminClient.GetProfileImage(user.Id, "") + CheckNoError(t, resp) + + info := &model.FileInfo{Path: "/users/" + user.Id + "/profile.png"} + if err := cleanupTestFile(info); err != nil { + t.Fatal(err) + } +} + func TestGetUsersByIds(t *testing.T) { th := Setup().InitBasic() Client := th.Client |