diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-04-18 00:06:33 +0900 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-04-17 11:06:33 -0400 |
commit | 742bab6429aeb1b581275da3c06af99fe293baab (patch) | |
tree | f5fb57770677d09081061eccbaf23d4a7fab6f9d /api4/user_test.go | |
parent | a2f5ad0d1422001a0fbbad4dd0004faf5244ea55 (diff) | |
download | chat-742bab6429aeb1b581275da3c06af99fe293baab.tar.gz chat-742bab6429aeb1b581275da3c06af99fe293baab.tar.bz2 chat-742bab6429aeb1b581275da3c06af99fe293baab.zip |
APIv4 PUT /users/{user_id}/active (#6118)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r-- | api4/user_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go index 2ff665c8a..95271984c 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -850,6 +850,49 @@ func TestUpdateUserRoles(t *testing.T) { CheckBadRequestStatus(t, resp) } +func TestUpdateUserActive(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + Client := th.Client + SystemAdminClient := th.SystemAdminClient + user := th.BasicUser + + pass, resp := Client.UpdateUserActive(user.Id, false) + CheckNoError(t, resp) + + if !pass { + t.Fatal("should have returned true") + } + + pass, resp = Client.UpdateUserActive(user.Id, false) + CheckUnauthorizedStatus(t, resp) + + if pass { + t.Fatal("should have returned false") + } + + th.LoginBasic2() + + _, resp = Client.UpdateUserActive(user.Id, true) + CheckForbiddenStatus(t, resp) + + _, resp = Client.UpdateUserActive(GenerateTestId(), true) + CheckForbiddenStatus(t, resp) + + _, resp = Client.UpdateUserActive("junk", true) + CheckBadRequestStatus(t, resp) + + Client.Logout() + + _, resp = Client.UpdateUserActive(user.Id, true) + CheckUnauthorizedStatus(t, resp) + + _, resp = SystemAdminClient.UpdateUserActive(user.Id, true) + CheckNoError(t, resp) + + _, resp = SystemAdminClient.UpdateUserActive(user.Id, false) + CheckNoError(t, resp) +} + func TestGetUsers(t *testing.T) { th := Setup().InitBasic() defer TearDown() |