mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* add endpoint and tests for revoking all sessions for a user * fix failing test build
This commit is contained in:
@@ -1971,6 +1971,51 @@ func TestRevokeSessions(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
func TestRevokeAllSessions(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.BasicUser
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
_, resp := Client.RevokeAllSessions(th.BasicUser2.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.InitSystemAdmin()
|
||||
|
||||
_, resp = Client.RevokeAllSessions("junk" + user.Id)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
status, resp := Client.RevokeAllSessions(user.Id)
|
||||
if status == false {
|
||||
t.Fatal("user all sessions revoke unsuccessful")
|
||||
}
|
||||
CheckNoError(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
_, resp = Client.RevokeAllSessions(user.Id)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
sessions, _ := Client.GetSessions(user.Id, "")
|
||||
if len(sessions) < 1 {
|
||||
t.Fatal("session should exist")
|
||||
}
|
||||
|
||||
_, resp = Client.RevokeAllSessions(user.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
sessions, _ = th.SystemAdminClient.GetSessions(user.Id, "")
|
||||
if len(sessions) != 0 {
|
||||
t.Fatal("no sessions should exist for user")
|
||||
}
|
||||
|
||||
_, resp = Client.RevokeAllSessions(user.Id)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestAttachDeviceId(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Reference in New Issue
Block a user