Commit Graph

3301 Commits

Author SHA1 Message Date
catalintomai
59e92e9ae1 MM-4887: Remove back to MM button for Zapier-MM OAuth integration setup (#13890)
* MM-4887: Remove back to MM button got Zapier OAuth setup

* MM-4887: remove Zapier dependency

Co-authored-by: Catalin Tomai <catalin.tomai@mattermost.com>
2020-03-30 11:19:15 -07:00
Doug Lauder
16b535314d MM-23222 mirror audit logs to file (#14062)
* MM-23222 add file target (with rotation) to audit

* MM-23222 mirror syslog audits to local filesystem

    * provides config options for file name, max size, max age

    * rotates files based on max size and max age; delete as needed based on max backups

* include cluster id in log records

* sort meta data fields
2020-03-17 16:12:56 -04:00
Agniva De Sarker
42081a1441 Remove unncessary recover() calls (#14066)
* Remove unncessary recover() calls

A recover which is not called inside a defer will always return nil.
So there's no use of calling it.

And even if we did call it inside a defer, recovering and immediately
panicking does not make sense either. So we just remove it.

* Fixed another instance
2020-03-17 11:04:39 +00:00
Doug Lauder
4ac0619c90 MM-22273 New auditing system (phase 1) (#13967)
* New auditing API outputting to syslog via TLS

* New config section for specifying remote syslog server IP, port, and cert.

* Legacy audit API retained for access history feature
2020-03-12 15:50:21 -04:00
Mario de Frutos Dieguez
c8a923d9e3 MM-22247: Space in content-type breaks integration with 3rd party apps (#13839) 2020-03-07 09:43:57 +01:00
Miguel de la Cruz
182c29b456 MM-21898: Part 2. Add opentracing (#13904)
* initial implementation of opentracing

* app layer

* Revert Makefile

* .

* cleanup

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* [ci]

* autogenerate interface

* .

* missed vendor files

* updated interfaces

* updated store layers

* lint fixes

* .

* finishing layer generators and nested spans

* added errors and b3 support

* code review

* .

* .

* fixed build error due to misplased flag.Parse()

* code review addressed
2020-03-05 14:46:08 +01:00
Mario de Frutos Dieguez
b162cf92cd MM-21976: Include cache layer to be tested (#13749) 2020-03-04 14:18:03 +01:00
Mario de Frutos Dieguez
a43439dd60 Include deleted channels on get user channels endpoint (#13877) 2020-03-02 22:15:15 +01:00
Jesús Espino
7035e09fe9 Adding changes to separate unit tests and integration tests (#13670)
* Introducing unit (not integration) tests for the app layer

* Initial support for unit tests at the API

* Adding unit tests support to the store layer

* Add unit tests support in commands

* Adding last tests needed for run unit tests properly

* Fixing govet

* Removing some duplication

* Fixing tests

* Fixing tests

* Not compiling test helpers with the main module for api

* Revert "Not compiling test helpers with the main module for api"

This reverts commit 36a199bbe0.

* Fixing tests

* Fixing unit tests

* More consistency between api4/apiteslib.go and app/helper_test.go

* Renaming things to make more obvious the new Setup functions purpose

* Reverting change in go.sum

* Start with empty mock for app layer

* Start with empty mock for api layer

* Start with empty mock for web layer

* Renaming SetupWithStoreMockConfig to SetupConfigWithStoreMock

* Fixing tests on web package

* Removing unnecesary function
2020-03-02 08:13:39 -08:00
Ali Farooq
e4fb5791b0 MM-21626, MM-21627 - Plugin API/Hooks Prometheus instrumentati… (#13825)
* MM-21626,MM-21627 - Plugin API/Hooks Prometheus instrumentation

* Updated einterface mocks

* Fixed supervisor tests

* ignoring golint errors for plugin metrics wrappers

* Making golangci happy

* Using variadic form when generating wrapper code

* Removed artificial delay

* Removed comments from tests

* Renaming plugin wrappers to api/hooks_timer_layer

* updating vendor dir and mod files

* Recording plugin api/hook responses in prometheus

* Updated einterfaces-mocks

* Updating go sum

* Updating go sum

* Fixing conflicts

* More conflicts fixing

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-02-14 15:47:43 -05:00
Eli Yukelzon
17523fa5d9 MM-21898 - Part 1: Generate and use an interface instead of *A… (#13840)
* Generate and use an interface instead of *App
2020-02-13 13:26:58 +01:00
Shota Gvinepadze
a7854f1b97 [MM-22037] Enable uppercase letters in the email (#13794)
* Enable uppercase letters in the email

* Lowercase email on every input

* Remove invalid test
2020-02-12 08:51:45 -05: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
Agniva De Sarker
73ce92400b MM-22057: Limit incoming request bodies (#13827)
* MM-22057: Limit incoming request bodies

Set the max request body size to be equal to MaxFileSize.
Ideally, non-file request bodies should be smaller than file request bodies,
but we don't have a clean way to identify all file upload handlers.

There shouldn't be any valid request which exceeds the max file upload size.
So this is a safe global limit to apply.

* Fix tests

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-02-07 14:59:59 -05:00
Agniva De Sarker
a986aeb401 Remove explicit application/wasm mimetype (#13804)
Go mime sniffer supports the application/wasm mimetype natively
now. So there is no need to set this explicitly.
2020-02-05 09:06:17 +05:30
Agniva De Sarker
11d15107b0 MM-21922: Add metrics for http verb (#13679)
* MM-21922: Add metrics for http verb

* Use multiple params

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-28 08:52:00 +05:30
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
Vladimir Lebedev
50e965510a MM-19462 - Migrate tests from "web/oauth_test.go" to use testify (#13525)
* Migrate tests from "web/oauth_test.go" to use testify

* make test cleaner
2020-01-20 15:30:13 +01:00
Vladimir Lebedev
69f4dcd955 MM-19463 - Migrate tests from "web/webhook_test.go" to use testify (#13524)
* MM-19463 - Migrate tests from "web/webhook_test.go" to use testify

* fix shadows declaration

* make test cleaner

* fix wrong test order

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-14 11:09:11 +01:00
Ben Schumacher
2d9e85e82a [MM-20706] Drop 26 character requirement from post action IDs (#13225) 2020-01-14 07:18:14 +01:00
Doug Clark
7f6074b300 GH-13570 Allow /static/plugins/* endpoint responses to be cached (except for 404s) (#13592)
* Reinstate caching on /static/plugins/* endpoint except for 404s

* fix struct name and change default behavior for staticFilesHandler
2020-01-08 16:43:59 -04:00
Claudio Costa
c89d1435ab Use ApiTrustRequester for SAML complete endpoint (#13562) 2020-01-06 09:38:17 +01:00
Claudio Costa
637d9e0ea6 Add CSRF check for handlers that do not require a session but have one (#13354) 2019-12-11 07:56:53 -08:00
Jesse Hallam
345b0c560a MM-20948: nocache for static plugin assets (#13322)
Serve static plugin assets with a `Cache-Control: no-cache, public` header. This avoids caching a 404 response for such an asset, preventing it from being loaded until expiry even if the file later becomes available.

This is currently preventing updates of plugins on community and would generally affect any customer with a cache in front of the Mattermost servers.

Fixes: https://mattermost.atlassian.net/browse/MM-20948
2019-12-05 23:57:30 -04: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
Doug Lauder
5abbe50258 MM-8607 Add ability to turn off non-critical services when under load (#13212)
* MM-8607: add ability to turn off non-critical services under load

* server busy invalid param unit tests

* MM-8607: rename server busy endpoints

* MM-8607: handle case where App not initialized

* MM-8607: additional unit test cases per feedback.

* MM-8607: use decorator to check isbusy when adding endpoint route

* MM-8607: rename endpoints, use struct for json

* Update api4/system.go

Fix misspelled log output

Co-Authored-By: Saturnino Abril <saturnino.abril@gmail.com>

* MM-8607: fix i18n order; max seconds for server busy expiry
2019-11-27 20:41:09 -05:00
ishanray
bf693b6a0c Fix typo by removing extra p in function name (#12996) 2019-11-12 15:14:57 +01:00
Jesse Hallam
6a906e91ad enable non-GOPATH testing with different mattermost-server folder name (#12930)
* enable non-GOPATH testing

Tweak the testlib package to support finding the root without assuming the folder name of the repository.

Fixes: MM-19729

* fix web tests
2019-11-06 14:46:51 -05:00
Nicolas Le Cam
2ea0c669f6 Update minimum Safari supported version to 12 (#12912) 2019-11-04 11:01:29 -05:00
Ben Schumacher
a2adf7b3f5 Run unused against codebase (#12968)
* Remove unused methods

* Fix missed issues
2019-11-01 23:08:01 +01:00
Claudio Costa
422f377c96 [MM-19473] Fix data race on user login (#12870)
* Avoid writes to App.Session outside the app layer

* Fix merge

* Remove unneeded else condition
2019-10-31 12:50:43 +01:00
catalintomai
5dbccd0f07 [MM-18360] Add audit logging for SAML user login (#12831)
* Add audit logging for SAML user login

* add statement for login sucess

* Update web/saml.go

Co-Authored-By: Martin Kraft <martin@upspin.org>
2019-10-29 10:54:43 -07:00
Ben Schumacher
37e0424977 Include request_id in HTTP request logs (#12880) 2019-10-25 20:02:18 +02:00
Adrian
a622ba412e Use locale-agnostic Firefox download link (#12251)
This link redirects to the most suitable language for the user based on their browser's `Accept-Language` header.
2019-10-25 11:19:56 +02:00
Sascha Andres
e83f83fa85 MM-1946 Migrate tests from "web/web_test.go" to use testify #12794 (#12802)
* MM-1946 Migrate tests from "web/web_test.go" to use testify #12794

Also changed call in commented out test for client.

* refactor: re-introduce t.Run

* Update web/web_test.go

Co-Authored-By: Harrison Healey <harrisonmhealey@gmail.com>
2019-10-21 11:00:21 -04:00
Ruslan Abelharisov
d10c524d34 Replace t.fatal with testify package functions (#12842) 2019-10-21 11:12:25 +02:00
Jesús Espino
e236eb74fa Add prometheous metrics for each api handler (#12254) 2019-09-20 15:09:58 +02:00
Nikhil Ranjan
e58aeb90a8 MM-18255 Converting to structured logging the file web/static.go (#12093)
* Converting to structured logging the file web/static.go

* change staticDir to clientDir in logs
2019-09-13 00:22:48 +08:00
Nikhil Ranjan
7ff3439513 Converting to structured logging the file web/handlers.go (#12092) 2019-09-10 09:39:22 +03:00
jfrerich
031cf78c93 [MM-15886] Don't send {"status":"OK"} json response if mobile… (#11982) 2019-08-30 16:57:51 -05:00
Devin Binnie
9562917734 [MM-16677] New unsupported browser page (#11858)
* Added OSVersion to unsupported browser template (and some test code)

* [MM-17569] Working prototype (not functional) of unsupported browser page

* WIP

* WIP

* [MM-17571] Unsupported browser page template logic

* WIP

* [MM-17572][MM-17573] Added browsers and tested for unsupported under IE and Safari

* Clean-up

* Added missing license header

* Fixed a test

* Blank commit to force CI update

* PR feedback

* oops
2019-08-15 14:30:40 -04:00
Marc Argent
50011d5589 GH-11192 Move non-API OAuth endpoints from api4 to web package (#11327)
* GH-11192 WIP

* GH-11192 WIP

* GH-11192 tidy up

* GH-11192 rename handlers

* GH-11192 add TestAuthorizeOAuthApp

* GH-11192 WIP

* GH-11192 Tests mostly passing

* GH-11192 add missing closeBody function back

* GH-11192 add test api endpoint

* GH-11192 rename endpoint to oauth_test
2019-08-15 08:45:31 -04:00
Joram Wilander
404c49f62f MM-16725 Respect env var overrides when setting config (#11821)
* Respect env var overrides when setting config

* Use strings.NewReader
2019-08-09 11:33:59 -04:00
Jesús Espino
fe8a0f6485 Guest accounts feature (#11428)
* MM-14139: Creating permissions for invite/promote/demote guests (#10778)

* MM-14139: Creating permissions for invite/promote/demote guests

* Fixing tests

* Adding invite guest api endpoint (#10792)

* Adding invite guest api endpoint

* Adding i18n

* Adding some tests

* WIP

* Migrating Token.Extra info to bigger size (2048)

* Fixing tests

* Adding client function for invite guests

* Adding send guests invites tests

* Renaming file from guest to guest_invite

* Adding Promote/Demote users from/to guest endpoints (#10791)

* Adding Promote/Demote users from/to guest endpoints

* Adding i18n translations

* Adding the client functions

* Using getQueryBuilder function

* Addressing PR review comments

* Adding default channels to users on promte from guest (#10851)

* Adding default channels to users on promte from guest

* Addressing PR review comments

* Fixing merge problems

* Sending websockets events on promote/demote (#11403)

* Sending websockets events on promote/demote

* Fixing merge problems

* Fixing govet shadowing problem

* Fixing feature branch tests

* Avoiding leaking users data through websockets for guest accounts (#11489)

* Avoiding leaking users data through websockets for guest accounts

* Adding tests and fixing code error

* Fixing i18n

* Allow to enable/disable guests and other extra config settings (#11481)

* Allow to enable/disable guests and other extra config settings

* Fixing tests and moving license and config validation to api level

* Update api4/role_test.go

Co-Authored-By: George Goldberg <george@gberg.me>

* Update api4/role_test.go

Co-Authored-By: George Goldberg <george@gberg.me>

* Fixing typo

* fixing tests

* Managing correctly the guest channel leave behavior (#11578)

* MM-15134: Removing guests from teams or system on leave channels if needed

* WIP

* No deactivating the guest user when leave the last team

* Adding a couple of tests

* Fixing shadow variables

* Fixing tests

* fixing tests

* fixing shadow variables

* Adding guest counts for channel stats (#11646)

* Adding guest counts for channel stats

* Adding tests

* Fixing tests

* Fixing guest domain restrictions (#11660)

* Adding needed migration for the database

* Fixing migration
2019-07-22 22:13:39 +02:00
Daniel Schalla
cb534c704e Enhance logging of CSRF Warning (#11630) 2019-07-17 09:08:58 -04:00
Saturnino Abril
b832985f1d MM-11210 Add "GET /posts/unread" API to support landing on the last unread post (#11486)
* [MM-11210] Add API GET 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/posts/unread' for scrolling overhaul (#9108)

* Add API GET 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/posts/unread'

* add constants

* refactor GetPostSince and added more tests

* move constants to app package

* [MM-11528 &&  MM-11583] Add userId to in the "posts/unread" path and update test with time delay to fix intermittent failure (#9229)

* add userId to in the "posts/unread" path and update test with time delay to fix intermittent failure

* add limit before and after to query

* remove time delay on test and put pretermined value of Post.CreateAt

* Fix conflict

* [MM-11876] Add cursor to posts list such as next_post_id and previous_post_id (#9707)

* add cursor to posts list such as next_post_id and previous_post_id

add publish previous_post_id on WEBSOCKET_EVENT_POSTED and only get next or previous post IDs if necessary

revert change on adding previous_post_id in WEBSOCKET_EVENT_POSTED

add missing strings import

fix merge conflicts

* update per comment

* update per feedback

* corrected the logic in getting the next and previous post ID

* fix logic to determine next and post IDs, and rename function to have suffix of "Time"

* rearrange logics and add mote tests

* fix merge conflict

* fix missing message when using unread API (#10233)

* MM-15569 Fixes failing test on TestGetPostsForChannelAroundLastUnread (#11039)

* Fix missing posts when getting posts since

* revert changes to GetPostsSince

* migrate Post.GetPostAfterTime and Post.GetPostBeforeTime to sync by default

* revert change to cacheItem

* Fix post ID validation, build query on squirrel and only return post ID as necessary
2019-07-04 02:53:04 +05:30
Martin Kraft
c07b7046ca MM-16500: Adds ability to retrieve the total count of teams via the API. (#11325) 2019-06-24 22:05:34 +01:00
Martin Kraft
9d41c7a583 MM-16258: Adds new API endpoint + (App & Client & Store) to retrieve … (#11176)
* MM-16258: Adds new API endpoint + (App & Client & Store) to retrieve Users who would be removed from a list of hypothetical group IDs representing the synced groups.

* MM-16258: Adds roles to JSON response.

* MM-16258: Updates GetByIDs to use Squirrel.

* MM-16258: Puts as much as possible into Squirrel.

* MM-16258: Changes names of methods, functions, and route.

* MM-16258: Updates some comments.

* MM-16258: Extra validation of group_ids parameter.

* MM-16258: Changes validation of group_ids query param.

* MM-16258: Rename a variable and a constant.

* MM-16258: Fix test.
2019-06-17 09:51:56 -04:00
Christopher Speller
1ca421472f Fix bots being unable to post when personal access tokens are disabled. (#11105) 2019-06-13 11:54:09 -07:00