mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): Some more browser-id related fixes (no-changelog) (#9102)
This commit is contained in:
committed by
GitHub
parent
3e231dbfe6
commit
a7108d14f9
@@ -22,6 +22,7 @@ import { PUBLIC_API_REST_PATH_SEGMENT, REST_PATH_SEGMENT } from '../constants';
|
||||
import type { SetupProps, TestServer } from '../types';
|
||||
import { LicenseMocker } from '../license';
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import type { APIRequest } from '@/requests';
|
||||
|
||||
/**
|
||||
* Plugin to prefix a path segment into a request URL pathname.
|
||||
@@ -43,11 +44,12 @@ function prefix(pathSegment: string) {
|
||||
};
|
||||
}
|
||||
|
||||
const browserId = 'test-browser-id';
|
||||
function createAgent(app: express.Application, options?: { auth: boolean; user: User }) {
|
||||
const agent = request.agent(app);
|
||||
void agent.use(prefix(REST_PATH_SEGMENT));
|
||||
if (options?.auth && options?.user) {
|
||||
const token = Container.get(AuthService).issueJWT(options.user);
|
||||
const token = Container.get(AuthService).issueJWT(options.user, browserId);
|
||||
agent.jar.setCookie(`${AUTH_COOKIE_NAME}=${token}`);
|
||||
}
|
||||
return agent;
|
||||
@@ -73,6 +75,10 @@ export const setupTestServer = ({
|
||||
const app = express();
|
||||
app.use(rawBodyReader);
|
||||
app.use(cookieParser());
|
||||
app.use((req: APIRequest, _, next) => {
|
||||
req.browserId = browserId;
|
||||
next();
|
||||
});
|
||||
|
||||
// Mock all telemetry and logging
|
||||
mockInstance(Logger);
|
||||
|
||||
Reference in New Issue
Block a user