@ -12,8 +12,8 @@ import (
. "github.com/smartystreets/goconvey/convey"
)
func TestDashboardAcl ApiEndpoint ( t * testing . T ) {
Convey ( "Given a dashboard acl " , t , func ( ) {
func TestDashboardPermission ApiEndpoint ( t * testing . T ) {
Convey ( "Given a dashboard with permissions " , t , func ( ) {
mockResult := [ ] * m . DashboardAclInfoDTO {
{ OrgId : 1 , DashboardId : 1 , UserId : 2 , Permission : m . PERMISSION_VIEW } ,
{ OrgId : 1 , DashboardId : 1 , UserId : 3 , Permission : m . PERMISSION_EDIT } ,
@ -56,7 +56,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
Convey ( "When user is org admin" , func ( ) {
loggedInUserScenarioWithRole ( "When calling GET on" , "GET" , "/api/dashboards/id/1/acl" , "/api/dashboards/id/:dashboardsId/acl" , m . ROLE_ADMIN , func ( sc * scenarioContext ) {
Convey ( "Should be able to access ACL" , func ( ) {
sc . handlerFunc = GetDashboardAcl List
sc . handlerFunc = GetDashboardPermission List
sc . fakeReqWithParams ( "GET" , sc . url , map [ string ] string { } ) . exec ( )
So ( sc . resp . Code , ShouldEqual , 200 )
@ -71,7 +71,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
loggedInUserScenarioWithRole ( "When calling GET on" , "GET" , "/api/dashboards/id/2/acl" , "/api/dashboards/id/:dashboardId/acl" , m . ROLE_ADMIN , func ( sc * scenarioContext ) {
getDashboardNotFoundError = m . ErrDashboardNotFound
sc . handlerFunc = GetDashboardAcl List
sc . handlerFunc = GetDashboardPermission List
sc . fakeReqWithParams ( "GET" , sc . url , map [ string ] string { } ) . exec ( )
Convey ( "Should not be able to access ACL" , func ( ) {
@ -99,7 +99,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
mockResult = append ( mockResult , & m . DashboardAclInfoDTO { OrgId : 1 , DashboardId : 1 , UserId : 1 , Permission : m . PERMISSION_ADMIN } )
Convey ( "Should be able to access ACL" , func ( ) {
sc . handlerFunc = GetDashboardAcl List
sc . handlerFunc = GetDashboardPermission List
sc . fakeReqWithParams ( "GET" , sc . url , map [ string ] string { } ) . exec ( )
So ( sc . resp . Code , ShouldEqual , 200 )
@ -145,7 +145,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
// Getting the permissions is an Admin permission
Convey ( "Should not be able to get list of permissions from ACL" , func ( ) {
sc . handlerFunc = GetDashboardAcl List
sc . handlerFunc = GetDashboardPermission List
sc . fakeReqWithParams ( "GET" , sc . url , map [ string ] string { } ) . exec ( )
So ( sc . resp . Code , ShouldEqual , 403 )
@ -157,7 +157,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
loggedInUserScenarioWithRole ( "When calling GET on" , "GET" , "/api/dashboards/id/1/acl" , "/api/dashboards/id/:dashboardsId/acl" , m . ROLE_EDITOR , func ( sc * scenarioContext ) {
Convey ( "Should not be able to access ACL" , func ( ) {
sc . handlerFunc = GetDashboardAcl List
sc . handlerFunc = GetDashboardPermission List
sc . fakeReqWithParams ( "GET" , sc . url , map [ string ] string { } ) . exec ( )
So ( sc . resp . Code , ShouldEqual , 403 )
@ -204,7 +204,7 @@ func postAclScenario(desc string, url string, routePattern string, role m.RoleTy
sc . context . OrgId = TestOrgID
sc . context . OrgRole = role
return UpdateDashboardAcl ( c , cmd )
return UpdateDashboardPermissions ( c , cmd )
} )
sc . m . Post ( routePattern , sc . defaultHandler )