Update what is being audit logged (#11833)
No need to audit log workflow runs as it's already a form of audit log. Add more audit log for other objects Rename MessagingTelemetry to MessagingMonitoring Merge Analytics and Audit in one (Audit) --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,30 +1,30 @@
|
||||
import process from 'process';
|
||||
|
||||
import { ClickHouseClient, createClient } from '@clickhouse/client';
|
||||
import request from 'supertest';
|
||||
import { createClient, ClickHouseClient } from '@clickhouse/client';
|
||||
|
||||
import { GenericTrackEvent } from 'src/engine/core-modules/analytics/utils/events/track/track';
|
||||
import { OBJECT_RECORD_CREATED_EVENT } from 'src/engine/core-modules/analytics/utils/events/track/object-record/object-record-created';
|
||||
import { OBJECT_RECORD_CREATED_EVENT } from 'src/engine/core-modules/audit/utils/events/track/object-record/object-record-created';
|
||||
import { GenericTrackEvent } from 'src/engine/core-modules/audit/utils/events/track/track';
|
||||
|
||||
describe('ClickHouse Event Registration (integration)', () => {
|
||||
let clickhouseClient: ClickHouseClient;
|
||||
let clickHouseClient: ClickHouseClient;
|
||||
|
||||
beforeAll(async () => {
|
||||
jest.useRealTimers();
|
||||
|
||||
clickhouseClient = createClient({
|
||||
clickHouseClient = createClient({
|
||||
url: process.env.CLICKHOUSE_URL,
|
||||
});
|
||||
|
||||
await clickhouseClient.query({
|
||||
query: 'TRUNCATE TABLE events',
|
||||
await clickHouseClient.query({
|
||||
query: 'TRUNCATE TABLE auditEvent',
|
||||
format: 'JSONEachRow',
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (clickhouseClient) {
|
||||
await clickhouseClient.close();
|
||||
if (clickHouseClient) {
|
||||
await clickHouseClient.close();
|
||||
}
|
||||
});
|
||||
|
||||
@ -53,10 +53,10 @@ describe('ClickHouse Event Registration (integration)', () => {
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body.data.trackAnalytics.success).toBe(true);
|
||||
|
||||
const queryResult = await clickhouseClient.query({
|
||||
const queryResult = await clickHouseClient.query({
|
||||
query: `
|
||||
SELECT *
|
||||
FROM events
|
||||
FROM auditEvent
|
||||
WHERE event = '${OBJECT_RECORD_CREATED_EVENT}' AND timestamp >= now() - INTERVAL 1 SECOND
|
||||
|
||||
`,
|
||||
@ -1,65 +0,0 @@
|
||||
import request from 'supertest';
|
||||
|
||||
const client = request(`http://localhost:${APP_PORT}`);
|
||||
|
||||
describe('auditLogsResolver (e2e)', () => {
|
||||
it('should find many auditLogs', () => {
|
||||
const queryData = {
|
||||
query: `
|
||||
query auditLogs {
|
||||
auditLogs {
|
||||
edges {
|
||||
node {
|
||||
name
|
||||
properties
|
||||
context
|
||||
objectName
|
||||
objectMetadataId
|
||||
recordId
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
deletedAt
|
||||
workspaceMemberId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
};
|
||||
|
||||
return client
|
||||
.post('/graphql')
|
||||
.set('Authorization', `Bearer ${ADMIN_ACCESS_TOKEN}`)
|
||||
.send(queryData)
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
expect(res.body.data).toBeDefined();
|
||||
expect(res.body.errors).toBeUndefined();
|
||||
})
|
||||
.expect((res) => {
|
||||
const data = res.body.data.auditLogs;
|
||||
|
||||
expect(data).toBeDefined();
|
||||
expect(Array.isArray(data.edges)).toBe(true);
|
||||
|
||||
const edges = data.edges;
|
||||
|
||||
if (edges.length > 0) {
|
||||
const auditLogs = edges[0].node;
|
||||
|
||||
expect(auditLogs).toHaveProperty('name');
|
||||
expect(auditLogs).toHaveProperty('properties');
|
||||
expect(auditLogs).toHaveProperty('context');
|
||||
expect(auditLogs).toHaveProperty('objectName');
|
||||
expect(auditLogs).toHaveProperty('objectMetadataId');
|
||||
expect(auditLogs).toHaveProperty('recordId');
|
||||
expect(auditLogs).toHaveProperty('id');
|
||||
expect(auditLogs).toHaveProperty('createdAt');
|
||||
expect(auditLogs).toHaveProperty('updatedAt');
|
||||
expect(auditLogs).toHaveProperty('deletedAt');
|
||||
expect(auditLogs).toHaveProperty('workspaceMemberId');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,6 +1,6 @@
|
||||
import { TrackEventName } from 'src/engine/core-modules/analytics/types/events.type';
|
||||
import { TrackEventName } from 'src/engine/core-modules/audit/types/events.type';
|
||||
|
||||
export const AnalyticsContextMock = (params?: {
|
||||
export const AuditContextMock = (params?: {
|
||||
track?:
|
||||
| ((
|
||||
event: TrackEventName,
|
||||
Reference in New Issue
Block a user