From 1c0dcda80108c8b2ded9691d8edc6ce46342215f Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Mon, 26 Feb 2024 07:55:54 +0100 Subject: [PATCH] [MM-56400] Allow mmctl to download a Support Packet using --local mode (#25836) --- server/channels/api4/system_local.go | 1 + server/channels/api4/system_test.go | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/server/channels/api4/system_local.go b/server/channels/api4/system_local.go index 25d47e621e..640220501a 100644 --- a/server/channels/api4/system_local.go +++ b/server/channels/api4/system_local.go @@ -17,6 +17,7 @@ func (api *API) InitSystemLocal() { api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(setServerBusy)).Methods("POST") api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(getServerBusyExpires)).Methods("GET") api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(clearServerBusy)).Methods("DELETE") + api.BaseRoutes.System.Handle("/support_packet", api.APILocal(generateSupportPacket)).Methods("GET") api.BaseRoutes.APIRoot.Handle("/integrity", api.APILocal(localCheckIntegrity)).Methods("POST") api.BaseRoutes.System.Handle("/schema/version", api.APILocal(getAppliedSchemaMigrations)).Methods("GET") } diff --git a/server/channels/api4/system_test.go b/server/channels/api4/system_test.go index 11f6bb711e..d33a7a2993 100644 --- a/server/channels/api4/system_test.go +++ b/server/channels/api4/system_test.go @@ -211,16 +211,18 @@ func TestGenerateSupportPacket(t *testing.T) { th.LoginSystemManager() defer th.TearDown() - t.Run("As a System Administrator", func(t *testing.T) { + t.Run("system admin and local client can generate support packet", func(t *testing.T) { l := model.NewTestLicense() th.App.Srv().SetLicense(l) - file, _, err := th.SystemAdminClient.GenerateSupportPacket(context.Background()) - require.NoError(t, err) - require.NotZero(t, len(file)) + th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) { + file, _, err := th.SystemAdminClient.GenerateSupportPacket(context.Background()) + require.NoError(t, err) + require.NotZero(t, len(file)) + }) }) - t.Run("As a System Administrator but with RestrictSystemAdmin true", func(t *testing.T) { + t.Run("Using system admin and local client but with RestrictSystemAdmin true", func(t *testing.T) { originalRestrictSystemAdminVal := *th.App.Config().ExperimentalSettings.RestrictSystemAdmin th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ExperimentalSettings.RestrictSystemAdmin = true }) defer func() { @@ -229,9 +231,11 @@ func TestGenerateSupportPacket(t *testing.T) { }) }() - _, resp, err := th.SystemAdminClient.GenerateSupportPacket(context.Background()) - require.Error(t, err) - CheckForbiddenStatus(t, resp) + th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) { + _, resp, err := th.SystemAdminClient.GenerateSupportPacket(context.Background()) + require.Error(t, err) + CheckForbiddenStatus(t, resp) + }) }) t.Run("As a system role, not system admin", func(t *testing.T) {