diff --git a/cmd/mattermost/commands/export.go b/cmd/mattermost/commands/export.go index a837025615..076cc19142 100644 --- a/cmd/mattermost/commands/export.go +++ b/cmd/mattermost/commands/export.go @@ -145,6 +145,7 @@ func scheduleExportCmdF(command *cobra.Command, args []string) error { func buildExportCmdF(format string) func(command *cobra.Command, args []string) error { return func(command *cobra.Command, args []string) error { a, err := InitDBCommandContextCobra(command) + license := a.License() if err != nil { return err } @@ -158,7 +159,7 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string) return errors.New("exportFrom must be a positive integer") } - if a.MessageExport() == nil { + if a.MessageExport() == nil || license == nil || !*license.Features.MessageExport { return errors.New("message export feature not available") } diff --git a/cmd/mattermost/commands/export_test.go b/cmd/mattermost/commands/export_test.go index 4806a1f760..f4d5355b34 100644 --- a/cmd/mattermost/commands/export_test.go +++ b/cmd/mattermost/commands/export_test.go @@ -62,3 +62,13 @@ func TestMessageExportNegativeTimeoutSeconds(t *testing.T) { // should fail fast because timeout seconds must be a positive int require.Error(t, th.RunCommand(t, "--format", "actiance", "--exportFrom", "0", "--timeoutSeconds", "-1", "export", "schedule")) } + +func TestMessageExportFailsWithoutLicense(t *testing.T) { + th := Setup(t) + defer th.TearDown() + + actual, _ := th.RunCommandWithOutput(t, "export", "csv", "export.csv", "--exportFrom", "0") + + // should fail fast because timeout seconds must be a positive int + require.Contains(t, actual, "message export feature not available") +}