[MM-56400] Allow mmctl to download a Support Packet using --local mode (#25836)

This commit is contained in:
Ben Schumacher 2024-02-26 07:55:54 +01:00 committed by GitHub
parent e9b9d4ff60
commit 1c0dcda801
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 8 deletions

View File

@ -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")
}

View File

@ -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)
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,10 +231,12 @@ func TestGenerateSupportPacket(t *testing.T) {
})
}()
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) {
_, resp, err := th.SystemManagerClient.GenerateSupportPacket(context.Background())