Commit Graph

3283 Commits

Author SHA1 Message Date
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
Harrison Healey
803ce61ef8 MM-15889 Add unit tests for CSRF checks (#11058)
* MM-15889 Add unit tests for CSRF checks

* Moved CSRF token test to login tests

* Remove empty test

* Remove debug messages
2019-06-11 15:09:00 -04:00
Jesús Espino
4de81fa94c MM-15835: correct errors and content types for oauth api calls (#10999)
* MM-15835: correct errors and content types for oauth api calls

* Addressing PR review comments
2019-05-30 13:23:26 -04:00
Daniel Schalla
2d97f01781 [MM-15639] Add config setting to explicitly define which IP headers are trusted (#10907)
* Add config setting to explicitly define which IP headers are trusted

* fix variable shadowing

* Optimize code flow; Add Ratelimit test for header set

* Extend Ratelimit tests

* Add additional unit tests

* Structured logging
2019-05-24 20:22:13 +02:00
Martin Kraft
e8af4872c6 MM-15422: Adds new parameters for retrieving pages of channels. (#10903)
* MM-15422: Adds new parameters for retrieving pages of channels and searching channels.

* MM-15422: Appends excluded channel names with defaults. Adds separate struct for data-tier option parameter.
2019-05-24 11:28:42 -04:00
Daniel Schalla
d269891476 [MM-15490] Rework default password requirements (#10844)
* Rework default password requirements

* Update API Test Lib Default User PW

* Remove unused function; Disable password reqs in dev mode

* Disable strict password requirements for unit tests

* Update unit tests
2019-05-21 11:03:36 -07:00
Jerry Fireman
571a026a4e MM-11701 Log request ID for outgoing webhooks (#10513)
* "Log request ID"

* "Log request ID"

* "Update in response to comment"

* "Update in response to comment"

* "Run gofmt"
2019-05-17 06:48:32 -07:00
Martin Kraft
1b78f9debc MM-14897: Changes to be able to add and remove groups from channels. (#10794)
* MM-15162: Changes for LDAP groups removals phase.

* MM-14897: Changes to be able to add and remove groups from channels.

* Update model/client4.go

* MM-14897: PR-requested change to string interpolation.
2019-05-15 12:03:47 -04:00
Joram Wilander
68da625802 Do not try to render web app error page when web server is disabled (#10820) 2019-05-13 12:10:30 -04:00
Martin Kraft
480fffd3cc MM-15162: Changes for LDAP groups removals. (#10701)
* MM-15162: Changes for LDAP groups removals phase.

* MM-15162: Adds missing translation.

* MM-15162: Fixes tests.

* MM-15162: Removes some confusing branching.

* MM-15162: Make permission less restrictive.

* MM-15162: Moves counting to the DB tier.

* MM-15162: Moves CountGroupsByTeam into own store method.

* MM-15162: Adds count to tests.

* MM-15162: Fix for wrong cast type.

* MM-15162: Fix for possible null SchemeGuest column.

* MM-15162: Fixes bug whereby permissions error didn't return.

* MM-15162: Changes for LDAP groups removals phase.

* MM-15162: Adds missing translation.

* MM-15162: Fixes tests.

* MM-15162: Removes some confusing branching.

* MM-15162: Make permission less restrictive.

* MM-15162: Moves counting to the DB tier.

* MM-15162: Moves CountGroupsByTeam into own store method.

* MM-15162: Adds count to tests.

* MM-15162: Fix for wrong cast type.

* MM-15162: Fix for possible null SchemeGuest column.

* MM-15162: Fixes bug whereby permissions error didn't return.

* MM-15162: Adds missing translation blocking enterprise build.

* MM-15162: Update to group commands.
2019-05-10 11:47:21 -04:00
d28park
4552c20d5b [MM-12958] Support running two Mattermost instances on the same domain using subpaths (#10493) 2019-05-03 22:52:32 +02:00
Jesús Espino
584ec68755 MM-15021: Adding new builtin system schema for Guests (#10601)
* MM-15021: Adding new builtin system schema for Guests

* Fixing tests

* Setting properly the permissions

* Adding guests to sampledata

* Restrict more roles updates in the app layer for guests

* Adding comment to explain that permissions migration must go at the end

* Setting the default guest role for custom scheme during migration

* Fixing import and export

* Creating scheme guest roles on migration

* Fixing tests

* Fixing tests

* Fixing tests
2019-04-30 20:36:21 +02:00
Puneeth Reddy
ec95793b90 MM-15276: Migrate Team.Update to sync by default (#10693)
* MM-15276: Migrate Team.Update to sync by default

* MM-15276: Addressing review comments and change Update func signature similar to other interface Update method

* update store mocks for update fn

* addressing review comments
2019-04-25 15:29:02 +02:00
Jesús Espino
12c50eb830 Initial migration of the store to be sync (#10592)
* Migrating audit store

* Final migration example for the audit store

* async example

* Ending migration

* Removing Async helper

* Fixing tests

* Fixing govet problems with the StoreResult instanstiation
2019-04-15 22:53:52 +02:00
happygaijin
ba34b4607c MM-14575 - Automatically serve static files for plugins (#10476)
* MM-14575 - Automatically serve static files for plugins
* Added static handler for plugin public files
* Added StaticFilesPath method to Environment for use by MainRouter
* Added "static_files" property to Manifest Server
* Added unit tests for these changes

* MM-14575: Adding comment for cache control value

* MM-14575: Moved Static Plugin Request handler to plugin_requests
* Updated testing

* MM-14575: Removing the StaticFiles from Manifest Server

* MM-14575: Removing static files from test

* MM-14575: Updating static files test

* MM14575: Removing cache directive from plugin static files

* MM14575: Moving plugin public directory to root

* MM-14575: Updating tests for changed public directory

* MM-14575: Moved compileGo to a common utils package for tests

* MM-14575: Moving plugins initialization to InitPlugins find in tests

* Update utils/test_files_compiler.go

Adding Copyright header

Co-Authored-By: happygaijin <happygaijin@users.noreply.github.com>

* MM-14575: Consistent usage of static vs public name

* Removing spurious newline

* Comment typo

Co-Authored-By: happygaijin <happygaijin@users.noreply.github.com>

* Removing spurious new line

Co-Authored-By: happygaijin <happygaijin@users.noreply.github.com>

* MM14575: Adding a test to make sure only public files can be requested

* MM-14575 Adding a test for redirects on public files
2019-04-05 10:35:51 -04:00
Daniel Schalla
41fe33bbb1 Avoid panic from reading CSRF of nil session pointer (#10554)
* Avoid panic from reading CSRF of nil session pointer

* Reorganize CSRF Handling

* Remove autoimport added by IDE

* Remove unnecessary nil check

* gofmt
2019-04-04 18:24:40 +02:00
Christopher Speller
0e6f335f74 Exempting bot accounts from MFA requirements. (#10527) 2019-04-02 13:27:49 -07:00
Martin Kraft
5dbf8aec7d MM-12488: Accepts parameters to search and filter LDAP groups. (#10418) 2019-03-14 15:43:52 -04:00
Jesse Hallam
1e462da2d4 MM-14143 config cleanup final (#10374)
* TestGetLicenseFileFromDisk: avoid using fileutils.FindConfigFile

* config: abstract config-related file access, extend memory store

* simplify config validate to avoid file knowledge

* fix relative file tests

* cluster: fix ConfigChanged event

The old and new configurations were swapped when notifying the enterprise code of configuration changes, creating needless instability in propagating config updates across a cluster.

* config/database: ignore duplicates

* test cleanup

* remove unnecessary Save() in test
2019-03-06 15:06:45 -05:00