Files
twenty/packages/twenty-server/test/integration/rest/utils/make-rest-api-request.util.ts
Marie 12cc61e096 [permissions] Add workspace + security settings permission gates (#10204)
In this PR

- closing https://github.com/twentyhq/core-team-issues/issues/313
- adding permission gates on workspace settings and security settings
- adding integration tests for each of the protected setting and
security
2025-02-14 17:32:42 +01:00

27 lines
630 B
TypeScript

import { IncomingHttpHeaders } from 'http';
import request from 'supertest';
export type RestAPIRequestMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
interface RestAPIRequestParams {
method: RestAPIRequestMethod;
path: string;
headers?: IncomingHttpHeaders;
body?: any;
}
export const makeRestAPIRequest = ({
method,
path,
headers = {},
body,
}: RestAPIRequestParams) => {
const client = request(`http://localhost:${APP_PORT}`);
return client[method](`/rest${path}`)
.set('Authorization', `Bearer ${ADMIN_ACCESS_TOKEN}`)
.set(headers)
.send(body ? JSON.stringify(body) : undefined);
};