diff options
Diffstat (limited to 'api4/user_test.go')
-rw-r--r-- | api4/user_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go index 501bb38e3..54aae4e49 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -131,6 +131,38 @@ func TestGetUser(t *testing.T) { } } +func TestGetUsersByIds(t *testing.T) { + th := Setup().InitBasic() + Client := th.Client + + users, resp := Client.GetUsersByIds([]string{th.BasicUser.Id}) + CheckNoError(t, resp) + + if users[0].Id != th.BasicUser.Id { + t.Fatal("returned wrong user") + } + CheckUserSanitization(t, users[0]) + + _, resp = Client.GetUsersByIds([]string{}) + CheckBadRequestStatus(t, resp) + + users, resp = Client.GetUsersByIds([]string{"junk"}) + CheckNoError(t, resp) + if len(users) > 0 { + t.Fatal("no users should be returned") + } + + users, resp = Client.GetUsersByIds([]string{"junk", th.BasicUser.Id}) + CheckNoError(t, resp) + if len(users) != 1 { + t.Fatal("1 user should be returned") + } + + Client.Logout() + _, resp = Client.GetUsersByIds([]string{th.BasicUser.Id}) + CheckUnauthorizedStatus(t, resp) +} + func TestUpdateUser(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() |