mirror of
https://github.com/n8n-io/n8n.git
synced 2026-07-28 03:24:59 +02:00
fix(core): Stabilize public API test logging (no-changelog) (#32060)
This commit is contained in:
parent
3059088ab6
commit
3dd6aaa22e
|
|
@ -77,18 +77,19 @@ function createLazyValidatorMiddleware(
|
|||
'express-openapi-validator'
|
||||
);
|
||||
|
||||
const authStrategyRegistry = Container.get(AuthStrategyRegistry);
|
||||
const eventService = Container.get(EventService);
|
||||
const lastActiveAtService = Container.get(LastActiveAtService);
|
||||
const logger = Container.get(Logger);
|
||||
|
||||
const authenticate = async (req: AuthenticatedRequest) => {
|
||||
const authenticated = await Container.get(AuthStrategyRegistry).authenticate(req);
|
||||
const authenticated = await authStrategyRegistry.authenticate(req);
|
||||
|
||||
if (authenticated) {
|
||||
Container.get(LastActiveAtService)
|
||||
.updateLastActiveIfStale(req.user.id)
|
||||
.catch((error: unknown) => {
|
||||
Container.get(Logger).error('Failed to update last active timestamp', {
|
||||
error,
|
||||
});
|
||||
});
|
||||
Container.get(EventService).emit('public-api-invoked', {
|
||||
lastActiveAtService.updateLastActiveIfStale(req.user.id).catch((error: unknown) => {
|
||||
logger.error('Failed to update last active timestamp', { error });
|
||||
});
|
||||
eventService.emit('public-api-invoked', {
|
||||
userId: req.user.id,
|
||||
path: req.path,
|
||||
method: req.method,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { LicenseState, ModuleRegistry } from '@n8n/backend-common';
|
||||
import { LicenseState, Logger, ModuleRegistry } from '@n8n/backend-common';
|
||||
import { mockInstance, mockLogger, testModules, testDb } from '@n8n/backend-test-utils';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import type { APIRequest, User } from '@n8n/db';
|
||||
|
|
@ -110,7 +110,7 @@ export const setupTestServer = ({
|
|||
});
|
||||
|
||||
// Mock all telemetry and logging
|
||||
mockLogger();
|
||||
Container.set(Logger, mockLogger());
|
||||
mockInstance(PostHogClient);
|
||||
mockInstance(Push);
|
||||
mockInstance(Telemetry);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user