diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-01-06 09:14:21 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-01-06 09:14:21 -0500 |
commit | cc5e8be7331ef2d85dd70261d90cde63d3e82993 (patch) | |
tree | 479ee2b5a7450b0af6c8e4a48d6448f2fd27fdc0 /api/user_test.go | |
parent | 50fa6d1aea40e30b8178ec3d71f59b6ae7dd1d31 (diff) | |
parent | e432b66641b9f11e505a8497efaeea53ab4b6ce0 (diff) | |
download | chat-cc5e8be7331ef2d85dd70261d90cde63d3e82993.tar.gz chat-cc5e8be7331ef2d85dd70261d90cde63d3e82993.tar.bz2 chat-cc5e8be7331ef2d85dd70261d90cde63d3e82993.zip |
Merge pull request #1809 from mattermost/PLT-1557
PLT-1557 revoking sessions from same device
Diffstat (limited to 'api/user_test.go')
-rw-r--r-- | api/user_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/api/user_test.go b/api/user_test.go index ffa96cb66..9a172805a 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -162,6 +162,37 @@ func TestLogin(t *testing.T) { Client.AuthToken = authToken } +func TestLoginWithDeviceId(t *testing.T) { + Setup() + + team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + rteam, _ := Client.CreateTeam(&team) + + user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"} + ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(ruser.Id)) + + deviceId := model.NewId() + if result, err := Client.LoginByEmailWithDevice(team.Name, user.Email, user.Password, deviceId); err != nil { + t.Fatal(err) + } else { + ruser := result.Data.(*model.User) + + if ssresult, err := Client.GetSessions(ruser.Id); err != nil { + t.Fatal(err) + } else { + sessions := ssresult.Data.([]*model.Session) + if _, err := Client.LoginByEmailWithDevice(team.Name, user.Email, user.Password, deviceId); err != nil { + t.Fatal(err) + } + + if sresult := <-Srv.Store.Session().Get(sessions[0].Id); sresult.Err == nil { + t.Fatal("session should have been removed") + } + } + } +} + func TestSessions(t *testing.T) { Setup() |