Skip to content

Commit

Permalink
Changing ids
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyhulen committed Feb 23, 2017
1 parent b943d70 commit 573fce4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
33 changes: 32 additions & 1 deletion api/user_test.go
Expand Up @@ -1097,7 +1097,38 @@ func TestUserUpdateDeviceId(t *testing.T) {

Client.Login(user.Email, "passwd1")
Client.SetTeamId(team.Id)
deviceId := model.PUSH_NOTIFY_APPLE_V1 + ":1234567890"
deviceId := model.PUSH_NOTIFY_APPLE + ":1234567890"

if _, err := Client.AttachDeviceId(deviceId); err != nil {
t.Fatal(err)
}

if result := <-app.Srv.Store.Session().GetSessions(user.Id); result.Err != nil {
t.Fatal(result.Err)
} else {
sessions := result.Data.([]*model.Session)

if sessions[0].DeviceId != deviceId {
t.Fatal("Missing device Id")
}
}
}

func TestUserUpdateDeviceId2(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient

team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)

user := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
LinkUserToTeam(user, team)
store.Must(app.Srv.Store.User().VerifyEmail(user.Id))

Client.Login(user.Email, "passwd1")
Client.SetTeamId(team.Id)
deviceId := model.PUSH_NOTIFY_APPLE_REACT_NATIVE + ":1234567890"

if _, err := Client.AttachDeviceId(deviceId); err != nil {
t.Fatal(err)
Expand Down
8 changes: 4 additions & 4 deletions model/push_notification.go
Expand Up @@ -10,10 +10,10 @@ import (
)

const (
PUSH_NOTIFY_APPLE_V1 = "apple"
PUSH_NOTIFY_ANDROID_V1 = "android"
PUSH_NOTIFY_APPLE_V2 = "apple2"
PUSH_NOTIFY_ANDROID_V2 = "android2"
PUSH_NOTIFY_APPLE = "apple"
PUSH_NOTIFY_ANDROID = "android"
PUSH_NOTIFY_APPLE_REACT_NATIVE = "apple_rn"
PUSH_NOTIFY_ANDROID_REACT_NATIVE = "android_rn"

PUSH_TYPE_MESSAGE = "message"
PUSH_TYPE_CLEAR = "clear"
Expand Down
20 changes: 20 additions & 0 deletions store/sql_session_store_test.go
Expand Up @@ -197,6 +197,26 @@ func TestSessionUpdateDeviceId(t *testing.T) {
}
}

func TestSessionUpdateDeviceId2(t *testing.T) {
Setup()

s1 := model.Session{}
s1.UserId = model.NewId()
Must(store.Session().Save(&s1))

if rs1 := (<-store.Session().UpdateDeviceId(s1.Id, model.PUSH_NOTIFY_APPLE_REACT_NATIVE+":1234567890", s1.ExpiresAt)); rs1.Err != nil {
t.Fatal(rs1.Err)
}

s2 := model.Session{}
s2.UserId = model.NewId()
Must(store.Session().Save(&s2))

if rs2 := (<-store.Session().UpdateDeviceId(s2.Id, model.PUSH_NOTIFY_APPLE_REACT_NATIVE+":1234567890", s1.ExpiresAt)); rs2.Err != nil {
t.Fatal(rs2.Err)
}
}

func TestSessionStoreUpdateLastActivityAt(t *testing.T) {
Setup()

Expand Down

0 comments on commit 573fce4

Please sign in to comment.