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
5cf63e37
Commit
5cf63e37
authored
Jun 17, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: remove unused test file
parent
d89c1260
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
70 deletions
+0
-70
pkg/services/guardian/guardian_test.go
+0
-70
No files found.
pkg/services/guardian/guardian_test.go
deleted
100644 → 0
View file @
d89c1260
package
guardian
import
(
"testing"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestGuardian
(
t
*
testing
.
T
)
{
Convey
(
"Given a user with list of dashboards that they have access to"
,
t
,
func
()
{
hitList
:=
[]
int64
{
1
,
2
}
var
orgId
int64
=
1
var
userId
int64
=
1
Convey
(
"And the user is a Grafana admin"
,
func
()
{
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetSignedInUserQuery
)
error
{
query
.
Result
=
&
m
.
SignedInUser
{
IsGrafanaAdmin
:
true
}
return
nil
})
filteredHitlist
,
err
:=
FilterRestrictedDashboards
(
hitList
,
orgId
,
userId
)
So
(
err
,
ShouldBeNil
)
Convey
(
"should return all dashboards"
,
func
()
{
So
(
len
(
filteredHitlist
),
ShouldEqual
,
2
)
So
(
filteredHitlist
[
0
],
ShouldEqual
,
1
)
So
(
filteredHitlist
[
1
],
ShouldEqual
,
2
)
})
})
Convey
(
"And the user is an org admin"
,
func
()
{
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetSignedInUserQuery
)
error
{
query
.
Result
=
&
m
.
SignedInUser
{
IsGrafanaAdmin
:
false
,
OrgRole
:
m
.
ROLE_ADMIN
}
return
nil
})
filteredHitlist
,
err
:=
FilterRestrictedDashboards
(
hitList
,
orgId
,
userId
)
So
(
err
,
ShouldBeNil
)
Convey
(
"should return all dashboards"
,
func
()
{
So
(
len
(
filteredHitlist
),
ShouldEqual
,
2
)
So
(
filteredHitlist
[
0
],
ShouldEqual
,
1
)
So
(
filteredHitlist
[
1
],
ShouldEqual
,
2
)
})
})
Convey
(
"And the user is an editor"
,
func
()
{
bus
.
AddHandler
(
"test"
,
func
(
query
*
m
.
GetSignedInUserQuery
)
error
{
query
.
Result
=
&
m
.
SignedInUser
{
IsGrafanaAdmin
:
false
,
OrgRole
:
m
.
ROLE_EDITOR
}
return
nil
})
bus
.
AddHandler
(
"test2"
,
func
(
query
*
m
.
GetAllowedDashboardsQuery
)
error
{
query
.
Result
=
[]
int64
{
1
}
return
nil
})
filteredHitlist
,
err
:=
FilterRestrictedDashboards
(
hitList
,
orgId
,
userId
)
So
(
err
,
ShouldBeNil
)
Convey
(
"should return dashboard that editor has access to"
,
func
()
{
So
(
len
(
filteredHitlist
),
ShouldEqual
,
1
)
So
(
filteredHitlist
[
0
],
ShouldEqual
,
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