@@ -10,9 +10,11 @@ import {
1010 BenchmarkWizardStepResponse ,
1111 CreateBenchmarkRequest ,
1212 ListBenchmarksResponse ,
13+ Permission ,
1314 PrincipalType ,
1415} from '@openops/shared' ;
1516import { StatusCodes } from 'http-status-codes' ;
17+ import { getProjectScopedRoutePolicy } from '../core/security/route-policies/route-security-policy-factory' ;
1618import { assertBenchmarkFeatureEnabled } from './benchmark-feature-guard' ;
1719import { getBenchmarkStatus , listBenchmarks } from './benchmark-status.service' ;
1820import { createBenchmark } from './create-benchmark.service' ;
@@ -47,14 +49,17 @@ export const benchmarkController: FastifyPluginAsyncTypebox = async (app) => {
4749 userId : request . principal . id ,
4850 benchmarkConfiguration : request . body . benchmarkConfiguration ,
4951 } ) ;
52+
5053 return reply . status ( StatusCodes . CREATED ) . send ( result ) ;
5154 } ,
5255 ) ;
56+
5357 app . get ( '/' , ListBenchmarksRequestOptions , async ( request , reply ) => {
5458 const items = await listBenchmarks ( {
5559 projectId : request . principal . projectId ,
5660 provider : request . query . provider ,
5761 } ) ;
62+
5863 return reply . status ( StatusCodes . OK ) . send ( items ) ;
5964 } ) ;
6065
@@ -74,6 +79,10 @@ export const benchmarkController: FastifyPluginAsyncTypebox = async (app) => {
7479const ListBenchmarksRequestOptions = {
7580 config : {
7681 allowedPrincipals : [ PrincipalType . USER ] ,
82+ security : getProjectScopedRoutePolicy ( {
83+ allowedPrincipals : [ PrincipalType . USER ] ,
84+ permission : [ Permission . READ_RUN ] ,
85+ } ) ,
7786 } ,
7887 schema : {
7988 tags : [ 'benchmarks' ] ,
@@ -91,6 +100,15 @@ const ListBenchmarksRequestOptions = {
91100const WizardStepRequestOptions = {
92101 config : {
93102 allowedPrincipals : [ PrincipalType . USER ] ,
103+ security : getProjectScopedRoutePolicy ( {
104+ allowedPrincipals : [ PrincipalType . USER ] ,
105+ permission : [
106+ Permission . READ_APP_CONNECTION ,
107+ Permission . WRITE_FOLDER ,
108+ Permission . DELETE_FLOW ,
109+ Permission . WRITE_FLOW ,
110+ ] ,
111+ } ) ,
94112 } ,
95113 schema : {
96114 tags : [ 'benchmarks' ] ,
@@ -109,6 +127,15 @@ const WizardStepRequestOptions = {
109127const CreateBenchmarkRequestOptions = {
110128 config : {
111129 allowedPrincipals : [ PrincipalType . USER ] ,
130+ security : getProjectScopedRoutePolicy ( {
131+ allowedPrincipals : [ PrincipalType . USER ] ,
132+ permission : [
133+ Permission . READ_APP_CONNECTION ,
134+ Permission . WRITE_FOLDER ,
135+ Permission . DELETE_FLOW ,
136+ Permission . WRITE_FLOW ,
137+ ] ,
138+ } ) ,
112139 } ,
113140 schema : {
114141 tags : [ 'benchmarks' ] ,
@@ -127,6 +154,10 @@ const CreateBenchmarkRequestOptions = {
127154const BenchmarkStatusRequestOptions = {
128155 config : {
129156 allowedPrincipals : [ PrincipalType . USER ] ,
157+ security : getProjectScopedRoutePolicy ( {
158+ allowedPrincipals : [ PrincipalType . USER ] ,
159+ permission : [ Permission . READ_RUN ] ,
160+ } ) ,
130161 } ,
131162 schema : {
132163 tags : [ 'benchmarks' ] ,
0 commit comments