Commit Graph

287 Commits

Author SHA1 Message Date
Jesús Espino
2611606e13 Improved how CLI "command delete" command works (#9929) 2018-12-04 06:13:37 +01:00
Jesús Espino
adedb44925 Validating config on set command (#9914)
* Validating config on set command

* Adding more tests to confg set command
2018-12-03 14:18:05 +01:00
Jesús Espino
ba0a9b4d50 MM-12368: Fixing webhook create incomming (#9905) 2018-11-29 11:49:45 +01:00
Christopher Speller
da265fbaf7 Moving app from singular to being created for every request (#9889)
* Moving app from singular to being created for every request.

* Automatic refactor

* Adding license header

* Feedback fixes
2018-11-28 10:56:21 -08:00
Jesús Espino
415036ee8d Improving create-outgoing webhook command (#9899) 2018-11-28 15:55:16 +01:00
Harshit Patni
7663de06bb [MM - 12370] Add cli command "webhook delete" (#9804)
* [MM - 12370] Add cli command "webhook delete"

* Replace spaces with tabs

* Call cli command to delete hooks in tests

* Capture webhook object from create webhook to get webhook id

* Print error message when webhook not deleted

* Remove redundant error message and if condition in webhook delete test

* Fix build
2018-11-26 12:32:11 +01:00
Jesse Hallam
a78913178c Ensure unittest isolation (#9819)
* api4: fix TestGetUsersNotInTeam assertions

This test was relying on data from a previous test run. With the data cleared before each test, the assertions much match reality.

* *testlib: always InitSystemAdmin

Some tests implicitly relied on the basic user having system
administrator privileges because it was the first user created as such.
Eliminate `InitSystemAdmin` and explicitly create the system admin user
instead to avoid this ambiguity going forward.

* *testlib: drop all tables before each test

* api4: split up TestChannelDelete to avoid duplicate InitBasic

* api4: teardown in TestResetPassword, for when this test comes back

* invalidate cache on DropAllTables

This is necessary since the test store persists across tests.

* disable parallel tests

While tests within a package must be explicitly parallelized using `t.Parallel()`, tests across packages are run in parallel by default.  This causes problems given that the tests all currently share the same database instance.

Unfortunately, this also means that running the tests is much slower, but we can return to this later.
2018-11-20 20:16:25 -05:00
Wasim Thabraze
246ff89391 MM-12463 : Added capability to bulk export custom emojis (#9790) 2018-11-19 14:43:31 +00:00
Daniel Fiori
8d56fcf568 Add library and command for human-readable logs (#9809)
* Update logrus to 1.2 and add as a direct dependency

* Create an mlog/human package for pretty-printing logs

This package can read JSON logs from mattermost.log, and output the data to
either logrus or a custom formatter, to make the logs more human readable.

* Create a command for outputting human-readable logs

This command will read JSON data from mattermost.log or stdin, and
output in a human readable format. An optional argument can be used
to activate logrus output (which includes color support).

* Reorganize code in mlog/human and improve logrus timestamp formatting
2018-11-08 10:23:07 -08:00
Christopher Speller
ecade2f1ec MM-12849 Moving all non request scoped items to Server struct (#9806)
* Moving goroutine pool

* Auto refactor

* Moving plugins.

* Auto refactor

* Moving fields to server

* Auto refactor

* Removing siteurl duplication.

* Moving reset of app fields

* Auto refactor

* Formatting

* Moving niling of Server to after last use

* Fixing unit tests.
2018-11-07 10:20:07 -08:00
Wasim Thabraze
0dcbecac87 Added MinimumNArgs to required commands in channels.go and team.go (#9792)
Removed arguments length comparison as MinimumNArgs would handle it.

Addressed code review
2018-11-06 11:20:49 +00:00
Christopher Speller
418a0ec10e Fixing formatting. (#9801) 2018-11-06 16:28:55 +08:00
Jason Mojica
1aa3ceccc2 MM-12355: Add CLI command "command create" revision (#9734)
* Check for admin only setting and user admin status.

If "EnableOnlyAdminIntegrations" is true, will only allow team admins
to create slash commands

* Add test for non-admin user

* Simplify permissions check

* Change error message

* Fix test
2018-11-05 14:55:31 +00:00
Kerry Dougherty
c155359e58 MM-12369 Add Create Outgoing Webhook Command (#9779)
* add create outgoing webhook command

* add create outgoing webhook command
2018-11-02 13:39:38 -04:00
George Goldberg
8d3cfc6ad7 MM-12815: Clearly deprecated disused config settings. (#9751)
* MM-12815: Clearly deprecated disused config settings.

* Fix tests.
2018-10-31 08:38:38 +00:00
Mukul Rawat
2b6d6acb78 [MM-12361] Create CLI-command "config set" (#9535) (#9582)
* Create the config set command in the variable

* Register the command and declare the command in the run function

* Finish implementation of 'config set' cli command

* Write tests for config set command

* Change minimum number of arguments to 2

* Correct changes

* Correct error problem

* Update the command description and errors

* Refactor function name and improve error messages

* Write test for UpdateMap function
2018-10-29 09:29:15 +00:00
Shobhit Gupta
c317d6f265 MM-12356 Add cli command "command delete" (#9553)
* Add cli command for deleting commands

* Add code/test for delete command

* Fix test

* Add confirm flag

* Update as per comments

* Uncomment test

* Fix test
2018-10-23 12:19:10 +01:00
Artur Mogozov
c3993704ef MM-12372 Add modify-incoming webhook command (#9683)
* MM-12372 Add modify-incoming webhook command

* Review comments
2018-10-19 12:04:12 +01:00
Artur Mogozov
cedf6488e4 MM-12368 Add create webhook-incoming command (#9566) 2018-10-16 12:13:00 +01:00
Mukul Rawat
80153ef873 [MM-12362] Add CLI command 'config show' (#9536) (#9564)
* Add the subcommand by creating a new Command instance.

* Implemented the structure of the subcommand function.

* Register our new command

* Write some helper functions

* finish the pretty print function

* write some test for config show

* Refactor and extract the tab printing functionality in its own function

* Use app.Config() to create our config object & accept incoming changes

* Removed reading the file, make helper functions return string and perform printing inside the command

* Remove the previous code for checking presence of arguments and use 'cobra.NoArgs()' instead

* Remove named return and instead declare the variable and then return it.

* Remove printTab function and simplify printing out tabs using strings.Repeat

* Add some functions to test the output

* Update the usage and remove a comment

* Update the print
2018-10-15 18:06:46 -04:00
Wasim Thabraze
457a34c5f4 [MM-12363] Added Team archive command to archive a team by name (#9565)
* Added Team archive command to archive a team by name

* Team archive command now uses SoftDelete method

Team search and list command now shows archived teams with the term '(archived)' appended to them
2018-10-15 19:48:18 +01:00
Mukul Rawat
9385dc750d [MM-12360] Created CLI command "config get" (#9534) (#9558)
* Added the get command to get the value of a config setting.

* Depending on the config setting it can work on any depth of the
setting.

* Added test for the get command.

* Add print tabs

* Remove excess else statements

* Return with the value and remove named return variable

* Refactor the printMap function and return a string, remove side effects

* Improve the error message, use the name argument

* Use app.Config() to create our config object

* Remove reading the file, make helper functions return string and perform printing inside the command

* Remove the tab printing

* Add extra quotes on the output

* Remove extra code for checking arguments and replaced it with cobra.ExactArgs(1)

* Remove buffer from printConfigValues

* Add some tests to check the output of the command

* Write test for the function 'structToMap' and test for complext nested structs

* Write test for the function 'configToMap' and test for complext nested structs

* Write test for the function 'printMap' and test for complext maps as input

* Write test for the function 'printConfigValues' and test for complext maps as input

* Remove commented code

* Update the description of the  command
2018-10-15 10:49:25 -04:00
Jason Mojica
f025e749a9 MM-12355: Add CLI command "command create" (#9569)
* Add create command

* Create CreateCommand Tests

* Change method flag description

* Change nil test assertion
2018-10-13 13:35:00 +01:00
George Goldberg
9a4f3ce1e5 MM-12251: Add flag to MoveChannel to remove all deactivated users. (#9515) 2018-10-08 16:39:03 +01:00
Jesús Espino
0a68e741d0 Small fix in the webhook list error handling (#9567) 2018-10-05 16:40:26 +02:00
Ashutosh Kumar
cba33137d2 MM-12357: Add CLI command "team list" (#9531)
* (feat:command list)add command list for teams

Signed-off-by: sonasingh46 <sonasingh46@gmail.com>

* address review comments

Signed-off-by: sonasingh46 <sonasingh46@gmail.com>

* address review comments

Signed-off-by: sonasingh46 <sonasingh46@gmail.com>
2018-10-05 08:12:03 +02:00
Ben Echols
939ee15013 MM-12371 Add webhook list command (#9528)
* Added start of the webhook command

* start of unit tests

* created a simple hook for unit test

* added outgoing as well

* have it all working

* Add license headers to the files

* Addressing code review, fixed print reverted sql change
2018-10-04 20:16:25 +02:00
Daniel Schalla
7468f35cb0 Fix CMD Init. Error Checks (#9547) 2018-10-03 12:04:04 -07:00
Wasim Thabraze
b6835ab984 [MM-12367] Added CLI command 'team search' (#9512)
* Added 'search' sub-command for the command 'team' to search across teams with name

* Addressed code review

* Moved 'removeDuplicatesAndSortTeams' function to team.go

Addressed more code reviews

* Added unit test case for team search command

* Added unit test case to test searching of teams by display name
2018-10-03 09:31:53 +02:00
Jesús Espino
2945e8a2b0 MM-10699: Disallow renaming direct and group message channels (#9518)
* MM-10699: Disallow renaming direct and group message channels

* Replacing errors.New with errors.Wrapf
2018-10-02 19:33:52 +02:00
Christopher Speller
3785ad48c1 Adding arg spec to bulk export. (#9453) 2018-09-25 10:57:35 +01:00
Jesús Espino
a08df883b4 Move file backend to its own service (#9435)
* Move file backend to its own service

* Moving utils/inbucket to mailservice package
2018-09-20 10:07:03 -07:00
George Goldberg
ab99f0656f MM-11781: Basic Data Export Command Line. (#9296)
* MM-11781: Basic Data Export Command Line.

* ChannelStore new unit tests.

* TeamStore new unit tests.

* Unit test for new UserStore function.

* Unit tests for post store new methods.

* Review fixes.

* Fix duplicate command name.
2018-09-17 15:51:26 +01:00
Carlos Tadeu Panato Junior
35c148d255 fixing log messages (#9341)
* fixing log messages

* update per review

* Update notification.go

* Update server.go

* Update notification.go
2018-09-17 09:29:04 +02:00
George Goldberg
504591e7d6 MM-11882: Remove all users from a channel via CLI. (#9381) 2018-09-10 07:42:15 -04:00
Daniel Schalla
531897b1f0 add megacheck as makefile target (#9288)
Fix code issues in channel_test.go

Fix Channel Test Issues detected by Megacheck

Fix API Emoji Test Issues detected by Megacheck

Fixed API Issues Reported by Megacheck

Fixed App issues reported by megacheck

Remaining fixes

removed test added by mistake from old HEAD

gofmt

Store Fixes

simplified returns

Fix test for multi member channel delete

revert to delete unused function
2018-09-03 14:08:40 +02:00
Carlos Tadeu Panato Junior
0da5c852f0 add --username in the example for the commands (#9320)
* add --username in the example for the commands

* update per review
2018-08-29 16:57:26 +02:00
Jesús Espino
bba3bbd9f3 MM-11572: Force correct order on messages generated in the bulk (#9244) 2018-08-24 09:53:44 +02:00
cpanato
620d55810d Merge remote-tracking branch 'upstream/release-5.2' into release-5.2-daily-merge-20180810 2018-08-10 15:03:18 +02:00
Jesse Hallam
d8c8a19d35 avoid t.Fatal() in tests (#9189)
I've been burned a few times by tests that simply fatal, requiring me to
run another build to learn more about what the mismatch was. Avoid this.

This is part of a long running goal of mine to make testing "better".
2018-08-09 11:26:38 +02:00
Jesse Hallam
7649488a26 MM-11637: avoid stopping unstarted jobs (#9240)
The new locking primitives in 5.2 around jobs assume the
worker/scheduler was actually started, so don't try to stop if not
started.
2018-08-09 11:04:49 +02:00
Jesús Espino
3b640cd51b Remove global-relay export command from the cli (#9226) 2018-08-08 12:04:16 +02:00
George Goldberg
185ed89978 MM-11243: Make Elasticsearch work after enabling without restart. (#9146)
* MM-11243: Make Elasticsearch work after enabling without restart.

* Also cope with config vars changing whilst enabled.
2018-07-26 15:50:38 +01:00
Jesse Hallam
8948b91d7a unpack prepacked plugins on plugins initialization (#9149)
* unpack prepackaged plugins on plugins initialization

* leverage utils.FindDir
2018-07-26 08:45:26 -04:00
Jesús Espino
bfb2640451 Add idiomatic error handling in mattermost commands (#9147) 2018-07-24 10:11:47 -04:00
Jesús Espino
610ac5a53c MM-11003: Global Relay Export Refactor (#9136) 2018-07-20 17:13:35 +02:00
Druhin Bala
301e7eb1c4 MM-10699 Add channel renaming to CLI (#9094) 2018-07-18 11:49:48 +01:00
Santos Solorzano
f57d279dc0 [MM-10117] Add support to add/delete and enable/disable plugins via CLI (#8745)
* Testing caching for emojis

* MM-10117 Add support to add/delete and activate/deactivate plugins via CLI

* Removing old work

* MM-10117 Moved files and addedd plugin test

* MM-10117 Renamed commands to enable/disable and updated add test

* MM-10117 Finished plugin test and improved error message for plugin commands

* MM-10117 Fixing plugin directories for test

* MM-10117 Renamed commands and updated commands to support multiple plugins

* MM-10117 Updating removed to deleted textclear

* MM-10117 Fixing nil pointer error for listing plugins

* MM-10117 Removing fileReader close

* MM-10117 Declaring error for GetPlugins

* MM-10117 Removing unnecessary nil check
2018-07-11 12:17:19 -04:00
JoramWilander
6c7dc2d29c Merge branch 'plugins-2' 2018-07-10 15:01:43 -04:00
Christopher Speller
74e5d8ae66 MM-11120 Adding setting to disable email invitations and rate limiting. (#9063)
* Adding setting to disable email invitations.

* Adding a setting and rate limiting for email invite sending.

* Modifying email rate limit to 20/user/hour

* Adding EnableEmailInvitations to client side config and command.
2018-07-10 10:54:25 +02:00