There is a race at the DB level where the goroutine c.App.SyncRolesAndMembership
would set the the SchemeAdmin attribute to false. If this happens after
UpdateUserToTeamAdmin happens and before the Login, then the user does not
have the required permissions to unlink the group and it fails.
Thanks to @streamer45 for spotting the issue.
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* app/import: increase buffer size to avoid failing in large inputs
* remove commented out lock
* app/import: make maxTokenSize constant
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* MM-20913 add client API to fetch server busy state and timeout
* deprecate current API that only returns timeout
* required for mmctl MM-20913
* restore deleted unit test for GetServerBusyExpires
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* MM-22205 Add get channel moderations endpoint
* MM-22206 Add patch channel moderations endpoint
Add api tests for patch channel moderations
* MM-22205 Ensure ordered permissions returned and create struct ChannelModeratedRoles
* MM-22206 Use structs instead of map
* MM-22206 Add test cases for GetChannelModeratedPermissions
* MM-22206 Add tests for ChannelModeratedPermissionsChangedByPatch
* MM-22206 Use NewBool instead of defining booleans
* MM-22206 Tie Channel Mentions to Create Posts when building Channel Moderations
* Revert "MM-22206 Tie Channel Mentions to Create Posts when building Channel Moderations"
This reverts commit a0bfc95f17.
* MM-22206 Review changes
Modify GetSchemeRolesForChannel to return named variables
Change calls to SessionHasPermissionToChannel to SessionHasPermissionTo
Add a CreateChannelScheme method
Add a DeleteChannelScheme method
Move GetChannelModeratedPermissions to Role model
* Fix lint
* Add ChannelModeration methods to App interface
* MM-22206 Rename method to GetTeamSchemeChannelRoles
* MM-22206 Check CHANNEL_MODERATED_PERMISSIONS_MAP for existing permission before iterating through it
* Modify wording to higherScoped to match #13813
* MM-22206 Delete channel scheme between tests
* MM-22206 Fix tests
* Actually patch role
* MM-22206 Shadow declaration of err
* Summary
Fixing inconsistencies of the app_error messages. Now all end with a
period and there is the same user experience all over the system.
We agreed on this change on the community server a while ago and I just
came around finally doing it.
Ticket Link
N/A
Checklist
Includes text changes and localization file (.../i18n/en.json and
.../webapp/i18n/en.json) updates
* Update i18n/en.json
Approving changes
Co-Authored-By: Jason Blais <13119842+jasonblais@users.noreply.github.com>
* Update i18n/en.json
Approving changes
Co-Authored-By: Jason Blais <13119842+jasonblais@users.noreply.github.com>
* Update i18n/en.json
Approving changes
Co-Authored-By: Jason Blais <13119842+jasonblais@users.noreply.github.com>
* Fix test failures due string differences
Co-authored-by: Jason Blais <13119842+jasonblais@users.noreply.github.com>
Co-authored-by: Miguel de la Cruz <mgdelacroix@gmail.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* Cache test users to speed up testing
Users were recreated for many tests and hashing passwords takes a lot of
time. Testing /api4 takes around 120s less and /app 60s less.
* fix build
* simplifying a bit the approach
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Jesús Espino <jespinog@gmail.com>
* MM-22282 Add Ephemeral response when using mentions without permission and add new prop to disable mention highlights on client
* MM-22622 Make test name test actually what it does and fix comment style
* MM-22622 Check ephemeral post created when post create with mentions on API
* MM-22622 More tests for App>CreatePost
* MM-22622 Make DisableMentionHighlights more concise and rename ephemeral post
* MM-22622 Dont send ephemeral message for system message created by user
* Trigger build
Hubs property has been detected by the race condition detector
as a possible one because we could set the Hubs variable
and also we're spawning goroutines that could ask for that property
This condition is not happening right now because we're setting the
Hubs variable in the server start and after that, we're spawning the
goroutines but the tests are failing because of this and in the future
this could be a problem
I could not figure out the actual root cause for this.
But a possible area of concern is that somewhere in the call stack,
the login failed partially. Therefore, the session did not have the teamMembers
populated. And the permission check failed therefore.
Adding the error checks should let us know in future if this is not the case.
Another possible case is the app.ClearTeamMembersCache which gets called in
the goroutine app.SyncRolesAndMembership. If this races with the session,
then it's possible that the teamMember is wiped off from the session. But this
happens after the permission check. So it's not very likely.
Also, while we are here, I found that (*app).ClearTeamMembersCache
does not log the internal error bubbled up. This prevents us from understanding
what actually happened. Added that logging.
* 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
* Running tests in mysql and postgres
* Fixing ci
* Fixing ci
* Fixing ci
* Fixing ci
* Fixing ci
* Fixing ci
* Fixing ci
* Fixing ci
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* Remove unnecessary struct2interface dependency
Running go mod tidy on the repo removes it.
This was also preventing 1.14beta from running the repo,
because now it verifies modules.txt with go.mod, which had a mismatch.
* fixing CI
* Fix test-server target
* Fix some discrepancies in vendor
* Removing the Makefile target for now
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
- Fix panic due to not checking for JSON marshal error
- Reorder the FileExists check which would fail if we were to pass
the -short flag to bypass the slow URL test. In which case, the plugin
would have been removed from the filesystem.
So we move the check before we remove the plugin.
https://mattermost.atlassian.net/browse/MM-22666
* allow ExpireInSeconds < 0
Allow `ExpireInSeconds < 0` for use with `KVSetWithOptions`. While this has no practical use in reality, it's much easier to thoroughly unit tests the underlying functionality if we can match the semantics of CompareAndSet. Strictly speaking, this is a breaking change, but not relative to the advertised semantics. Anyway, it's also not entirely unreasonable to treat a negative `ExpireInSeconds` as having already expired vs. marking it as never expired.
* updated tests, to break apart
* honour expiry in CompareAndSet
* honour expiry in CompareAndDelete
* honour expiry in List
* fail unique constraint exception for SaveOrUpdate
A unique constraint error on a `SaveOrUpdate` should not be ignored: we did not save or update the requested value, as someone else managed to write the record first.
Note this is handled differently in `CompareAndSet`, where we correctly swallow the error and return `false` to indicate we did not successfully save the value.
* unexport DEFAULT_PLUGIN_KEY_FETCH_LIMIT
* s/InternalServerError/BadRequest/ for failed SaveOrUpdate
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* [MM-20941] Parallelize plugin loading on startup
* [MM-20941] Parallelize plugin SyncPlugins
* [MM-20941] Make activation and deactivation of plugin concurrent
* [MM-20941] Remove uncessary optimization
This reverts commit aad2680aec.
[MM-20941] Remove uncessary wait in SyncPlugins
[MM-20941] Parallelize processing of prepackaged plugins
* [MM-20941] Fix lint issue
* [MM-20941] Fix bug for getting the number of plugins to process
* [MM-20941] Use buffered channel and fix return issue in prepackaged plugin processing
* [MM-20941] Implement feedback
* [MM-20941] Fix looping over channel for plugins
* [MM-20941] Retain signature of process plugin
* [MM-20941] Fix function documentation
* [MM-20941] Fix bug to pass the plugin path in anonymous function
* [MM-20941] Rename variable
* [MM-20941] Make minor changes in variable naming
Co-authored-by: mattermod <mattermod@users.noreply.github.com>