From ccb034382850b7e8ea924a4559e47ef44203155c Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 3 Feb 2017 09:30:57 -0500 Subject: Implement POST /users/ids endpoint for APIv4 (#5274) --- api4/user_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'api4/user_test.go') 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() -- cgit v1.2.3-1-g7c22