Этот коммит содержится в:
Ben Schumacher
2023-10-11 10:13:36 +02:00
коммит произвёл GitHub
родитель 176370e175
Коммит 0d5a8b8841
189 изменённых файлов: 1 добавлений и 361 удалений

Просмотреть файл

@@ -1325,7 +1325,6 @@ func TestAssignBot(t *testing.T) {
_, _, err = th.Client.AssignBot(context.Background(), bot.UserId, bot2.UserId)
CheckErrorID(t, err, "api.context.permissions.app_error")
})
}

Просмотреть файл

@@ -834,7 +834,6 @@ func TestDeleteGroupChannel(t *testing.T) {
_, err = client.DeleteChannel(context.Background(), rgc.Id)
CheckErrorID(t, err, "api.channel.delete_channel.type.invalid")
})
}
func TestGetChannel(t *testing.T) {
@@ -2020,7 +2019,6 @@ func TestDeleteChannel(t *testing.T) {
require.NoError(t, err)
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
th.LoginBasic()
publicChannel5 := th.CreatePublicChannel()
c.Logout(context.Background())
@@ -2041,9 +2039,7 @@ func TestDeleteChannel(t *testing.T) {
_, err = client.DeleteChannel(context.Background(), publicChannel5.Id)
require.NoError(t, err)
})
}
func TestDeleteChannel2(t *testing.T) {
@@ -3393,7 +3389,6 @@ func TestAddChannelMemberAddMyself(t *testing.T) {
client.Login(context.Background(), user.Email, user.Password)
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
// Check the appropriate permissions are enforced.
defaultRolePermissions := th.SaveDefaultRolePermissions()
defer func() {

Просмотреть файл

@@ -329,7 +329,6 @@ func Test_requestTrial(t *testing.T) {
}
func Test_validateBusinessEmail(t *testing.T) {
t.Run("Returns forbidden for invalid business email", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()

Просмотреть файл

@@ -552,7 +552,6 @@ func TestGetCommand(t *testing.T) {
newCmd, _, err := th.SystemAdminClient.CreateCommand(context.Background(), newCmd)
require.NoError(t, err)
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
t.Run("ValidId", func(t *testing.T) {
cmd, _, err := client.GetCommandById(context.Background(), newCmd.Id)
require.NoError(t, err)

Просмотреть файл

@@ -21,7 +21,6 @@ func (api *API) InitDrafts() {
}
func upsertDraft(c *Context, w http.ResponseWriter, r *http.Request) {
if !*c.App.Config().ServiceSettings.AllowSyncedDrafts {
c.Err = model.NewAppError("upsertDraft", "api.drafts.disabled.app_error", nil, "", http.StatusNotImplemented)
return

Просмотреть файл

@@ -42,7 +42,6 @@ func (api *API) InitFile() {
api.BaseRoutes.Team.Handle("/files/search", api.APISessionRequiredDisableWhenBusy(searchFiles)).Methods("POST")
api.BaseRoutes.PublicFile.Handle("", api.APIHandler(getPublicFile)).Methods("GET")
}
func parseMultipartRequestHeader(req *http.Request) (boundary string, err error) {
@@ -179,7 +178,6 @@ func uploadFileSimple(c *Context, r *http.Request, timestamp time.Time) *model.F
// entire message recursively calling itself in stream mode. In case of (b) it
// calls to uploadFileMultipartLegacy for legacy support
func uploadFileMultipart(c *Context, r *http.Request, asStream io.Reader, timestamp time.Time) *model.FileUploadResponse {
expectClientIds := true
var clientIds []string
resp := model.FileUploadResponse{
@@ -356,7 +354,6 @@ NextPart:
// *model.FileUploadResponse filled in with the individual model.FileInfo's.
func uploadFileMultipartLegacy(c *Context, mr *multipart.Reader,
timestamp time.Time) *model.FileUploadResponse {
// Parse the entire form.
form, err := mr.ReadForm(*c.App.Config().FileSettings.MaxFileSize)
if err != nil {

Просмотреть файл

@@ -97,7 +97,6 @@ func testUploadFilesPost(
clientIds []string,
useChunked bool,
) (*model.FileUploadResponse, *model.Response, error) {
// Do not check len(clientIds), leave it entirely to the user to
// provide. The server will error out if it does not match the number
// of files, but it's not critical here.
@@ -731,7 +730,6 @@ func TestUploadFiles(t *testing.T) {
th.cleanupTestFile(dbInfo)
}
})
}
}
}

Просмотреть файл

@@ -1426,7 +1426,6 @@ func TestGetGroupsByUserId(t *testing.T) {
groups, _, err = th.Client.GetGroupsByUserId(context.Background(), user1.Id)
require.NoError(t, err)
assert.ElementsMatch(t, []*model.Group{group1, group2}, groups)
}
func TestGetGroupStats(t *testing.T) {

Просмотреть файл

@@ -54,7 +54,6 @@ func (api *API) APISessionRequired(h handlerFunc) http.Handler {
return gziphandler.GzipHandler(handler)
}
return handler
}
// CloudAPIKeyRequired provides a handler for webhook endpoints to access Cloud installations from CWS
@@ -74,7 +73,6 @@ func (api *API) CloudAPIKeyRequired(h handlerFunc) http.Handler {
return gziphandler.GzipHandler(handler)
}
return handler
}
// RemoteClusterTokenRequired provides a handler for remote cluster requests to /remotecluster endpoints.
@@ -115,7 +113,6 @@ func (api *API) APISessionRequiredMfa(h handlerFunc) http.Handler {
return gziphandler.GzipHandler(handler)
}
return handler
}
// APIHandlerTrustRequester provides a handler for API endpoints which do not require the user to be logged in and are
@@ -136,7 +133,6 @@ func (api *API) APIHandlerTrustRequester(h handlerFunc) http.Handler {
return gziphandler.GzipHandler(handler)
}
return handler
}
// APISessionRequiredTrustRequester provides a handler for API endpoints which do require the user to be logged in and
@@ -156,7 +152,6 @@ func (api *API) APISessionRequiredTrustRequester(h handlerFunc) http.Handler {
return gziphandler.GzipHandler(handler)
}
return handler
}
// DisableWhenBusy provides a handler for API endpoints which should be disabled when the server is under load,
@@ -177,7 +172,6 @@ func (api *API) APISessionRequiredDisableWhenBusy(h handlerFunc) http.Handler {
return gziphandler.GzipHandler(handler)
}
return handler
}
// APILocal provides a handler for API endpoints to be used in local

Просмотреть файл

@@ -12,5 +12,4 @@ func (api *API) InitLdapLocal() {
api.BaseRoutes.LDAP.Handle("/certificate/private", api.APILocal(addLdapPrivateCertificate)).Methods("POST")
api.BaseRoutes.LDAP.Handle("/certificate/public", api.APILocal(removeLdapPublicCertificate)).Methods("DELETE")
api.BaseRoutes.LDAP.Handle("/certificate/private", api.APILocal(removeLdapPrivateCertificate)).Methods("DELETE")
}

Просмотреть файл

@@ -294,7 +294,6 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
})
t.Run("returns status 451 when it receives status 451", func(t *testing.T) {
license := model.NewTestLicense()
license.Features.Users = model.NewInt(nUsers)
licenseJSON, jsonErr := json.Marshal(license)
@@ -369,7 +368,6 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
CheckErrorID(t, err, "api.license.upgrade_needed.app_error")
CheckForbiddenStatus(t, resp)
})
}
func TestRequestTrialLicense(t *testing.T) {

Просмотреть файл

@@ -21,7 +21,6 @@ func TestNotifyAdmin(t *testing.T) {
require.Error(t, err)
require.Equal(t, http.StatusBadRequest, statusCode)
})
t.Run("error when plan is unknown when notifying on upgrade", func(t *testing.T) {
@@ -36,7 +35,6 @@ func TestNotifyAdmin(t *testing.T) {
require.Error(t, err)
require.Equal(t, ": Unable to save notify data.", err.Error())
require.Equal(t, http.StatusInternalServerError, statusCode)
})
t.Run("error when plan is unknown when notifying to trial", func(t *testing.T) {
@@ -52,7 +50,6 @@ func TestNotifyAdmin(t *testing.T) {
require.Error(t, err)
require.Equal(t, ": Unable to save notify data.", err.Error())
require.Equal(t, http.StatusInternalServerError, statusCode)
})
t.Run("error when feature is unknown when notifying on upgrade", func(t *testing.T) {
@@ -132,7 +129,6 @@ func TestTriggerNotifyAdmin(t *testing.T) {
require.Error(t, err)
require.Equal(t, ": Internal error during cloud api request.", err.Error())
require.Equal(t, http.StatusForbidden, statusCode)
})
t.Run("error when non admins try to trigger notifications", func(t *testing.T) {

Просмотреть файл

@@ -462,7 +462,6 @@ func TestDisableOnRemove(t *testing.T) {
}
func TestGetMarketplacePlugins(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -683,7 +682,6 @@ func TestGetMarketplacePlugins(t *testing.T) {
}
func TestGetInstalledMarketplacePlugins(t *testing.T) {
samplePlugins := []*model.MarketplacePlugin{
{
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
@@ -827,7 +825,6 @@ func TestGetInstalledMarketplacePlugins(t *testing.T) {
}
func TestSearchGetMarketplacePlugins(t *testing.T) {
samplePlugins := []*model.MarketplacePlugin{
{
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
@@ -953,7 +950,6 @@ func TestSearchGetMarketplacePlugins(t *testing.T) {
}
func TestGetLocalPluginInMarketplace(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -1115,7 +1111,6 @@ func TestGetLocalPluginInMarketplace(t *testing.T) {
}
func TestGetRemotePluginInMarketplace(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -1172,7 +1167,6 @@ func TestGetRemotePluginInMarketplace(t *testing.T) {
}
func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -1304,7 +1298,6 @@ func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
}
func TestInstallMarketplacePlugin(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1655,7 +1648,6 @@ func TestInstallMarketplacePlugin(t *testing.T) {
}
func TestInstallMarketplacePluginPrepackagedDisabled(t *testing.T) {
path, _ := fileutils.FindDir("tests")
signatureFilename := "testplugin2.tar.gz.sig"

Просмотреть файл

@@ -1358,7 +1358,6 @@ func TestPatchPost(t *testing.T) {
})
t.Run("err with integrations-reserved props", func(t *testing.T) {
originalHardenedModeSetting := *th.App.Config().ServiceSettings.ExperimentalEnableHardenedMode
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ExperimentalEnableHardenedMode = true

Просмотреть файл

@@ -192,7 +192,6 @@ func TestGetPreferenceByCategoryAndName(t *testing.T) {
_, resp, err = client.GetPreferenceByCategoryAndName(context.Background(), user.Id, preferences[0].Category, preferences[0].Name)
require.Error(t, err)
CheckUnauthorizedStatus(t, resp)
}
func TestUpdatePreferences(t *testing.T) {

Просмотреть файл

@@ -574,7 +574,6 @@ func TestGetBulkReactions(t *testing.T) {
assert.ElementsMatch(t, expectedPostIdsReactionsMap[post4.Id], postIdsReactionsMap[post4.Id])
assert.ElementsMatch(t, expectedPostIdsReactionsMap[post5.Id], postIdsReactionsMap[post5.Id])
assert.Equal(t, expectedPostIdsReactionsMap, postIdsReactionsMap)
})
t.Run("get-reactions-as-anonymous-user", func(t *testing.T) {

Просмотреть файл

@@ -273,7 +273,6 @@ func TestGraphQLChannels(t *testing.T) {
assert.Equal(t, myTeam.DisplayName, ch.Team.DisplayName)
}
}
})
t.Run("Delete+Update", func(t *testing.T) {
@@ -500,7 +499,6 @@ func TestGetPrettyDNForUsers(t *testing.T) {
cache["user2"] = "teststring!!"
assert.Equal(t, "teststring!!", getPrettyDNForUsers("full_name", users, "user1", cache))
})
}
func TestChannelCursor(t *testing.T) {

Просмотреть файл

@@ -184,7 +184,6 @@ func TestGetRolesByNames(t *testing.T) {
_, _, err = client.GetRolesByNames(context.Background(), []string{model.NewId(), model.NewId(), "", " "})
require.NoError(t, err)
})
}
func TestPatchRole(t *testing.T) {
@@ -208,7 +207,6 @@ func TestPatchRole(t *testing.T) {
}
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
// Cannot edit a system admin
adminRole, err := th.App.Srv().Store().Role().GetByName(context.Background(), "system_admin")
assert.NoError(t, err)

Просмотреть файл

@@ -151,7 +151,6 @@ func TestGetRemoteClusterById(t *testing.T) {
require.Error(t, err)
CheckNotFoundStatus(t, resp)
})
}
func TestCreateDirectChannelWithRemoteUser(t *testing.T) {

Просмотреть файл

@@ -438,7 +438,6 @@ func TestPostLog(t *testing.T) {
logMessage, _, err := th.SystemAdminClient.PostLog(context.Background(), message)
require.NoError(t, err)
require.NotEmpty(t, logMessage, "should return the log message")
}
func TestGetAnalyticsOld(t *testing.T) {
@@ -966,7 +965,6 @@ func TestCompleteOnboarding(t *testing.T) {
case <-time.After(15 * time.Second):
require.Fail(t, "timed out waiting testplugin2 to be installed and enabled ")
}
})
t.Run("as a system admin when plugins are disabled", func(t *testing.T) {

Просмотреть файл

@@ -1376,7 +1376,6 @@ func TestGetTeamByName(t *testing.T) {
_, resp, err = client.GetTeamByName(context.Background(), "", "")
require.Error(t, err)
CheckNotFoundStatus(t, resp)
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
@@ -2427,7 +2426,6 @@ func TestAddTeamMemberMyself(t *testing.T) {
}
})
}
}
func TestAddTeamMembersDomainConstrained(t *testing.T) {
@@ -2732,7 +2730,6 @@ func TestRemoveTeamMemberEvents(t *testing.T) {
assert.Equal(t, eventUserId, th.BasicUser2.Id)
})
})
}
func TestGetTeamStats(t *testing.T) {

Просмотреть файл

@@ -53,7 +53,6 @@ func createUpload(c *Context, w http.ResponseWriter, r *http.Request) {
c.Err = model.NewAppError("createUpload", "api.file.cloud_upload.app_error", nil, "", http.StatusBadRequest)
return
}
} else {
if !c.App.SessionHasPermissionToChannel(c.AppContext, *c.AppContext.Session(), us.ChannelId, model.PermissionUploadFile) {
c.SetPermissionError(model.PermissionUploadFile)

Просмотреть файл

@@ -161,7 +161,6 @@ func TestCreateUserInputFilter(t *testing.T) {
defer th.TearDown()
t.Run("DomainRestriction", func(t *testing.T) {
enableAPIUserDeletion := th.App.Config().ServiceSettings.EnableAPIUserDeletion
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.TeamSettings.EnableOpenServer = true
@@ -354,7 +353,6 @@ func TestCreateUserWithToken(t *testing.T) {
})
t.Run("EnableUserCreationDisable", func(t *testing.T) {
enableUserCreation := th.App.Config().TeamSettings.EnableUserCreation
defer func() {
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = enableUserCreation })
@@ -375,7 +373,6 @@ func TestCreateUserWithToken(t *testing.T) {
require.Error(t, err)
CheckNotImplementedStatus(t, resp)
CheckErrorID(t, err, "api.user.create_user.signup_email_disabled.app_error")
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
enableUserCreation := th.App.Config().TeamSettings.EnableUserCreation
@@ -3053,7 +3050,6 @@ func TestGetUsersInGroup(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, len(users), 0)
})
}
func TestGetUsersInGroupByDisplayName(t *testing.T) {
@@ -3111,7 +3107,6 @@ func TestGetUsersInGroupByDisplayName(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, users[0].Id, user1.Id)
})
}
func TestUpdateUserMfa(t *testing.T) {
@@ -3586,7 +3581,6 @@ func TestRevokeSessionsFromAllUsers(t *testing.T) {
sessions, err = th.Server.Store().Session().GetSessions(admin.Id)
require.Empty(t, sessions)
require.NoError(t, err)
}
func TestAttachDeviceId(t *testing.T) {
@@ -3607,7 +3601,6 @@ func TestAttachDeviceId(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.Description, func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.SiteURL = tc.SiteURL
})
@@ -6630,7 +6623,6 @@ func TestThreadSocketEvents(t *testing.T) {
require.EqualValues(t, float64(1), data["previous_unread_mentions"])
require.EqualValues(t, float64(0), data["unread_replies"])
require.EqualValues(t, float64(0), data["unread_mentions"])
}
case <-time.After(1 * time.Second):
return
@@ -6660,7 +6652,6 @@ func TestThreadSocketEvents(t *testing.T) {
require.EqualValues(t, float64(0), data["previous_unread_mentions"])
require.EqualValues(t, float64(1), data["unread_replies"])
require.EqualValues(t, float64(1), data["unread_mentions"])
}
case <-time.After(1 * time.Second):
return
@@ -6852,7 +6843,6 @@ func TestFollowThreads(t *testing.T) {
require.NoError(t, err)
require.Len(t, uss.Threads, 1)
require.GreaterOrEqual(t, uss.Threads[0].LastViewedAt, uss.Threads[0].LastReplyAt)
})
t.Run("No permission to channel", func(t *testing.T) {
@@ -6967,7 +6957,6 @@ func TestMaintainUnreadRepliesInThread(t *testing.T) {
// should have 2 unread replies now
checkThreadListReplies(t, th, th.SystemAdminClient, th.SystemAdminUser.Id, 2, 1, &model.GetUserThreadsOpts{Unread: true})
}
func TestThreadCounts(t *testing.T) {
@@ -7167,7 +7156,6 @@ func TestReadThreads(t *testing.T) {
})
client := th.Client
t.Run("all threads", func(t *testing.T) {
rpost, resp, err := client.CreatePost(context.Background(), &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
require.NoError(t, err)
CheckCreatedStatus(t, resp)