[MM-16512] Migrate Token.Save to Sync by default (#11353)
* [MM-16512] Migrate Token.Save to Sync by default * refactor: formatting * test: add checks for errors while saving tokens * test: fixup
Этот коммит содержится в:
@@ -205,7 +205,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
TOKEN_TYPE_VERIFY_EMAIL,
|
||||
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id}),
|
||||
)
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
require.Nil(t, th.App.Srv.Store.Token().Save(token))
|
||||
defer th.App.DeleteToken(token)
|
||||
if _, err := th.App.AddUserToTeamByToken(ruser.Id, token.Token); err == nil {
|
||||
t.Fatal("Should fail on bad token type")
|
||||
@@ -218,7 +218,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id}),
|
||||
)
|
||||
token.CreateAt = model.GetMillis() - TEAM_INVITATION_EXPIRY_TIME - 1
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
require.Nil(t, th.App.Srv.Store.Token().Save(token))
|
||||
defer th.App.DeleteToken(token)
|
||||
if _, err := th.App.AddUserToTeamByToken(ruser.Id, token.Token); err == nil {
|
||||
t.Fatal("Should fail on expired token")
|
||||
@@ -230,7 +230,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
TOKEN_TYPE_TEAM_INVITATION,
|
||||
model.MapToJson(map[string]string{"teamId": model.NewId()}),
|
||||
)
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
require.Nil(t, th.App.Srv.Store.Token().Save(token))
|
||||
defer th.App.DeleteToken(token)
|
||||
if _, err := th.App.AddUserToTeamByToken(ruser.Id, token.Token); err == nil {
|
||||
t.Fatal("Should fail on bad team id")
|
||||
@@ -242,7 +242,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
TOKEN_TYPE_TEAM_INVITATION,
|
||||
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id}),
|
||||
)
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
require.Nil(t, th.App.Srv.Store.Token().Save(token))
|
||||
defer th.App.DeleteToken(token)
|
||||
if _, err := th.App.AddUserToTeamByToken(model.NewId(), token.Token); err == nil {
|
||||
t.Fatal("Should fail on bad user id")
|
||||
@@ -254,7 +254,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
TOKEN_TYPE_TEAM_INVITATION,
|
||||
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id}),
|
||||
)
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
require.Nil(t, th.App.Srv.Store.Token().Save(token))
|
||||
if _, err := th.App.AddUserToTeamByToken(ruser.Id, token.Token); err != nil {
|
||||
t.Log(err)
|
||||
t.Fatal("Should add user to the team")
|
||||
@@ -274,7 +274,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
TOKEN_TYPE_TEAM_INVITATION,
|
||||
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id}),
|
||||
)
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
require.Nil(t, th.App.Srv.Store.Token().Save(token))
|
||||
if _, err := th.App.AddUserToTeamByToken(ruser.Id, token.Token); err == nil {
|
||||
t.Fatal("Should return an error when trying to join a group-constrained team.")
|
||||
} else {
|
||||
@@ -303,7 +303,7 @@ func TestAddUserToTeamByToken(t *testing.T) {
|
||||
TOKEN_TYPE_TEAM_INVITATION,
|
||||
model.MapToJson(map[string]string{"teamId": th.BasicTeam.Id}),
|
||||
)
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
require.Nil(t, th.App.Srv.Store.Token().Save(token))
|
||||
|
||||
if _, err := th.App.AddUserToTeamByToken(ruser.Id, token.Token); err == nil || err.Where != "JoinUserToTeam" {
|
||||
t.Log(err)
|
||||
|
||||
Ссылка в новой задаче
Block a user