do not expect secure connection in metering cy test

This commit is contained in:
Gergő Ábrahám 2025-03-21 10:08:01 +01:00
parent 0b65d1131c
commit 73dc41ef4c
2 changed files with 20 additions and 6 deletions

View file

@ -13,6 +13,7 @@ import DebugProxy from '@cypress/debugging-proxy';
import { ES_CERT_PATH, ES_KEY_PATH } from '@kbn/dev-utils';
import type { UsageRecord } from '@kbn/security-solution-serverless/server/types';
import { setupStackServicesUsingCypressConfig } from './common';
import { type StartTransparentApiProxyOptions } from '../tasks/transparent_api_proxy';
export const transparentApiProxy = (
on: Cypress.PluginEvents,
@ -22,7 +23,7 @@ export const transparentApiProxy = (
const interceptedRequestBody: UsageRecord[][] = [];
on('task', {
startTransparentApiProxy: async (options) => {
startTransparentApiProxy: async (options: StartTransparentApiProxyOptions) => {
const { log } = await setupStackServicesUsingCypressConfig(config);
const port = options?.port || 3623;
@ -30,12 +31,18 @@ export const transparentApiProxy = (
log.debug(`[Transparent API] Starting transparent API proxy on port ${port}`);
try {
const httpsOptions = options?.useCert
? {
https: {
key: fs.readFileSync(ES_KEY_PATH),
cert: fs.readFileSync(ES_CERT_PATH),
},
}
: {};
proxy = new DebugProxy({
keepRequests: true,
https: {
key: fs.readFileSync(ES_KEY_PATH),
cert: fs.readFileSync(ES_CERT_PATH),
},
...httpsOptions,
onRequest: (_: string, req: IncomingMessage, res: ServerResponse) => {
let body = '';

View file

@ -7,7 +7,14 @@
import type { UsageRecord } from '@kbn/security-solution-serverless/server/types';
export const startTransparentApiProxy = (options: { port?: number }): Cypress.Chainable<null> => {
export interface StartTransparentApiProxyOptions {
port?: number;
useCert?: boolean;
}
export const startTransparentApiProxy = (
options: StartTransparentApiProxyOptions
): Cypress.Chainable<null> => {
return cy.task('startTransparentApiProxy', options);
};