diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-01 16:13:16 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-02-01 16:13:16 -0500 |
commit | 36f43edba3481a19476943942bff1ab53cc14e0f (patch) | |
tree | 4f2925a492cb594e6c80a7f569395528139307ce /api4/user_test.go | |
parent | 187aff9fa8bd7616b5a93aefaa2e9166d5d3d4ab (diff) | |
download | chat-36f43edba3481a19476943942bff1ab53cc14e0f.tar.gz chat-36f43edba3481a19476943942bff1ab53cc14e0f.tar.bz2 chat-36f43edba3481a19476943942bff1ab53cc14e0f.zip |
Implement PUT /users/{user_id}/roles endpoint for APIv4 (#5238)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r-- | api4/user_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go index c55c70b36..713e0268b 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -182,3 +182,27 @@ func TestUpdateUser(t *testing.T) { _, resp = th.SystemAdminClient.UpdateUser(user) CheckNoError(t, resp) } + +func TestUpdateUserRoles(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + Client := th.Client + SystemAdminClient := th.SystemAdminClient + + _, resp := Client.UpdateUserRoles(th.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id) + CheckForbiddenStatus(t, resp) + + _, resp = SystemAdminClient.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id) + CheckNoError(t, resp) + + _, resp = SystemAdminClient.UpdateUserRoles(th.BasicUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id) + CheckNoError(t, resp) + + _, resp = SystemAdminClient.UpdateUserRoles(th.BasicUser.Id, "junk") + CheckBadRequestStatus(t, resp) + + _, resp = SystemAdminClient.UpdateUserRoles("junk", model.ROLE_SYSTEM_USER.Id) + CheckBadRequestStatus(t, resp) + + _, resp = SystemAdminClient.UpdateUserRoles(model.NewId(), model.ROLE_SYSTEM_USER.Id) + CheckBadRequestStatus(t, resp) +} |