@@ -609,7 +609,16 @@ roles() ->
609609 {desc , <<" Access to /metrics endpoint for Prometheus integration. "
610610 " Can read all stats for all services. This user cannot "
611611 " access the web console" >>}],
612- [{[admin , stats_export ], [read ]}]}].
612+ [{[admin , stats_export ], [read ]}]},
613+ {eventing_manage_functions , ? RBAC_SCOPE_PARAMS ,
614+ [{name , <<" Manage Scope Functions" >>},
615+ {folder , eventing },
616+ {desc , <<" Can manage eventing functions for a given scope" >>}],
617+ [{[{collection , [bucket_name , scope_name , any ]}, eventing , function ], [manage ]},
618+ {[{collection , [bucket_name , scope_name , any ]}, collections ], [read ]},
619+ {[ui ], [read ]},
620+ {[pools ], [read ]}]}
621+ ].
613622
614623ui_folders () ->
615624 [{admin , " Administrative" },
@@ -619,6 +628,7 @@ ui_folders() ->
619628 {'query' , " Query & Index" },
620629 {search , " Search" },
621630 {analytics , " Analytics" },
631+ {eventing , " Eventing" },
622632 {xdcr , " XDCR" },
623633 {backup , " Backup" },
624634 {mobile , " Mobile" }].
@@ -1506,6 +1516,36 @@ query_functions_test_() ->
15061516
15071517 {foreach , fun () -> ok end , Tests }.
15081518
1519+ eventing_functions_test_ () ->
1520+ Roles = [{eventing_manage_functions , [eventing , function ], manage }],
1521+
1522+ Sources = [{scope , [" default" , " s" ]},
1523+ {scope , [" default" , " s1" ]},
1524+ {bucket , " default" }],
1525+
1526+ Tests =
1527+ lists :flatmap (
1528+ fun ({Role , Object , Oper }) ->
1529+ RoleStr = atom_to_list (Role ),
1530+ Permissions = [{[S | Object ], Oper } || S <- Sources ],
1531+ Test =
1532+ ? cut (fun () ->
1533+ compile_and_assert (Role , Permissions , _ , _ )
1534+ end ),
1535+
1536+ [{" existing scope with id's : " ++ RoleStr ,
1537+ Test ([{" default" , <<" default_id" >>}, {" s" , 1 }],
1538+ [true , false , false ])},
1539+ {" whole bucket" ,
1540+ Test ([" default" , any ],
1541+ [true , true , true ])},
1542+ {" another bucket" ,
1543+ Test ([" test" , any ],
1544+ [false , false , false ])}]
1545+ end , Roles ),
1546+
1547+ {foreach , fun () -> ok end , Tests }.
1548+
15091549validate_role_test () ->
15101550 ValidateRole = validate_role (_ , roles (), toy_buckets ()),
15111551 ? assertEqual ({ok , admin }, ValidateRole (admin )),
0 commit comments