demonslayer134
04/24/2025, 10:38 AMimport grpc from 'k6/net/grpc';
import { check, sleep } from 'k6';
const client = new grpc.Client();
client.load(['protos'], 'authzed/api/v1/permissions_service.proto');
client.load(['protos'], 'authzed/api/v1/core.proto');
client.load(['protos'], 'buf/validate/validate.proto');
export let options = {
stages: [
{ duration: '5s', target: 5 },
{ duration: '10s', target: 5 },
{ duration: '5s', target: 0 },
],
};
const BASE_URL = 'localhost:50051';
const TOKEN = 'abc';
export default () => {
client.connect(BASE_URL, { plaintext: true });
const metadata = {
Authorization: Bearer ${TOKEN},
};
const checkPayload = {
resource: {
objectType: 'module',
objectId: 'AdPlatform',
},
permission: 'role',
subject: {
object: {
objectType: 'user',
objectId: 'test@example.com',
},
},
};
const response = client.invoke( 'authzed.api.v1.PermissionsService/CheckPermission', checkPayload, { metadata });
check(response, {
'permission check status is OK': (r) => r && r.status === grpc.StatusOK,
});
client.close();
sleep(1);
};
this is k6 script i have written for validation test .
but i am facing issue with protobuf files and getting this error,
help me resolve this issue