Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
mattermost-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
sysadmin
mattermost
mattermost-server
Commits
cad80670
Commit
cad80670
authored
Sep 27, 2018
by
George Goldberg
Committed by
Christopher Speller
Sep 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MM-12013: Fix post-permission checks to cascade for DM/GM channels. (#9476)
parent
45464234
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
api4/apitestlib.go
api4/apitestlib.go
+14
-0
api4/post_test.go
api4/post_test.go
+25
-0
app/authorization.go
app/authorization.go
+3
-1
No files found.
api4/apitestlib.go
View file @
cad80670
...
...
@@ -455,6 +455,20 @@ func (me *TestHelper) CreateMessagePostNoClient(channel *model.Channel, message
return
post
}
func
(
me
*
TestHelper
)
CreateDmChannel
(
user
*
model
.
User
)
*
model
.
Channel
{
utils
.
DisableDebugLogForTest
()
var
err
*
model
.
AppError
var
channel
*
model
.
Channel
if
channel
,
err
=
me
.
App
.
CreateDirectChannel
(
me
.
BasicUser
.
Id
,
user
.
Id
);
err
!=
nil
{
mlog
.
Error
(
err
.
Error
())
time
.
Sleep
(
time
.
Second
)
panic
(
err
)
}
utils
.
EnableDebugLogForTest
()
return
channel
}
func
(
me
*
TestHelper
)
LoginBasic
()
{
me
.
LoginBasicWithClient
(
me
.
Client
)
}
...
...
api4/post_test.go
View file @
cad80670
...
...
@@ -599,6 +599,31 @@ func TestUpdatePost(t *testing.T) {
CheckNoError
(
t
,
resp
)
}
func
TestUpdateOthersPostInDirectMessageChannel
(
t
*
testing
.
T
)
{
// This test checks that a sysadmin with the "EDIT_OTHERS_POSTS" permission can edit someone else's post in a
// channel without a team (DM/GM). This indirectly checks for the proper cascading all the way to system-wide roles
// on the user object of permissions based on a post in a channel with no team ID.
th
:=
Setup
()
.
InitBasic
()
.
InitSystemAdmin
()
defer
th
.
TearDown
()
dmChannel
:=
th
.
CreateDmChannel
(
th
.
SystemAdminUser
)
post
:=
&
model
.
Post
{
Message
:
"asd"
,
ChannelId
:
dmChannel
.
Id
,
PendingPostId
:
model
.
NewId
()
+
":"
+
fmt
.
Sprint
(
model
.
GetMillis
()),
UserId
:
th
.
BasicUser
.
Id
,
CreateAt
:
0
,
}
post
,
resp
:=
th
.
Client
.
CreatePost
(
post
)
CheckNoError
(
t
,
resp
)
post
.
Message
=
"changed"
post
,
resp
=
th
.
SystemAdminClient
.
UpdatePost
(
post
.
Id
,
post
)
CheckNoError
(
t
,
resp
)
}
func
TestPatchPost
(
t
*
testing
.
T
)
{
th
:=
Setup
()
.
InitBasic
()
.
InitSystemAdmin
()
defer
th
.
TearDown
()
...
...
app/authorization.go
View file @
cad80670
...
...
@@ -74,7 +74,9 @@ func (a *App) SessionHasPermissionToChannelByPost(session model.Session, postId
if
result
:=
<-
a
.
Srv
.
Store
.
Channel
()
.
GetForPost
(
postId
);
result
.
Err
==
nil
{
channel
:=
result
.
Data
.
(
*
model
.
Channel
)
return
a
.
SessionHasPermissionToTeam
(
session
,
channel
.
TeamId
,
permission
)
if
channel
.
TeamId
!=
""
{
return
a
.
SessionHasPermissionToTeam
(
session
,
channel
.
TeamId
,
permission
)
}
}
return
a
.
SessionHasPermissionTo
(
session
,
permission
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment