@@ -41,10 +41,6 @@ issues:
|
|||||||
- unused
|
- unused
|
||||||
text: "SetupEnterprise"
|
text: "SetupEnterprise"
|
||||||
|
|
||||||
- linters:
|
|
||||||
- staticcheck
|
|
||||||
path: ".*_test.go|store/storetest"
|
|
||||||
|
|
||||||
- linters:
|
- linters:
|
||||||
- golint
|
- golint
|
||||||
text: "should have|should be|should replace|stutters|underscore|annoying|error strings should not be capitalized"
|
text: "should have|should be|should replace|stutters|underscore|annoying|error strings should not be capitalized"
|
||||||
|
|||||||
@@ -1450,7 +1450,7 @@ func TestConvertBotToUser(t *testing.T) {
|
|||||||
require.NotNil(t, user)
|
require.NotNil(t, user)
|
||||||
require.Equal(t, bot.UserId, user.Id)
|
require.Equal(t, bot.UserId, user.Id)
|
||||||
|
|
||||||
bot, resp = client.GetBot(bot.UserId, "")
|
_, resp = client.GetBot(bot.UserId, "")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
|
|
||||||
bot = &model.Bot{
|
bot = &model.Bot{
|
||||||
@@ -1466,7 +1466,7 @@ func TestConvertBotToUser(t *testing.T) {
|
|||||||
require.Equal(t, bot.UserId, user.Id)
|
require.Equal(t, bot.UserId, user.Id)
|
||||||
require.Contains(t, user.GetRoles(), model.SystemAdminRoleId)
|
require.Contains(t, user.GetRoles(), model.SystemAdminRoleId)
|
||||||
|
|
||||||
bot, resp = client.GetBot(bot.UserId, "")
|
_, resp = client.GetBot(bot.UserId, "")
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,13 +180,13 @@ func TestUpdateChannel(t *testing.T) {
|
|||||||
// Test that changing the type fails and returns error
|
// Test that changing the type fails and returns error
|
||||||
|
|
||||||
private.Type = model.ChannelTypeOpen
|
private.Type = model.ChannelTypeOpen
|
||||||
newPrivateChannel, resp = Client.UpdateChannel(private)
|
_, resp = Client.UpdateChannel(private)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
// Test that keeping the same type succeeds
|
// Test that keeping the same type succeeds
|
||||||
|
|
||||||
private.Type = model.ChannelTypePrivate
|
private.Type = model.ChannelTypePrivate
|
||||||
newPrivateChannel, resp = Client.UpdateChannel(private)
|
_, resp = Client.UpdateChannel(private)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
//Non existing channel
|
//Non existing channel
|
||||||
|
|||||||
@@ -63,13 +63,6 @@ func TestGetConfigWithAccessTag(t *testing.T) {
|
|||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
varyByHeader := *&th.App.Config().RateLimitSettings.VaryByHeader // environment perm.
|
|
||||||
supportEmail := *&th.App.Config().SupportSettings.SupportEmail // site perm.
|
|
||||||
defer th.App.UpdateConfig(func(cfg *model.Config) {
|
|
||||||
cfg.RateLimitSettings.VaryByHeader = varyByHeader
|
|
||||||
cfg.SupportSettings.SupportEmail = supportEmail
|
|
||||||
})
|
|
||||||
|
|
||||||
// set some values so that we know they're not blank
|
// set some values so that we know they're not blank
|
||||||
mockVaryByHeader := model.NewId()
|
mockVaryByHeader := model.NewId()
|
||||||
mockSupportEmail := model.NewId() + "@mattermost.com"
|
mockSupportEmail := model.NewId() + "@mattermost.com"
|
||||||
@@ -353,7 +346,7 @@ func TestUpdateConfigMessageExportSpecialHandling(t *testing.T) {
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
*cfg.MessageExportSettings.EnableExport = true
|
*cfg.MessageExportSettings.EnableExport = true
|
||||||
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
_, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
assert.True(t, *th.App.Config().MessageExportSettings.EnableExport)
|
assert.True(t, *th.App.Config().MessageExportSettings.EnableExport)
|
||||||
@@ -364,7 +357,7 @@ func TestUpdateConfigMessageExportSpecialHandling(t *testing.T) {
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
*cfg.MessageExportSettings.EnableExport = false
|
*cfg.MessageExportSettings.EnableExport = false
|
||||||
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
_, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
assert.False(t, *th.App.Config().MessageExportSettings.EnableExport)
|
assert.False(t, *th.App.Config().MessageExportSettings.EnableExport)
|
||||||
@@ -381,7 +374,7 @@ func TestUpdateConfigMessageExportSpecialHandling(t *testing.T) {
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
*cfg.MessageExportSettings.EnableExport = true
|
*cfg.MessageExportSettings.EnableExport = true
|
||||||
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
_, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
assert.True(t, *th.App.Config().MessageExportSettings.EnableExport)
|
assert.True(t, *th.App.Config().MessageExportSettings.EnableExport)
|
||||||
@@ -392,7 +385,7 @@ func TestUpdateConfigMessageExportSpecialHandling(t *testing.T) {
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
*cfg.MessageExportSettings.EnableExport = false
|
*cfg.MessageExportSettings.EnableExport = false
|
||||||
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
_, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
assert.False(t, *th.App.Config().MessageExportSettings.EnableExport)
|
assert.False(t, *th.App.Config().MessageExportSettings.EnableExport)
|
||||||
@@ -745,7 +738,7 @@ func TestPatchConfig(t *testing.T) {
|
|||||||
SiteURL: model.NewString(""),
|
SiteURL: model.NewString(""),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
updatedConfig, resp = th.SystemAdminClient.PatchConfig(&config)
|
_, resp = th.SystemAdminClient.PatchConfig(&config)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
CheckErrorMessage(t, resp, "api.config.update_config.clear_siteurl.app_error")
|
CheckErrorMessage(t, resp, "api.config.update_config.clear_siteurl.app_error")
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func TestCreateEmoji(t *testing.T) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
newEmoji, resp = Client.CreateEmoji(emoji, utils.CreateTestGif(t, 10, app.MaxEmojiOriginalWidth+1), "image.gif")
|
_, resp = Client.CreateEmoji(emoji, utils.CreateTestGif(t, 10, app.MaxEmojiOriginalWidth+1), "image.gif")
|
||||||
require.NotNil(t, resp.Error, "should fail - emoji is too wide")
|
require.NotNil(t, resp.Error, "should fail - emoji is too wide")
|
||||||
|
|
||||||
// try to create an emoji that's too tall
|
// try to create an emoji that's too tall
|
||||||
@@ -137,7 +137,7 @@ func TestCreateEmoji(t *testing.T) {
|
|||||||
Name: model.NewId(),
|
Name: model.NewId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
newEmoji, resp = Client.CreateEmoji(emoji, utils.CreateTestGif(t, app.MaxEmojiOriginalHeight+1, 10), "image.gif")
|
_, resp = Client.CreateEmoji(emoji, utils.CreateTestGif(t, app.MaxEmojiOriginalHeight+1, 10), "image.gif")
|
||||||
require.NotNil(t, resp.Error, "should fail - emoji is too tall")
|
require.NotNil(t, resp.Error, "should fail - emoji is too tall")
|
||||||
|
|
||||||
// try to create an emoji that's too large
|
// try to create an emoji that's too large
|
||||||
|
|||||||
@@ -669,8 +669,8 @@ func TestUploadFiles(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if !bytes.Equal(data, expected) {
|
if !bytes.Equal(data, expected) {
|
||||||
tf, err := ioutil.TempFile("", fmt.Sprintf("test_%v_*_%s", i, name))
|
tf, err := ioutil.TempFile("", fmt.Sprintf("test_%v_*_%s", i, name))
|
||||||
defer tf.Close()
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
defer tf.Close()
|
||||||
_, err = io.Copy(tf, bytes.NewReader(data))
|
_, err = io.Copy(tf, bytes.NewReader(data))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Errorf("Actual data mismatched %s, written to %q - expected %d bytes, got %d.", name, tf.Name(), len(expected), len(data))
|
t.Errorf("Actual data mismatched %s, written to %q - expected %d bytes, got %d.", name, tf.Name(), len(expected), len(data))
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ func TestPatchGroupTeam(t *testing.T) {
|
|||||||
assert.Equal(t, model.GroupSyncableTypeTeam, groupSyncable.Type)
|
assert.Equal(t, model.GroupSyncableTypeTeam, groupSyncable.Type)
|
||||||
|
|
||||||
patch.AutoAdd = model.NewBool(true)
|
patch.AutoAdd = model.NewBool(true)
|
||||||
groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
_, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||||
CheckOKStatus(t, response)
|
CheckOKStatus(t, response)
|
||||||
|
|
||||||
_, response = th.SystemAdminClient.PatchGroupSyncable(model.NewId(), th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
_, response = th.SystemAdminClient.PatchGroupSyncable(model.NewId(), th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||||
@@ -628,7 +628,7 @@ func TestPatchGroupChannel(t *testing.T) {
|
|||||||
assert.Equal(t, model.GroupSyncableTypeChannel, groupSyncable.Type)
|
assert.Equal(t, model.GroupSyncableTypeChannel, groupSyncable.Type)
|
||||||
|
|
||||||
patch.AutoAdd = model.NewBool(true)
|
patch.AutoAdd = model.NewBool(true)
|
||||||
groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
_, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||||
CheckOKStatus(t, response)
|
CheckOKStatus(t, response)
|
||||||
|
|
||||||
_, response = th.SystemAdminClient.PatchGroupSyncable(model.NewId(), th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
_, response = th.SystemAdminClient.PatchGroupSyncable(model.NewId(), th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ func testCreatePostWithOutgoingHook(
|
|||||||
ResponseType: respPostType,
|
ResponseType: respPostType,
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, outGoingHookResponse.ToJson())
|
fmt.Fprint(w, outGoingHookResponse.ToJson())
|
||||||
success <- true
|
success <- true
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
@@ -835,7 +835,7 @@ func TestUpdateOthersPostInDirectMessageChannel(t *testing.T) {
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
post.Message = "changed"
|
post.Message = "changed"
|
||||||
post, resp = th.SystemAdminClient.UpdatePost(post.Id, post)
|
_, resp = th.SystemAdminClient.UpdatePost(post.Id, post)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1422,7 +1422,7 @@ func TestGetPostsBefore(t *testing.T) {
|
|||||||
require.Equal(t, post3.Id, posts.NextPostId, "should match NextPostId")
|
require.Equal(t, post3.Id, posts.NextPostId, "should match NextPostId")
|
||||||
require.Equal(t, post1.Id, posts.PrevPostId, "should match PrevPostId")
|
require.Equal(t, post1.Id, posts.PrevPostId, "should match PrevPostId")
|
||||||
|
|
||||||
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, "junk", 1, 1, "", false)
|
_, resp = Client.GetPostsBefore(th.BasicChannel.Id, "junk", 1, 1, "", false)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post5.Id, 0, 3, "", false)
|
posts, resp = Client.GetPostsBefore(th.BasicChannel.Id, post5.Id, 0, 3, "", false)
|
||||||
@@ -1562,7 +1562,7 @@ func TestGetPostsAfter(t *testing.T) {
|
|||||||
require.Equal(t, post5.Id, posts.NextPostId, "should match NextPostId")
|
require.Equal(t, post5.Id, posts.NextPostId, "should match NextPostId")
|
||||||
require.Equal(t, post3.Id, posts.PrevPostId, "should match PrevPostId")
|
require.Equal(t, post3.Id, posts.PrevPostId, "should match PrevPostId")
|
||||||
|
|
||||||
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, "junk", 1, 1, "", false)
|
_, resp = Client.GetPostsAfter(th.BasicChannel.Id, "junk", 1, 1, "", false)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post1.Id, 0, 3, "", false)
|
posts, resp = Client.GetPostsAfter(th.BasicChannel.Id, post1.Id, 0, 3, "", false)
|
||||||
|
|||||||
@@ -2015,7 +2015,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
_, resp = Client.Login(guest.Email, guest.Password)
|
_, resp = Client.Login(guest.Email, guest.Password)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
tm, resp = Client.AddTeamMemberFromInvite("", team.InviteId)
|
_, resp = Client.AddTeamMemberFromInvite("", team.InviteId)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
// by invite_id
|
// by invite_id
|
||||||
@@ -2046,11 +2046,11 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
model.MapToJson(map[string]string{"teamId": team.Id}),
|
model.MapToJson(map[string]string{"teamId": team.Id}),
|
||||||
)
|
)
|
||||||
require.NoError(t, th.App.Srv().Store.Token().Save(token))
|
require.NoError(t, th.App.Srv().Store.Token().Save(token))
|
||||||
tm, resp = Client.AddTeamMemberFromInvite(token.Token, "")
|
_, resp = Client.AddTeamMemberFromInvite(token.Token, "")
|
||||||
require.Equal(t, "app.team.invite_token.group_constrained.error", resp.Error.Id)
|
require.Equal(t, "app.team.invite_token.group_constrained.error", resp.Error.Id)
|
||||||
|
|
||||||
// Attempt to use an invite id
|
// Attempt to use an invite id
|
||||||
tm, resp = Client.AddTeamMemberFromInvite("", team.InviteId)
|
_, resp = Client.AddTeamMemberFromInvite("", team.InviteId)
|
||||||
require.Equal(t, "app.team.invite_id.group_constrained.error", resp.Error.Id)
|
require.Equal(t, "app.team.invite_id.group_constrained.error", resp.Error.Id)
|
||||||
|
|
||||||
// User is not in associated groups so shouldn't be allowed
|
// User is not in associated groups so shouldn't be allowed
|
||||||
|
|||||||
@@ -5453,12 +5453,10 @@ func TestGetThreadsForUser(t *testing.T) {
|
|||||||
|
|
||||||
var rootIds []*model.Post
|
var rootIds []*model.Post
|
||||||
for i := 0; i < 30; i++ {
|
for i := 0; i < 30; i++ {
|
||||||
time.Sleep(1)
|
|
||||||
rpost, resp := Client.CreatePost(&model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
|
rpost, resp := Client.CreatePost(&model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
CheckCreatedStatus(t, resp)
|
CheckCreatedStatus(t, resp)
|
||||||
rootIds = append(rootIds, rpost)
|
rootIds = append(rootIds, rpost)
|
||||||
time.Sleep(1)
|
|
||||||
_, resp2 := Client.CreatePost(&model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
|
_, resp2 := Client.CreatePost(&model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
|
||||||
CheckNoError(t, resp2)
|
CheckNoError(t, resp2)
|
||||||
CheckCreatedStatus(t, resp2)
|
CheckCreatedStatus(t, resp2)
|
||||||
@@ -5482,10 +5480,8 @@ func TestGetThreadsForUser(t *testing.T) {
|
|||||||
|
|
||||||
var rootIds []*model.Post
|
var rootIds []*model.Post
|
||||||
for i := 0; i < 30; i++ {
|
for i := 0; i < 30; i++ {
|
||||||
time.Sleep(1)
|
|
||||||
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: fmt.Sprintf("testMsg-%d", i)})
|
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: fmt.Sprintf("testMsg-%d", i)})
|
||||||
rootIds = append(rootIds, rpost)
|
rootIds = append(rootIds, rpost)
|
||||||
time.Sleep(1)
|
|
||||||
postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: fmt.Sprintf("testReply-%d", i), RootId: rpost.Id})
|
postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: fmt.Sprintf("testReply-%d", i), RootId: rpost.Id})
|
||||||
}
|
}
|
||||||
rootId := rootIds[15].Id // middle point
|
rootId := rootIds[15].Id // middle point
|
||||||
@@ -5822,14 +5818,11 @@ func TestThreadCounts(t *testing.T) {
|
|||||||
// create a post by regular user
|
// create a post by regular user
|
||||||
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
|
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
|
||||||
// reply with another
|
// reply with another
|
||||||
time.Sleep(1)
|
|
||||||
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
|
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
|
||||||
|
|
||||||
// create another post by regular user
|
// create another post by regular user
|
||||||
time.Sleep(1)
|
|
||||||
rpost2, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testMsg1"})
|
rpost2, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testMsg1"})
|
||||||
// reply with another 2 times
|
// reply with another 2 times
|
||||||
time.Sleep(1)
|
|
||||||
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply2", RootId: rpost2.Id})
|
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply2", RootId: rpost2.Id})
|
||||||
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply22", RootId: rpost2.Id})
|
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply22", RootId: rpost2.Id})
|
||||||
|
|
||||||
@@ -5868,12 +5861,10 @@ func TestSingleThreadGet(t *testing.T) {
|
|||||||
// create a post by regular user
|
// create a post by regular user
|
||||||
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
|
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
|
||||||
// reply with another
|
// reply with another
|
||||||
time.Sleep(1)
|
|
||||||
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
|
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
|
||||||
|
|
||||||
// create another thread to check that we are not returning it by mistake
|
// create another thread to check that we are not returning it by mistake
|
||||||
rpost2, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testMsg2"})
|
rpost2, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testMsg2"})
|
||||||
time.Sleep(1)
|
|
||||||
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply", RootId: rpost2.Id})
|
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply", RootId: rpost2.Id})
|
||||||
|
|
||||||
// regular user should have two threads with 3 replies total
|
// regular user should have two threads with 3 replies total
|
||||||
@@ -5982,7 +5973,6 @@ func TestReadThreads(t *testing.T) {
|
|||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
require.Len(t, uss.Threads, 1)
|
require.Len(t, uss.Threads, 1)
|
||||||
|
|
||||||
time.Sleep(1)
|
|
||||||
resp = th.Client.UpdateThreadsReadForUser(th.BasicUser.Id, th.BasicTeam.Id)
|
resp = th.Client.UpdateThreadsReadForUser(th.BasicUser.Id, th.BasicTeam.Id)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
CheckOKStatus(t, resp)
|
CheckOKStatus(t, resp)
|
||||||
@@ -6044,9 +6034,7 @@ func TestMarkThreadUnreadMentionCount(t *testing.T) {
|
|||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg @" + th.BasicUser2.Username})
|
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg @" + th.BasicUser2.Username})
|
||||||
time.Sleep(1)
|
|
||||||
reply, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply1", RootId: rpost.Id})
|
reply, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply1", RootId: rpost.Id})
|
||||||
time.Sleep(1)
|
|
||||||
postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply2", RootId: rpost.Id})
|
postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply2", RootId: rpost.Id})
|
||||||
|
|
||||||
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, model.GetMillis())
|
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, model.GetMillis())
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ func TestCreateIncomingWebhook_BypassTeamPermissions(t *testing.T) {
|
|||||||
channel := th.CreateChannelWithClientAndTeam(th.SystemAdminClient, model.ChannelTypeOpen, team.Id)
|
channel := th.CreateChannelWithClientAndTeam(th.SystemAdminClient, model.ChannelTypeOpen, team.Id)
|
||||||
|
|
||||||
hook = &model.IncomingWebhook{ChannelId: channel.Id}
|
hook = &model.IncomingWebhook{ChannelId: channel.Id}
|
||||||
rhook, resp = th.Client.CreateIncomingWebhook(hook)
|
_, resp = th.Client.CreateIncomingWebhook(hook)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -915,7 +915,7 @@ func TestUpdateIncomingWebhook_BypassTeamPermissions(t *testing.T) {
|
|||||||
channel := th.CreateChannelWithClientAndTeam(th.SystemAdminClient, model.ChannelTypeOpen, team.Id)
|
channel := th.CreateChannelWithClientAndTeam(th.SystemAdminClient, model.ChannelTypeOpen, team.Id)
|
||||||
|
|
||||||
hook2 := &model.IncomingWebhook{Id: rhook.Id, ChannelId: channel.Id}
|
hook2 := &model.IncomingWebhook{Id: rhook.Id, ChannelId: channel.Id}
|
||||||
rhook, resp = th.Client.UpdateIncomingWebhook(hook2)
|
_, resp = th.Client.UpdateIncomingWebhook(hook2)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1171,7 +1171,7 @@ func TestUpdateOutgoingWebhook_BypassTeamPermissions(t *testing.T) {
|
|||||||
channel := th.CreateChannelWithClientAndTeam(th.SystemAdminClient, model.ChannelTypeOpen, team.Id)
|
channel := th.CreateChannelWithClientAndTeam(th.SystemAdminClient, model.ChannelTypeOpen, team.Id)
|
||||||
|
|
||||||
hook2 := &model.OutgoingWebhook{Id: rhook.Id, ChannelId: channel.Id}
|
hook2 := &model.OutgoingWebhook{Id: rhook.Id, ChannelId: channel.Id}
|
||||||
rhook, resp = th.Client.UpdateOutgoingWebhook(hook2)
|
_, resp = th.Client.UpdateOutgoingWebhook(hook2)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
|||||||
channel = th.createPrivateChannel(th.BasicTeam)
|
channel = th.createPrivateChannel(th.BasicTeam)
|
||||||
resp.ChannelId = channel.Id
|
resp.ChannelId = channel.Id
|
||||||
args.UserId = th.BasicUser2.Id
|
args.UserId = th.BasicUser2.Id
|
||||||
post, err = th.App.HandleCommandResponsePost(th.Context, command, args, resp, builtIn)
|
_, err = th.App.HandleCommandResponsePost(th.Context, command, args, resp, builtIn)
|
||||||
|
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
require.Equal(t, err.Id, "api.command.command_post.forbidden.app_error")
|
require.Equal(t, err.Id, "api.command.command_post.forbidden.app_error")
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ func TestScheduler(t *testing.T) {
|
|||||||
ConfigService: &testutils.StaticConfigService{
|
ConfigService: &testutils.StaticConfigService{
|
||||||
Cfg: &model.Config{
|
Cfg: &model.Config{
|
||||||
// mock config
|
// mock config
|
||||||
DataRetentionSettings: *&model.DataRetentionSettings{
|
DataRetentionSettings: model.DataRetentionSettings{
|
||||||
EnableMessageDeletion: model.NewBool(true),
|
EnableMessageDeletion: model.NewBool(true),
|
||||||
},
|
},
|
||||||
MessageExportSettings: *&model.MessageExportSettings{
|
MessageExportSettings: model.MessageExportSettings{
|
||||||
EnableExport: model.NewBool(true),
|
EnableExport: model.NewBool(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -246,7 +246,15 @@ func TestBotPreSave(t *testing.T) {
|
|||||||
DeleteAt: 0,
|
DeleteAt: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
originalBot := &*bot
|
originalBot := &Bot{
|
||||||
|
UserId: bot.UserId,
|
||||||
|
Username: bot.Username,
|
||||||
|
DisplayName: bot.DisplayName,
|
||||||
|
Description: bot.Description,
|
||||||
|
OwnerId: bot.OwnerId,
|
||||||
|
LastIconUpdate: bot.LastIconUpdate,
|
||||||
|
DeleteAt: bot.DeleteAt,
|
||||||
|
}
|
||||||
|
|
||||||
bot.PreSave()
|
bot.PreSave()
|
||||||
assert.NotEqual(t, 0, bot.CreateAt)
|
assert.NotEqual(t, 0, bot.CreateAt)
|
||||||
@@ -269,11 +277,20 @@ func TestBotPreUpdate(t *testing.T) {
|
|||||||
DeleteAt: 0,
|
DeleteAt: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
originalBot := &*bot
|
originalBot := &Bot{
|
||||||
|
UserId: bot.UserId,
|
||||||
|
Username: bot.Username,
|
||||||
|
DisplayName: bot.DisplayName,
|
||||||
|
Description: bot.Description,
|
||||||
|
OwnerId: bot.OwnerId,
|
||||||
|
LastIconUpdate: bot.LastIconUpdate,
|
||||||
|
DeleteAt: bot.DeleteAt,
|
||||||
|
}
|
||||||
|
|
||||||
bot.PreSave()
|
bot.PreSave()
|
||||||
assert.NotEqual(t, 0, bot.UpdateAt)
|
assert.NotEqual(t, 0, bot.UpdateAt)
|
||||||
|
|
||||||
|
originalBot.CreateAt = bot.CreateAt
|
||||||
originalBot.UpdateAt = bot.UpdateAt
|
originalBot.UpdateAt = bot.UpdateAt
|
||||||
assert.Equal(t, originalBot, bot)
|
assert.Equal(t, originalBot, bot)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ func TestConfigIsValidDefaultAlgorithms(t *testing.T) {
|
|||||||
|
|
||||||
func TestConfigServiceProviderDefault(t *testing.T) {
|
func TestConfigServiceProviderDefault(t *testing.T) {
|
||||||
c1 := &Config{
|
c1 := &Config{
|
||||||
SamlSettings: *&SamlSettings{
|
SamlSettings: SamlSettings{
|
||||||
Enable: NewBool(true),
|
Enable: NewBool(true),
|
||||||
Verify: NewBool(false),
|
Verify: NewBool(false),
|
||||||
Encrypt: NewBool(false),
|
Encrypt: NewBool(false),
|
||||||
|
|||||||
@@ -111,12 +111,10 @@ func (s *BleveEngineTestSuite) TestDeleteChannelPosts() {
|
|||||||
userID := model.NewId()
|
userID := model.NewId()
|
||||||
channelID := model.NewId()
|
channelID := model.NewId()
|
||||||
channelToAvoidID := model.NewId()
|
channelToAvoidID := model.NewId()
|
||||||
posts := make([]*model.Post, 0)
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
post := createPost(userID, channelID)
|
post := createPost(userID, channelID)
|
||||||
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
|
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
|
||||||
require.Nil(s.T(), appErr)
|
require.Nil(s.T(), appErr)
|
||||||
posts = append(posts, post)
|
|
||||||
}
|
}
|
||||||
postToAvoid := createPost(userID, channelToAvoidID)
|
postToAvoid := createPost(userID, channelToAvoidID)
|
||||||
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
|
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
|
||||||
@@ -159,12 +157,10 @@ func (s *BleveEngineTestSuite) TestDeleteUserPosts() {
|
|||||||
userID := model.NewId()
|
userID := model.NewId()
|
||||||
userToAvoidID := model.NewId()
|
userToAvoidID := model.NewId()
|
||||||
channelID := model.NewId()
|
channelID := model.NewId()
|
||||||
posts := make([]*model.Post, 0)
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
post := createPost(userID, channelID)
|
post := createPost(userID, channelID)
|
||||||
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
|
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
|
||||||
require.Nil(s.T(), appErr)
|
require.Nil(s.T(), appErr)
|
||||||
posts = append(posts, post)
|
|
||||||
}
|
}
|
||||||
postToAvoid := createPost(userToAvoidID, channelID)
|
postToAvoid := createPost(userToAvoidID, channelID)
|
||||||
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
|
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
|
||||||
@@ -206,12 +202,10 @@ func (s *BleveEngineTestSuite) TestDeletePosts() {
|
|||||||
userID := model.NewId()
|
userID := model.NewId()
|
||||||
userToAvoidID := model.NewId()
|
userToAvoidID := model.NewId()
|
||||||
channelID := model.NewId()
|
channelID := model.NewId()
|
||||||
posts := make([]*model.Post, 0)
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
post := createPost(userID, channelID)
|
post := createPost(userID, channelID)
|
||||||
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
|
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
|
||||||
require.Nil(s.T(), appErr)
|
require.Nil(s.T(), appErr)
|
||||||
posts = append(posts, post)
|
|
||||||
}
|
}
|
||||||
postToAvoid := createPost(userToAvoidID, channelID)
|
postToAvoid := createPost(userToAvoidID, channelID)
|
||||||
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
|
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
m.Run()
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ func TestFixCRTCountsAndUnreads(t *testing.T) {
|
|||||||
cm2, err := ss.Channel().GetMember(context.Background(), c1.Id, uId2)
|
cm2, err := ss.Channel().GetMember(context.Background(), c1.Id, uId2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cm2.LastViewedAt = lastReplyAt - 10
|
cm2.LastViewedAt = lastReplyAt - 10
|
||||||
cm2, err = ss.Channel().UpdateMember(cm2)
|
_, err = ss.Channel().UpdateMember(cm2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Update ThreadMembership with bad data, as we might expect because
|
// Update ThreadMembership with bad data, as we might expect because
|
||||||
|
|||||||
@@ -659,20 +659,20 @@ func testChannelStoreGetByName(t *testing.T, ss store.Store) {
|
|||||||
|
|
||||||
channelID := result.Id
|
channelID := result.Id
|
||||||
|
|
||||||
result, err = ss.Channel().GetByName(o1.TeamId, "", true)
|
_, err = ss.Channel().GetByName(o1.TeamId, "", true)
|
||||||
require.Error(t, err, "Missing id should have failed")
|
require.Error(t, err, "Missing id should have failed")
|
||||||
|
|
||||||
result, err = ss.Channel().GetByName(o1.TeamId, o1.Name, false)
|
result, err = ss.Channel().GetByName(o1.TeamId, o1.Name, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, o1.ToJson(), result.ToJson(), "invalid returned channel")
|
require.Equal(t, o1.ToJson(), result.ToJson(), "invalid returned channel")
|
||||||
|
|
||||||
result, err = ss.Channel().GetByName(o1.TeamId, "", false)
|
_, err = ss.Channel().GetByName(o1.TeamId, "", false)
|
||||||
require.Error(t, err, "Missing id should have failed")
|
require.Error(t, err, "Missing id should have failed")
|
||||||
|
|
||||||
nErr = ss.Channel().Delete(channelID, model.GetMillis())
|
nErr = ss.Channel().Delete(channelID, model.GetMillis())
|
||||||
require.NoError(t, nErr, "channel should have been deleted")
|
require.NoError(t, nErr, "channel should have been deleted")
|
||||||
|
|
||||||
result, err = ss.Channel().GetByName(o1.TeamId, o1.Name, false)
|
_, err = ss.Channel().GetByName(o1.TeamId, o1.Name, false)
|
||||||
require.Error(t, err, "Deleted channel should not be returned by GetByName()")
|
require.Error(t, err, "Deleted channel should not be returned by GetByName()")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) {
|
|||||||
post.UserId = u1.Id
|
post.UserId = u1.Id
|
||||||
post.CreateAt = createAt
|
post.CreateAt = createAt
|
||||||
post.Message = "zz" + model.NewId() + "b"
|
post.Message = "zz" + model.NewId() + "b"
|
||||||
post, nErr = ss.Post().Save(post)
|
_, nErr = ss.Post().Save(post)
|
||||||
require.NoError(t, nErr)
|
require.NoError(t, nErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -967,12 +967,14 @@ func testUpsertMember(t *testing.T, ss store.Store) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
groupMembers, err := ss.Group().GetMemberUsers(group.Id)
|
groupMembers, err := ss.Group().GetMemberUsers(group.Id)
|
||||||
|
require.NoError(t, err)
|
||||||
beforeRestoreCount := len(groupMembers)
|
beforeRestoreCount := len(groupMembers)
|
||||||
|
|
||||||
_, err = ss.Group().UpsertMember(group.Id, user.Id)
|
_, err = ss.Group().UpsertMember(group.Id, user.Id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
groupMembers, err = ss.Group().GetMemberUsers(group.Id)
|
groupMembers, err = ss.Group().GetMemberUsers(group.Id)
|
||||||
|
require.NoError(t, err)
|
||||||
afterRestoreCount := len(groupMembers)
|
afterRestoreCount := len(groupMembers)
|
||||||
|
|
||||||
require.Equal(t, beforeRestoreCount+1, afterRestoreCount)
|
require.Equal(t, beforeRestoreCount+1, afterRestoreCount)
|
||||||
|
|||||||
@@ -1285,7 +1285,6 @@ func testPluginList(t *testing.T, ss store.Store) {
|
|||||||
pluginId := model.NewId()
|
pluginId := model.NewId()
|
||||||
|
|
||||||
var keys []string
|
var keys []string
|
||||||
var expiredKeys []string
|
|
||||||
now := model.GetMillis()
|
now := model.GetMillis()
|
||||||
for i := 0; i < 150; i++ {
|
for i := 0; i < 150; i++ {
|
||||||
key := model.NewId()
|
key := model.NewId()
|
||||||
@@ -1311,8 +1310,6 @@ func testPluginList(t *testing.T, ss store.Store) {
|
|||||||
|
|
||||||
if expireAt == 0 || expireAt > now {
|
if expireAt == 0 || expireAt > now {
|
||||||
keys = append(keys, key)
|
keys = append(keys, key)
|
||||||
} else {
|
|
||||||
expiredKeys = append(expiredKeys, key)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ func testPostStoreGetSingle(t *testing.T, ss store.Store) {
|
|||||||
o4.Message = model.NewRandomString(10)
|
o4.Message = model.NewRandomString(10)
|
||||||
o4.RootId = o1.Id
|
o4.RootId = o1.Id
|
||||||
|
|
||||||
o3, err = ss.Post().Save(o3)
|
_, err = ss.Post().Save(o3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
o4, err = ss.Post().Save(o4)
|
o4, err = ss.Post().Save(o4)
|
||||||
@@ -500,7 +500,7 @@ func testPostStoreGetSingle(t *testing.T, ss store.Store) {
|
|||||||
require.Equal(t, post.CreateAt, o1.CreateAt, "invalid returned post")
|
require.Equal(t, post.CreateAt, o1.CreateAt, "invalid returned post")
|
||||||
require.Equal(t, int64(1), post.ReplyCount, "wrong replyCount computed")
|
require.Equal(t, int64(1), post.ReplyCount, "wrong replyCount computed")
|
||||||
|
|
||||||
post, err = ss.Post().GetSingle(o2.Id, false)
|
_, err = ss.Post().GetSingle(o2.Id, false)
|
||||||
require.Error(t, err, "should not return deleted post")
|
require.Error(t, err, "should not return deleted post")
|
||||||
|
|
||||||
post, err = ss.Post().GetSingle(o2.Id, true)
|
post, err = ss.Post().GetSingle(o2.Id, true)
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ func testRemoteClusterGetAll(t *testing.T, ss store.Store) {
|
|||||||
|
|
||||||
idsAll := make([]string, 0)
|
idsAll := make([]string, 0)
|
||||||
idsOnline := make([]string, 0)
|
idsOnline := make([]string, 0)
|
||||||
idsOffline := make([]string, 0)
|
|
||||||
idsShareTopic := make([]string, 0)
|
idsShareTopic := make([]string, 0)
|
||||||
|
|
||||||
for _, item := range data {
|
for _, item := range data {
|
||||||
@@ -131,8 +130,6 @@ func testRemoteClusterGetAll(t *testing.T, ss store.Store) {
|
|||||||
idsAll = append(idsAll, saved.RemoteId)
|
idsAll = append(idsAll, saved.RemoteId)
|
||||||
if online {
|
if online {
|
||||||
idsOnline = append(idsOnline, saved.RemoteId)
|
idsOnline = append(idsOnline, saved.RemoteId)
|
||||||
} else {
|
|
||||||
idsOffline = append(idsOffline, saved.RemoteId)
|
|
||||||
}
|
}
|
||||||
if strings.Contains(saved.Topics, " shared ") {
|
if strings.Contains(saved.Topics, " shared ") {
|
||||||
idsShareTopic = append(idsShareTopic, saved.RemoteId)
|
idsShareTopic = append(idsShareTopic, saved.RemoteId)
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ func testSessionGet(t *testing.T, ss store.Store) {
|
|||||||
s2 := &model.Session{}
|
s2 := &model.Session{}
|
||||||
s2.UserId = s1.UserId
|
s2.UserId = s1.UserId
|
||||||
|
|
||||||
s2, err = ss.Session().Save(s2)
|
_, err = ss.Session().Save(s2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s3 := &model.Session{}
|
s3 := &model.Session{}
|
||||||
s3.UserId = s1.UserId
|
s3.UserId = s1.UserId
|
||||||
s3.ExpiresAt = 1
|
s3.ExpiresAt = 1
|
||||||
|
|
||||||
s3, err = ss.Session().Save(s3)
|
_, err = ss.Session().Save(s3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
session, err := ss.Session().Get(context.Background(), s1.Id)
|
session, err := ss.Session().Get(context.Background(), s1.Id)
|
||||||
@@ -88,7 +88,7 @@ func testSessionGetWithDeviceId(t *testing.T, ss store.Store) {
|
|||||||
s2.DeviceId = model.NewId()
|
s2.DeviceId = model.NewId()
|
||||||
s2.ExpiresAt = model.GetMillis() + 10000
|
s2.ExpiresAt = model.GetMillis() + 10000
|
||||||
|
|
||||||
s2, err = ss.Session().Save(s2)
|
_, err = ss.Session().Save(s2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s3 := &model.Session{}
|
s3 := &model.Session{}
|
||||||
@@ -96,7 +96,7 @@ func testSessionGetWithDeviceId(t *testing.T, ss store.Store) {
|
|||||||
s3.ExpiresAt = 1
|
s3.ExpiresAt = 1
|
||||||
s3.DeviceId = model.NewId()
|
s3.DeviceId = model.NewId()
|
||||||
|
|
||||||
s3, err = ss.Session().Save(s3)
|
_, err = ss.Session().Save(s3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
data, err := ss.Session().GetSessionsWithActiveDeviceIds(s1.UserId)
|
data, err := ss.Session().GetSessionsWithActiveDeviceIds(s1.UserId)
|
||||||
@@ -255,7 +255,7 @@ func testSessionCount(t *testing.T, ss store.Store) {
|
|||||||
s1.UserId = model.NewId()
|
s1.UserId = model.NewId()
|
||||||
s1.ExpiresAt = model.GetMillis() + 100000
|
s1.ExpiresAt = model.GetMillis() + 100000
|
||||||
|
|
||||||
s1, err := ss.Session().Save(s1)
|
_, err := ss.Session().Save(s1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
count, err := ss.Session().AnalyticsSessionCount()
|
count, err := ss.Session().AnalyticsSessionCount()
|
||||||
@@ -326,7 +326,7 @@ func testGetSessionsExpired(t *testing.T, ss store.Store) {
|
|||||||
s1.UserId = model.NewId()
|
s1.UserId = model.NewId()
|
||||||
s1.DeviceId = model.NewId()
|
s1.DeviceId = model.NewId()
|
||||||
s1.ExpiresAt = 0 // never expires
|
s1.ExpiresAt = 0 // never expires
|
||||||
s1, err = ss.Session().Save(s1)
|
_, err = ss.Session().Save(s1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s2 := &model.Session{}
|
s2 := &model.Session{}
|
||||||
@@ -340,7 +340,7 @@ func testGetSessionsExpired(t *testing.T, ss store.Store) {
|
|||||||
s3.UserId = model.NewId()
|
s3.UserId = model.NewId()
|
||||||
s3.DeviceId = model.NewId()
|
s3.DeviceId = model.NewId()
|
||||||
s3.ExpiresAt = now - (TenMinutes * 100) // expired outside threshold
|
s3.ExpiresAt = now - (TenMinutes * 100) // expired outside threshold
|
||||||
s3, err = ss.Session().Save(s3)
|
_, err = ss.Session().Save(s3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s4 := &model.Session{}
|
s4 := &model.Session{}
|
||||||
@@ -353,7 +353,7 @@ func testGetSessionsExpired(t *testing.T, ss store.Store) {
|
|||||||
s5.UserId = model.NewId()
|
s5.UserId = model.NewId()
|
||||||
s5.DeviceId = model.NewId()
|
s5.DeviceId = model.NewId()
|
||||||
s5.ExpiresAt = now + (TenMinutes * 100000) // not expired
|
s5.ExpiresAt = now + (TenMinutes * 100000) // not expired
|
||||||
s5, err = ss.Session().Save(s5)
|
_, err = ss.Session().Save(s5)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
sessions, err := ss.Session().GetSessionsExpired(TenMinutes*2, true, true) // mobile only
|
sessions, err := ss.Session().GetSessionsExpired(TenMinutes*2, true, true) // mobile only
|
||||||
|
|||||||
@@ -668,15 +668,13 @@ func testGetRemoteForUser(t *testing.T, ss store.Store) {
|
|||||||
{RemoteId: model.NewId(), SiteURL: model.NewId(), CreatorId: model.NewId(), RemoteTeamId: teamId, Name: "Test_Remote_2"},
|
{RemoteId: model.NewId(), SiteURL: model.NewId(), CreatorId: model.NewId(), RemoteTeamId: teamId, Name: "Test_Remote_2"},
|
||||||
{RemoteId: model.NewId(), SiteURL: model.NewId(), CreatorId: model.NewId(), RemoteTeamId: teamId, Name: "Test_Remote_3"},
|
{RemoteId: model.NewId(), SiteURL: model.NewId(), CreatorId: model.NewId(), RemoteTeamId: teamId, Name: "Test_Remote_3"},
|
||||||
}
|
}
|
||||||
var channelRemotes []*model.SharedChannelRemote
|
|
||||||
for _, rc := range remotes {
|
for _, rc := range remotes {
|
||||||
_, err := ss.RemoteCluster().Save(rc)
|
_, err := ss.RemoteCluster().Save(rc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
scr := &model.SharedChannelRemote{Id: model.NewId(), CreatorId: rc.CreatorId, ChannelId: channel.Id, RemoteId: rc.RemoteId}
|
scr := &model.SharedChannelRemote{Id: model.NewId(), CreatorId: rc.CreatorId, ChannelId: channel.Id, RemoteId: rc.RemoteId}
|
||||||
scr, err = ss.SharedChannel().SaveRemote(scr)
|
_, err = ss.SharedChannel().SaveRemote(scr)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
channelRemotes = append(channelRemotes, scr)
|
|
||||||
}
|
}
|
||||||
users := []string{model.NewId(), model.NewId(), model.NewId()}
|
users := []string{model.NewId(), model.NewId(), model.NewId()}
|
||||||
for _, id := range users {
|
for _, id := range users {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func testUserAccessTokenDisableEnable(t *testing.T, ss store.Store) {
|
|||||||
s2.UserId = uat.UserId
|
s2.UserId = uat.UserId
|
||||||
s2.Token = uat.Token
|
s2.Token = uat.Token
|
||||||
|
|
||||||
s2, err = ss.Session().Save(s2)
|
_, err = ss.Session().Save(s2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
nErr = ss.UserAccessToken().UpdateTokenEnable(uat.Id)
|
nErr = ss.UserAccessToken().UpdateTokenEnable(uat.Id)
|
||||||
@@ -136,7 +136,7 @@ func testUserAccessTokenSearch(t *testing.T, ss store.Store) {
|
|||||||
s1.UserId = uat.UserId
|
s1.UserId = uat.UserId
|
||||||
s1.Token = uat.Token
|
s1.Token = uat.Token
|
||||||
|
|
||||||
s1, nErr := ss.Session().Save(s1)
|
_, nErr := ss.Session().Save(s1)
|
||||||
require.NoError(t, nErr)
|
require.NoError(t, nErr)
|
||||||
|
|
||||||
_, nErr = ss.UserAccessToken().Save(uat)
|
_, nErr = ss.UserAccessToken().Save(uat)
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ func testWebhookStoreDeleteIncoming(t *testing.T, ss store.Store) {
|
|||||||
err = ss.Webhook().DeleteIncoming(o1.Id, model.GetMillis())
|
err = ss.Webhook().DeleteIncoming(o1.Id, model.GetMillis())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
webhook, err = ss.Webhook().GetIncoming(o1.Id, true)
|
_, err = ss.Webhook().GetIncoming(o1.Id, true)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ func testWebhookStoreGetOutgoingByChannelByUser(t *testing.T, ss store.Store) {
|
|||||||
o2.TeamId = model.NewId()
|
o2.TeamId = model.NewId()
|
||||||
o2.CallbackURLs = []string{"http://nowhere.com/"}
|
o2.CallbackURLs = []string{"http://nowhere.com/"}
|
||||||
|
|
||||||
o2, err = ss.Webhook().SaveOutgoing(o2)
|
_, err = ss.Webhook().SaveOutgoing(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Run("GetOutgoingByChannelByUser, no user filter", func(t *testing.T) {
|
t.Run("GetOutgoingByChannelByUser, no user filter", func(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user