Commit Graph

10684 Commits

Author SHA1 Message Date
Sandeep Sukhani
29060acb45 [MM-13828] Initialize tests in each package with a new temp folder with all test resources (#10261)
* [MM-13828] Running tests from a new temp folder with all test resources

Possible fix for #10132

All packages which have a TestMain and use testlib.MainHelper will have a new current working directory which will have all the test
resources copied.

Note: default.json is copied as config.json as well to make sure tests don't have any impact due to changes in config by devs

* [MM-13828] Added TestMain to remaining packages to use testlib.MainHelper

This makes sure tests from all packages run with same test resources, setup in a new temp folder for each package

* Updated Jenkins file to not not config/default.json

This makes sure CI has same config files as a dev's machine

* [MM-13828] Changes requested from code review

Added accessor methods to testlib.MainHelper for accessing members
Fixed some broken tests due to change in cwd while tests run
Some other code refactoring and improvements

* [MM-13828] Added new factory method with options for creating test main helper and some code refactoring

testlib.NewMainHelperWithOptions supports options to turn on/off test dependencies and environment setup
Some other code refactoring

* Exporting members of testlib.MainHelper to make enterprise tests work

* Fixed gofmt error

* [MM-13828] removed unwanted dependency on plugins directory while setting up test resources

* [MM-13828] Fixed some tests failing due to them being running from temp folder

* [MM-13828] Some code changes suggested in PR review

* Fixed gofmt error
2019-02-19 09:20:11 -05:00
Adzim Zul Fahmi
f4249b5456 [MM-12304] Add channel search support in mattermost cli (#10093)
#### Summary
add command search on channel group.
it could search channel by name or id in general
and search channel with team by team name or id

#### Ticket Link
Fixes https://github.com/mattermost/mattermost-server/issues/9491
https://mattermost.atlassian.net/browse/MM-12304

#### Checklist
- [x] Added or updated unit tests (required for all new features)
2019-02-19 07:42:30 +01:00
Jesse Hallam
9bf5687311 MM-11262: database config store (#10281)
* vendor github.com/jmoiron/sqlx

* MM-11262: introduce a database store

* revert unnecessary fmt.Errorf

* simplify unit test helper methods

* remote TODO re: retry

* relocate initializeConfigurationsTable for clarity

* factor out a commonStore

* acquire database config lock on close for safety

* add missing header

* fix lock comment
2019-02-15 10:05:29 -04:00
Carlos Tadeu Panato Junior
898a3a289c add stale bot (#10143)
* add stale bot

* update per feedback

* update per feedback
2019-02-15 14:25:29 +01:00
Shreyansh Chouhan
39ceaa3e86 [MM-13833] Configured unit tests to log through t.Log (#10272)
* Rerouted the unit test logs through t.Log

* resolving merge confilvts

* Update testing.go

* Update helper_test.go

* Added godocs for NewTestingLogger

* Added go docs for NewTestingLogger

* Resolving conflicts
2019-02-14 13:52:11 -04:00
Daniel Schalla
a6d0b73c0d Keep current eMail verification status when updating the user password (#10284) 2019-02-13 22:08:37 +01:00
Carlos Tadeu Panato Junior
42356bc74f add codecov back (#10215)
* add codecov back

* add token

* remove option

* update codecov

* upddate codecov

* add back threshold

* add some configs

* update per feedback

* add error fallback

* fix error

* testing
2019-02-13 15:32:12 -04:00
Jesse Hallam
cd5d5f832c MM-14052: fix subpath yet again (#10278)
* MM-14052: fix subpath yet again

The server now emits a script-src directive that overrides the root.html
rewrite. Fix this by emitting the requisite sha-256 hash server-side as
well as rewriting root.html. We can't remove the root.html rewrite,
since the assets may be on a CDN instead and we use the same code path
to rewrite them (on demand).

Prior to this change, going from / -> /subpath -> / would leave changes
in root.html: the Content-Security-Policy header would still have the
sha-256 hash, and the inline script would still override the publicPath
but to the default subpath value. To avoid sending down a sha-256 hash
server-side when no subpath is required, change this to fully strip out
the subpath changes. This is the only unit test change, as the existing
coverage proves the algorithm still works.

* fix subpath concatenation in test

path.Join isn't meant to work with a URL + path, and my test was effectively working with the subpath "/localhost:8065/subpath" instead of just "/subpath". The CI servers presumably caught this due to a different configuration than my local development.
2019-02-13 11:30:02 -04:00
Miguel de la Cruz
e9089acb6c Logs the errors when indexing and deleting posts with elasticsearch (#10282) 2019-02-13 16:17:59 +01:00
Daniel Schalla
e8e4e94b37 Fix out of range error if Search Replicas > Replicas (#10280) 2019-02-13 12:47:55 +01:00
Andrew Braunstein
c08fda1337 Added the SearchPostsInTeam method to the plugin API (#10106) 2019-02-13 07:41:32 +01:00
Harrison Healey
87e36a3ecf MM-14146 Update CSP for local image proxy (#10277) 2019-02-12 15:27:17 -05:00
Jesse Hallam
285b646d67 MM-13893: introduce file store (#10243)
* config file store

Introduce an interface and concrete implementation for accessing the config.

This mostly maps 1:1 with the exiting usage in `App`, except for internalizing the watcher. A future change will likely eliminate `App.PersistConfig()` and make this implicit on `Set` or `Patch`

* experimental file test changes

* emoji: move file driver checks from api4 to app

It is no longer possible to app.UpdateConfig and provide an invalid configuration, making it hard to test this case. This check doesn't really belong in the api anyway, since it's a configuration validity check and not a permissions check. Either way, the check now occurs at the App level.

* api4: generate valid public link salts for test

* TestStartServerRateLimiterCriticalError: use mock store to test invalid config

* remove config_test.go

* remove needsSave, and have Load() save to the backing store as necessary

* restore README.md

* move ldap UserFilter check to model isValid checks

* remove databaseStore until ready

* remove unimplemented Patch

* simplify unlockOnce implementation

* revert forgetting to set s.Ldap

* config/file.go: rename ReadOnlyConfigurationError to ErrReadOnlyConfiguration

* config: export FileStore

* add TestFileStoreSave

* improved config/utils test coverage

* restore config/README.md copy

* tweaks

* file store: acquire a write lock on Save/Close to safely close watcher

* fix unmarshal_test.go
2019-02-12 10:19:01 -08:00
Christopher Speller
9cfcab2307 MM-14039 Improving password lockout functionality. (#10254)
* Improving password lockout functionality.

* Switching order of mfa password checks to passowrd -> mfa
2019-02-12 07:56:41 -08:00
Jesse Hallam
3a71709103 MM-13893: refactor config (#10230)
* refactor utils/config* to config/

* pull validateLdapFilter into app

* clean up Config/GetConfig/GetSanitizedConfig usage

Eliminate app.GetConfig() in favour of just using app.Config() directly,
but expose app.GetSanitizedConfig() for when the old behaviour was
required.

* web: isolate config setup

* TestInvitePeopleProvider: make config explicit

* regenerateClientConfig: avoid racey map access

* integrate watch flag into app.ConfigFile option

* make app.Option return an error

* release.mk: only cp static files from config/

* release.mk: fix cp static files from config/

* api4: TestPlugin cleanup

* s/c/cfg/ for clarity

* fix merge conflict

* testlib: allow customization of testlib driver name
2019-02-12 08:37:54 -05:00
Jesse Hallam
aca8914e35 MM-14052: Fix subpath rewrite again (#10252)
* actually log an error when subpath rewrite fails

* update subpath rewrite to accommodate dropping unsafe-eval
2019-02-11 21:21:23 -05:00
Yusuke Nemoto
93244fdaa1 Add authorization header to request from post action to plugin (#10165)
* Add authorization header to request from post action to plugin
2019-02-09 05:22:22 -08:00
Harrison Healey
0e31ce9110 MM-13997 Prioritize images over OpenGraph metadata when requesting metadata (#10241) 2019-02-09 10:44:38 +01:00
Dan Maas
4fef9fe9ea Update NOTICE.txt (#10218)
(this is the automated NOTICE.txt update for February 2019)

- add new dependencies (willnorris/imageproxy, Masterminds/squirrel)
- misc copyright owner updates
2019-02-09 10:44:14 +01:00
Christopher Speller
03a96d71d8 Fixing plugin API not having proper access to Cluster. (#10257) 2019-02-08 18:13:52 -08:00
Harrison Healey
4dbeaffdf0 MM-14037 Ensure deprecated image proxy settings are read correctly (#10249) 2019-02-08 10:08:36 -05:00
Harrison Healey
3a8e8739b2 MM-13996 Properly get image dimensions for OpenGraph images using secure_url (#10240)
For images in the OpenGraph metadata, we only looked for the `url` field, but we should've also been looking for the `secure_url` field for sites that defined it. We also set the `secure_url` field when proxying OpenGraph images as well, so we were not properly giving image dimensions for OpenGraph images.

#### Ticket Link
https://mattermost.atlassian.net/browse/MM-13996
2019-02-07 19:43:25 +01:00
Joram Wilander
5cc767fc1b Do not update channel message count for team add/remove message (#10225) 2019-02-07 12:32:38 -05:00
Yusuke Nemoto
06f384df6d Enable PluginJobs (#10198) 2019-02-06 08:25:07 +01:00
Carlos Tadeu Panato Junior
ac68236b88 add fallback to master (#10235) 2019-02-05 13:07:44 -08:00
Carlos Tadeu Panato Junior
5172591437 use $env.CHANGE_TARGET when switch branch (#10228) 2019-02-05 17:10:44 +01:00
tauu
bfe33d683b Fixed login hooks not being called during first OAuth login (#10206)
* Fixed login hooks not being called during first OAuth login

* prevent call AddUserToTeamByTeamId twice for new users in LoginByOAuth
2019-02-05 16:27:54 +01:00
Martin Kraft
afcb224a79 Adds configuration for separate reply-to email header. (#10144)
* Adds configuration for separate reply-to email header.

* Changes config setting name.

* Using a separate variable and value in test.

* Updates for config pointer changes in another PR.

* Adds new key to test config. Adds default value.
2019-02-04 17:01:05 -05:00
Daniel Schalla
ba7ab0b8d1 Indicate incorrect password compared to empty / invalid password field in the error response (#10223) 2019-02-04 18:54:57 +01:00
Harrison Healey
dbf54b3599 MM-13838 Bypass the HTTP client when getting image dimensions from the image proxy (#10208)
* MM-13838 Bypass the HTTP client when getting image dimensions from the proxy

* Add additional log messages to debug failing test

* Fix unit test to work on Jenkins
2019-02-04 12:43:30 -05:00
Daniel Schalla
85c60f1402 [MM-13839] Check for password when updating the eMail (#10207)
* Check for password when updating the eMail

* Require password for email change

* Enhance unit testing

* Restructure error handling for update email path

* govet
2019-02-01 19:06:49 -04:00
Martin Kraft
9a3dc21adc Changes signature of FirstLoginSync function. (#10211)
* First login fix (2).

* Adds cautionary note about 'sanitized' fields.
2019-02-01 18:37:11 -04:00
Daniel Schalla
145fa9a57b [MM-13891] Enable team domain restriction for AuthService users (#10209)
* Enable team domain restriction for AuthService users

* govet
2019-02-01 18:28:35 -04:00
Harrison Healey
46b05499cc MM-13932 Fix image metadata for invalid image links (#10217) 2019-02-01 18:23:04 -04:00
Daniel Schalla
a2f46c0466 [MM-13889] Limit OpenGraph data response size (#10213)
* Limit OpenGraph data response size

* Add LimitReader to Metadata Image
2019-02-01 18:55:43 +01:00
Christopher Speller
4e0840969b MM-13923 Fixing pulling from incorect cache. (#10216)
* Fixing pulling from incorect cache.

* Adding caching test.
2019-02-01 08:13:51 -08:00
Simone Salsi
0f35c4b24d [MM 12458] Include user preferences in bulk export (#9784)
* First version of the preference exporter

* First working version of the preference export

* Removed useless debug line

* Added special case of empty string to harverst the omitempty feature

* Removed dangling line from rebase

* Moved exportablepreference in scope

* Fix go vet issue

* Fix formating

* Add simple test

* Add full test for BulkExportUsers

* Improve variable naming
2019-02-01 11:43:41 +00:00
Harrison Healey
ee9395f1b6 MM-13917 Enable post metadata by default (#10210) 2019-01-31 14:57:50 -05:00
Daniel Schalla
7cc66ee1d4 [MM-10346] CSRF Token Implementation + Tests (#10067)
* CSRF Token Implementation + Tests

Remove debug statements

Implement requested changes

* Fix non-cookie authentication methods stripping auth data from requests

* Fail when CSRF cookie is not returned as part of login
2019-01-31 20:39:02 +01:00
Carlos Tadeu Panato Junior
86aa01cf36 fix test (#10212) 2019-01-31 13:07:49 -04:00
Christopher Speller
51ef1ee32f Adding telemetry for slash commands, and webhook counts. (#10202) 2019-01-31 09:02:16 -08:00
Harrison Healey
7c677b6196 MM-13207 Add customizable timeout for link metadata and improve caching of errors (#10188)
* MM-13207 Add customizable timeout for link metadata and improve caching of errors

* Rename LinkMetadataTimeout to LinkMetadataTimeoutMilliseconds

* Add diagnostics for LinkMetadataTimeoutMilliseconds
2019-01-31 09:40:23 -05:00
Joram Wilander
2ca222033c MM-10658 Change config fields to pointers (#9033)
* MM 10658 Change config fields to pointers (#8898)

* Change fields of config structs to pointers and set defaults

MM-10658 https://github.com/mattermost/mattermost-server/issues/8841

* Fix tests that go broken during switching config structs to pointers

MM-10658 https://github.com/mattermost/mattermost-server/issues/8841

* Apply changes of current master while switching config structs to pointers

MM-10658 https://github.com/mattermost/mattermost-server/issues/8841

* Fix new config pointer uses

* Fix app tests

* Fix mail test

* remove debugging statement

* fix TestUpdateConfig

* assign config consistently

* initialize AmazonS3Region in TestS3TestConnection

* initialize fields for TestEmailTest

* fix TestCheckMandatoryS3Fields
2019-01-31 08:12:01 -05:00
Hanzei
0c981aa010 Prohibit variable shadowing (#10177)
* Prohibit variable shadowing

* Fix outstanding shadowed variables
2019-01-31 12:16:16 +01:00
Deep Vora
cd30a1f242 MM-12375 added webhook show command (#10123)
MM-12375 added tests for webhook show command
2019-01-31 11:07:42 +00:00
Hanzei
d898787371 Fix shadowed variables in various places: Part 1 of 2 (#10175)
* Fix shadowed variables in cmd package

* Fix shadowed variables in plugin package

* Fix shadowed variables in store package

* Fix shadowed variables in web package

* Changes as requested

Signed-off-by: Hanzei <hanzei@mailbox.org>

* Fix build

* Remove unnessary statements

* Use require all the time

* Fix build

* Rename variables according to feedback

* Fix NPE

* Changes as requested
2019-01-30 12:55:24 -05:00
dom3k
2c9cf41dad [MM-13747] Add ability to list users to plugin API (#10102)
* add GetUsers in plugin api

* change GetUsers(page int, perPage int) ([]*model.User, *model.AppError) to GetUsers(options *model.UserGetOptions) ([]*model.User, *model.AppError)

* Update GetUsers doc

Co-Authored-By: dom3k <szeptweb@gmail.com>

* Update doc in plugin/api.go

Co-Authored-By: dom3k <szeptweb@gmail.com>

* correct database initialization for the test

* Update plugin/api.go

Co-Authored-By: dom3k <szeptweb@gmail.com>
2019-01-30 12:55:02 -05:00
Jesse Hallam
2c3a2e9235 Query builder (#10104)
* add query builder to facilitate dynamic SQL construction

* leverage query builder to refactor user store

This is partially setup work for MM-13120, but merged to master to avoid
further conflicts.

* fix unrelated unit test breakage

* documentation tweaks

* Apply suggestions from code review

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* prefer comma separated case options to fallthrough

* vendor github.com/Masterminds/squirrel and deps

* switch to using github.com/Masterminds/squirrel

* rm querybuilder
2019-01-29 15:24:57 -05:00
kosgrz
099e6f74f3 MM-13851 Added a UserWasCreated hook for server-side plugins (#10178) 2019-01-29 18:40:48 +01:00
Carlos Tadeu Panato Junior
d4250f50d8 DB upgrades (#10190)
* uncoment db upgrade to 5.8.0

* add preparatory code for db upgrade 5.9.0

* fix versions

* Update store/sqlstore/upgrade.go

Co-Authored-By: cpanato <ctadeu@gmail.com>
2019-01-29 11:14:00 -05:00