2024-08-28 08:57:46 -07:00
|
|
|
import type { User } from '@/databases/entities/user';
|
2024-08-26 02:10:06 -07:00
|
|
|
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
|
2024-06-07 07:19:59 -07:00
|
|
|
import { ExecutionRecoveryService } from '@/executions/execution-recovery.service';
|
2024-01-26 03:21:15 -08:00
|
|
|
|
2023-11-08 07:29:39 -08:00
|
|
|
import { createUser } from './shared/db/users';
|
2024-05-31 00:40:03 -07:00
|
|
|
import type { SuperAgentTest } from './shared/types';
|
2024-09-12 09:07:18 -07:00
|
|
|
import * as utils from './shared/utils/';
|
|
|
|
import { mockInstance } from '../shared/mocking';
|
2023-01-04 00:47:48 -08:00
|
|
|
|
2023-09-05 04:32:09 -07:00
|
|
|
/**
|
|
|
|
* NOTE: due to issues with mocking the MessageEventBus in multiple tests running in parallel,
|
|
|
|
* the event bus tests are run in the eventbus.ee.test.ts file
|
|
|
|
* The tests in this file are only checking endpoint permissions.
|
|
|
|
*/
|
2023-01-04 00:47:48 -08:00
|
|
|
|
|
|
|
let owner: User;
|
|
|
|
let authOwnerAgent: SuperAgentTest;
|
|
|
|
|
2024-01-26 03:21:15 -08:00
|
|
|
mockInstance(MessageEventBus);
|
2024-06-07 07:19:59 -07:00
|
|
|
mockInstance(ExecutionRecoveryService);
|
2023-07-13 01:14:48 -07:00
|
|
|
const testServer = utils.setupTestServer({
|
|
|
|
endpointGroups: ['eventBus'],
|
2023-09-05 04:32:09 -07:00
|
|
|
enabledFeatures: [], // do not enable logstreaming
|
2023-07-13 01:14:48 -07:00
|
|
|
});
|
2023-01-27 02:19:47 -08:00
|
|
|
|
2023-07-13 01:14:48 -07:00
|
|
|
beforeAll(async () => {
|
2024-01-24 04:38:57 -08:00
|
|
|
owner = await createUser({ role: 'global:owner' });
|
2023-07-13 01:14:48 -07:00
|
|
|
authOwnerAgent = testServer.authAgentFor(owner);
|
2023-01-04 00:47:48 -08:00
|
|
|
});
|
|
|
|
|
2023-07-13 01:14:48 -07:00
|
|
|
describe('GET /eventbus/destination', () => {
|
|
|
|
test('should fail due to missing authentication', async () => {
|
|
|
|
const response = await testServer.authlessAgent.get('/eventbus/destination');
|
|
|
|
expect(response.statusCode).toBe(401);
|
|
|
|
});
|
2023-01-04 00:47:48 -08:00
|
|
|
|
2023-09-05 04:32:09 -07:00
|
|
|
test('should fail due to missing license when authenticated', async () => {
|
2023-07-13 01:14:48 -07:00
|
|
|
const response = await authOwnerAgent.get('/eventbus/destination');
|
2023-09-05 04:32:09 -07:00
|
|
|
expect(response.statusCode).toBe(403);
|
2023-07-13 01:14:48 -07:00
|
|
|
});
|
2023-01-04 00:47:48 -08:00
|
|
|
});
|
|
|
|
|
2023-07-13 01:14:48 -07:00
|
|
|
describe('POST /eventbus/destination', () => {
|
2023-09-05 04:32:09 -07:00
|
|
|
test('should fail due to missing authentication', async () => {
|
|
|
|
const response = await testServer.authlessAgent.post('/eventbus/destination');
|
|
|
|
expect(response.statusCode).toBe(401);
|
2023-02-17 01:54:07 -08:00
|
|
|
});
|
2023-01-04 00:47:48 -08:00
|
|
|
|
2023-09-05 04:32:09 -07:00
|
|
|
test('should fail due to missing license when authenticated', async () => {
|
|
|
|
const response = await authOwnerAgent.post('/eventbus/destination');
|
|
|
|
expect(response.statusCode).toBe(403);
|
2023-01-13 06:39:25 -08:00
|
|
|
});
|
2023-01-04 00:47:48 -08:00
|
|
|
});
|
|
|
|
|
2023-09-05 04:32:09 -07:00
|
|
|
describe('DELETE /eventbus/destination', () => {
|
|
|
|
test('should fail due to missing authentication', async () => {
|
|
|
|
const response = await testServer.authlessAgent.del('/eventbus/destination');
|
|
|
|
expect(response.statusCode).toBe(401);
|
2023-01-04 00:47:48 -08:00
|
|
|
});
|
|
|
|
|
2023-09-05 04:32:09 -07:00
|
|
|
test('should fail due to missing license when authenticated', async () => {
|
|
|
|
const response = await authOwnerAgent.del('/eventbus/destination');
|
|
|
|
expect(response.statusCode).toBe(403);
|
2023-01-13 06:39:25 -08:00
|
|
|
});
|
2023-01-04 00:47:48 -08:00
|
|
|
});
|