Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c826f39a
Commit
c826f39a
authored
Mar 13, 2019
by
Hugo Häggmark
Committed by
Leonard Gram
Mar 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: defaulting invalid permission level to member permission level
parent
c823ad5d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletions
+32
-1
pkg/services/sqlstore/team.go
+4
-1
pkg/services/sqlstore/team_test.go
+28
-0
No files found.
pkg/services/sqlstore/team.go
View file @
c826f39a
...
...
@@ -271,7 +271,10 @@ func UpdateTeamMember(cmd *m.UpdateTeamMemberCommand) error {
return
m
.
ErrTeamMemberNotFound
}
// TODO: check to make sure that permission is a legal value
if
cmd
.
Permission
!=
int64
(
m
.
PERMISSION_ADMIN
)
{
cmd
.
Permission
=
0
}
member
.
Permission
=
cmd
.
Permission
_
,
err
=
sess
.
Cols
(
"permission"
)
.
Where
(
"org_id=? and team_id=? and user_id=?"
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
.
Update
(
member
)
...
...
pkg/services/sqlstore/team_test.go
View file @
c826f39a
...
...
@@ -102,6 +102,34 @@ func TestTeamCommandsAndQueries(t *testing.T) {
So
(
qAfterUpdate
.
Result
[
0
]
.
Permission
,
ShouldEqual
,
m
.
PERMISSION_ADMIN
)
})
Convey
(
"Should default to member permission level when updating a user with invalid permission level"
,
func
()
{
userID
:=
userIds
[
0
]
team
:=
group1
.
Result
addMemberCmd
:=
m
.
AddTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
team
.
Id
,
UserId
:
userID
}
err
=
AddTeamMember
(
&
addMemberCmd
)
So
(
err
,
ShouldBeNil
)
qBeforeUpdate
:=
&
m
.
GetTeamMembersQuery
{
OrgId
:
testOrgId
,
TeamId
:
team
.
Id
}
err
=
GetTeamMembers
(
qBeforeUpdate
)
So
(
err
,
ShouldBeNil
)
So
(
qBeforeUpdate
.
Result
[
0
]
.
Permission
,
ShouldEqual
,
0
)
invalidPermissionLevel
:=
1337
err
=
UpdateTeamMember
(
&
m
.
UpdateTeamMemberCommand
{
UserId
:
userID
,
OrgId
:
testOrgId
,
TeamId
:
team
.
Id
,
Permission
:
int64
(
invalidPermissionLevel
),
})
So
(
err
,
ShouldBeNil
)
qAfterUpdate
:=
&
m
.
GetTeamMembersQuery
{
OrgId
:
testOrgId
,
TeamId
:
team
.
Id
}
err
=
GetTeamMembers
(
qAfterUpdate
)
So
(
err
,
ShouldBeNil
)
So
(
qAfterUpdate
.
Result
[
0
]
.
Permission
,
ShouldEqual
,
0
)
})
Convey
(
"Shouldn't be able to update a user not in the team."
,
func
()
{
err
=
UpdateTeamMember
(
&
m
.
UpdateTeamMemberCommand
{
UserId
:
1
,
...
...
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