Commit graph

41 commits

Author SHA1 Message Date
Eli Yukelzon
2af00f73c0
MM-24847 MM-24484 MM-24850 MM-24849 - local mode for commands (#14571)
* add unix socket listener for mmctl local mode

* First working PoC

* Adds the channel list endpoint

* Add team list endpoint

* Add a LocalClient to the api test helper and start local mode

* Add helper to test with both SystemAdmin and Local clients

* Add some docs

* Adds TestForAllClients test helper

* Incorporating @ashishbhate's proposal for adding test names to the helpers

* [MM-24146] Add unix socket listener for mmctl local mode (#14296)

* add unix socket listener for mmctl local mode

* add a constant for local-mode socket path

* reflect review comments

* Fix init errors after merge

* Adds create channel tests

* Always init local mode to allow for enabling-disabling it via config

* Check the RemoteAddr of the request before marking session as local

* Mark the request as errored if it's local and the origin is remote

* Set the socket permissions to read/write when initialising

* Fix linter

* Replace RemoteAddr check to ditch connections with the IP:PORT shape

* added update/move/get/delete command in local mode

* merge fix

* .

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
2020-05-31 16:57:04 +02:00
Ashish Bhate
33bfebc797
MM-24845/MM-24846: local mode handler for createCommand and listCommands (#14486)
* Add local mode handler for createCommand
* Add local mode handler for listCommands
* Fix bad merge

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-22 17:18:22 +05:30
Shota Gvinepadze
43e606173b
[MM-20684] Slash Command Autocomplete (#14557)
* [MM-20684] Initial implementation of the Command Autocomplete (#13602)

* Implement Autocomplete Data

* Change CommandName to Trigger

* Fix Autocomplete test

* Make stylistic changes

* Rename a bunch of fields and methods

* Fix variable names, safer type assertions

* [MM-20684] plugin autocomplete implementation (#14259)

* Add an endpoint for command autocomplete suggestions

* Add full Suggestion to the AutocompleteSugestion struct

* Add Dynamic Argument support

* Tidy up things

* Fix missed test case

* Add support of the named arguments

* Update autocomplete API

Fix review issues

Implement dynamic args as a local request

* Fix ineffassign

* Add support of the uppercase letters in arguments

* Add support of the optional arguments

* Remove ineffectual assignment

* Add support for icons (#14489)

* Address couple of nits

* Add comment to IconData

* Add types to all consts

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-21 12:24:56 +04:00
Claudio Costa
1e53fe85ad
[MM-21378] Add mutex to model.Post to guard against race conditions on Post.Props (#13884)
* Add mutex to model.Post to guard against race conditions on Post.Props

* Rename mutex

* Add GetProp() method to Post

* Fix more tests

* Fix flaky test

Benchmarks:

BenchmarkPostPropsGet_indirect
BenchmarkPostPropsGet_indirect-2     	85026746	        13.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsGet_indirect-4     	90273747	        13.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsGet_indirect-8     	88324293	        13.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsGet_indirect-16    	91427720	        13.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsGet_direct
BenchmarkPostPropsGet_direct-2       	1000000000	         0.242 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsGet_direct-4       	1000000000	         0.241 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsGet_direct-8       	1000000000	         0.240 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsGet_direct-16      	1000000000	         0.241 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsAdd_indirect
BenchmarkPostPropsAdd_indirect-2     	 5602224	       203 ns/op	     336 B/op	       2 allocs/op
BenchmarkPostPropsAdd_indirect-4     	 5959496	       206 ns/op	     336 B/op	       2 allocs/op
BenchmarkPostPropsAdd_indirect-8     	 5833999	       205 ns/op	     336 B/op	       2 allocs/op
BenchmarkPostPropsAdd_indirect-16    	 5802493	       225 ns/op	     336 B/op	       2 allocs/op
BenchmarkPostPropsAdd_direct
BenchmarkPostPropsAdd_direct-2       	100000000	        11.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsAdd_direct-4       	100000000	        11.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsAdd_direct-8       	100000000	        11.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsAdd_direct-16      	99840794	        11.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsDel_indirect
BenchmarkPostPropsDel_indirect-2     	18824002	        61.9 ns/op	      48 B/op	       1 allocs/op
BenchmarkPostPropsDel_indirect-4     	19470736	        63.8 ns/op	      48 B/op	       1 allocs/op
BenchmarkPostPropsDel_indirect-8     	17640460	        65.3 ns/op	      48 B/op	       1 allocs/op
BenchmarkPostPropsDel_indirect-16    	18692962	        65.4 ns/op	      48 B/op	       1 allocs/op
BenchmarkPostPropsDel_direct
BenchmarkPostPropsDel_direct-2       	516257440	         2.34 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsDel_direct-4       	514865216	         2.43 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsDel_direct-8       	511330477	         2.37 ns/op	       0 B/op	       0 allocs/op
BenchmarkPostPropsDel_direct-16      	499504010	         2.38 ns/op	       0 B/op	       0 allocs/op
2020-03-13 21:12:20 +01:00
Jesús Espino
1d1ab03c38
Passing t to all tests setup functions (#13841)
* Passing t to all tests setup functions

* Fixing build
2020-02-10 19:31:41 +01:00
Doug Lauder
40b7790318
MM-21727 add an endpoint to move a command to another team (#13624)
* MM-21727 add an endpoint to move a command to another team

* endpoint
* mock / client
* unit tests

* MM-21727 PR feedback, addressed nits

* MM-21727 remove CommandMove base route

* MM-21272 replace TeamId struct with CommandMoveRequest struct

* MM-21727 fixed typo in CommandMoveRequest struct name

* MM-21727 return not-found for all getCommandById calls

* MM-21727 ensure no command ids leak

* when calling GetCommandById with invalid id return not_found
* when checking perms to manage commands for team return same not_found
* update unit tests to check for not_found

* MM-21727 Rename TeamIdFromCommandMoveRequestJson -> CommandMoveRequestFromJson
2020-01-29 11:56:21 -05:00
Doug Lauder
28ec291910
MM-19250 - new endpoint to retrieve command by id (#13598)
* MM-19250 add endpoint to retrieve command by id

* endpoint
* client
* unit tests

* MM-19250 update comment; remove redundant unit test

* MM-19250 rename GetCommand to GetCommandById

* MM-19250 don't filter on autocomplete flag

* MM-19250: require team_id when using GetCommandById

* team_id added to endpoint query string for GET
* unit test to check for mismatch teamid param and command teamid

* Revert "MM-19250: require team_id when using GetCommandById"

This reverts commit ed78e27964.

* MM-19250 don't leak existence of id when user doesn't have perms

* return 404 not_found when id not found
* return 404 not_found when id exists but user missing perms to view team
* return 404 not_found when id exists but user missing perms to manage commands

* MM-19250 fix typos in comments

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-24 09:32:56 -05:00
Jesús Espino
a63684fcb5
Consistent license message for all the go files (#13235)
* Consistent license message for all the go files

* Fixing the last set of unconsistencies with the license headers

* Addressing PR review comments

* Fixing busy.go and busy_test.go license header
2019-11-29 12:59:40 +01:00
Miguel de la Cruz
2259b7f2a8
[MM-19948] Set version on module file and internal paths (#13186)
* [MM-19948] Set version on module file and internal paths

* Fixes after merge

* Fix i18n checker error
2019-11-28 14:39:38 +01:00
Simon
caeadbec88 MM-19468 Migrate tests from "api4/command_test.go" to use testify (#12809)
* MM-19468 Migrate tests from "api4/command_test.go" to use testify

* swap expected and actual values during token regeneration test
2019-10-24 09:32:31 -04:00
Claudio Costa
dac7014b48 MM-11931 Add support for AllowedUntrustedInternalConnections to be comma-separated (#11614)
* Add support for AllowedUntrustedInternalConnections to be comma-separated

* Add comprehensive test cases for fields splitting function
2019-07-17 10:04:09 -04:00
Daniel Schalla
68703f9b76
Verify team membership when returning command list (#11487) 2019-07-04 14:52:47 +02: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
Joram Wilander
8cfca681b0
MM-12843 Add interactive dialogs (#9816)
* Add interactive dialogs

* Fix unit test

* Updates per feedback

* Fix typo

* Updates per feedback, add icon_url and error returns

* Updates per feedback

* Update per feedback
2018-11-19 15:27:17 -05: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
alezakos
d585f9d9a3 MM-11895: Don't crush user-provided GET parameters on slash command URLs (#9372) 2018-09-11 15:58:57 -04:00
Saturnino Abril
9e5ec7d09d [MM-10754] Remove unnecessary command_test route (#9050)
* remove unnecessary command_test route

* replaced localhost with ts.URL
2018-07-06 09:07:42 -04:00
Jesse Hallam
a1656dffa9 MM-10201: querystring for get slash commands (#8779)
* pass GET slash command payloads through query string

Previously, both GET and POST requests received the payload via the
body, but this was incorrect for GET requests. Now, the payloads for GET
requests is sent via the query string.

* reorder tests for clarity

* switch command tests to use httptest servers

* restore original test command endpoints
2018-05-14 13:24:22 -04:00
Christopher Speller
80925f7cfd Fixing unit tests for Go 1.10 (#8568) 2018-04-03 15:41:02 -04:00
Chris
8e19ba029f Reduce utils.Cfg references (#7650)
* app.UpdateConfig method

* test fix

* another test fix

* the config override option as-was is just error prone, remove it for now

* derp
2017-10-18 15:36:43 -07:00
Jonathan
b884c8c410 PLT-7193: Regression - Custom slash commands don't work in direct or group message channels (#7635)
* No longer overriding specified team id for DMs/GMs, as these types of channels don't belong to a team, and doing so breaks slash commands for them

* Ensured user is on specified team in case of GM/DM, extended test suite
2017-10-17 10:21:12 -07:00
Chris
34285d8cca parallel tests (#7629) 2017-10-16 11:09:43 -04:00
Jonathan
fa80cb10a8 PLT-7785: Slash commands can be issued to a channel in a team without it (#7567)
* Ensured that specified channel is a part of specified team

* Simplified approach to just infer team id from specified channel id to eliminate the attack vector entirely
2017-10-04 08:12:13 -07:00
Chris
9bc7af0c57 Don't use global app for api / api4 tests (#7528)
* don't use global app for api / api4 tests

* put sleep back. we're gonna have to do some goroutine wrangling

* fix oauth test config assumptions

* jobs package, i'm comin' for you next

* app test fix

* try increasing sleep a little
2017-10-02 09:50:56 +01:00
Joram Wilander
f263d2b951 PLT-7684 Add support to outgoing webhooks and slash commands to set post type and props (#7531)
* Add support to outgoing webhooks and slash commands to set post type and props

* Fix nil access
2017-09-28 09:08:16 -07:00
George Goldberg
2be5577b88 Model: NewLocAppError -> NewAppError (#7450) 2017-09-15 08:32:11 -04:00
Christopher Speller
29fca51821
Renaming repo 2017-09-06 23:11:59 -07:00
Chris
1adfd0e9be app type transition (#7167) 2017-09-06 17:12:54 -05:00
Saturnino Abril
f34cd567a6 [PLT-5170] Add join the channel system message for the person who created the channel (#7299)
* add join the channel system message for the person who created the channel

* update test
2017-08-30 16:29:32 -04:00
Saturnino Abril
651dd33b29 set to default value with config is missing (#7320) 2017-08-30 13:54:16 -04:00
Chris
ffbf8e51fe PLT-6358: Server HTTP client improvements (#6980)
* restrict untrusted, internal http connections by default

* command test fix

* more test fixes

* change setting from toggle to whitelist

* requested ui changes

* add isdefault diagnostic

* fix tests
2017-08-09 13:49:07 -07:00
Joram Wilander
528f2dc6c3 Merge release-3.10 into master (#6654)
* PLT-6787 Fixed being able to send a post before files finished uploading (#6617)

* Fix quick switcher for channels/users not stored locally (#6610)

* Fix button text on confirm mention modal (#6609)

* fix post delete permission of channel admin (#6608)

* open comment thread for the most recent reply-able message (#6605)

* Use mutex flag with yarn to prevent concurrent builds interfering (#6619)

* Use mutex flag with yarn to prevent concurrent builds interfering

* Remove yarn mutex file with clean

* Minor bug fixes (#6615)

* PLT-6774 - Fixing color for offline icon

* PLT-6784 - Fixing status icon

* Fixing icon margin

* Updating caret position

* PLT-6070 Have ChannelMentionProvider stop searching after a term returns no results (#6620)

* Fixing JS error (#6623)

* Minor bug fixes (#6622)

* PLT-6808 - Updating channel switcher on mobile

* PLT-6743 - Updating scrollbar styling

* Login instead of failing if user exists in OAuth sign-up flow (#6627)

* PLT-6802 Disable team switcher (#6626)

* Disable team switcher

* Fix ESLint errors

* PLT-6807 Ensured select teams page can scroll on iOS (#6630)

* Do not redirect from account switch pages on 401 (#6631)

* Fixing loadtest command and renaming to /test (#6624)

* PLT-6820 Update mattermost-redux dependency (#6632)

* translations PR 20170612 (#6629)

* Bump HTTP client timeout to 30 seconds (#6633)

* For team unreads return empty array instead of null (#6636)

* PLT-6831 Fix status modal localization IDs (#6637)

* Fix status modal localization IDs

* Update test snapshot
2017-06-15 11:05:43 -04:00
Saturnino Abril
0e007e344b APIv4 POST /commands/execute (#6205) 2017-04-27 09:41:52 -04:00
Carlos Tadeu Panato Junior
d8d0716122 [APIV4] POST /commands/{command_id}/regen_token for apiV4 (#6052)
* implement POST /commands/{command_id}/regen_token for apiV4

* update comment
2017-04-16 16:49:57 -04:00
Harrison Healey
fb6f2a123c PLT-5860 Updated copyright date (#6058)
* PLT-5860 Updated copyright date in about modal

* PLT-5860 Updated copyright notice in JSX files

* PLT-5860 Updated copyright notice in go files

* Fixed misc copyright dates

* Fixed component snapshots
2017-04-12 08:27:57 -04:00
Saturnino Abril
3b1088f3bd APIv4 DELETE /commands/{command_id} (#6012) 2017-04-10 09:27:10 -04:00
Saturnino Abril
a3f5cffd46 APIv4 PUT /commands/{command_id} (#5999)
* APIv4 PUT /commands/{command_id}

* update client parameter and api4 test
2017-04-07 10:06:09 -07:00
Carlos Tadeu Panato Junior
0a81dd9fff implement GET /teams/{team_id}/commands/autocomplete (#5951) 2017-04-03 21:20:04 -07:00
Carlos Tadeu Panato Junior
88b8df3146 implement GET /commands (#5865) 2017-04-03 08:12:50 -04:00
Joram Wilander
5f6d50bff1 Use 201 status code where appropriate for APIv4 (#5903) 2017-03-31 09:56:20 -04:00
Carlos Tadeu Panato Junior
6935e2d5ea implement POST /commands for apiv4 (#5849) 2017-03-23 19:42:32 -04:00