From f71f27a923d6602f1fda485ee183523f10b2d0ab Mon Sep 17 00:00:00 2001 From: Shreyansh Shah Date: Fri, 24 Feb 2023 00:20:19 +0530 Subject: [PATCH 1/3] feat: remove/replace headers while recording tc Signed-off-by: Shreyansh Shah --- src/keploy.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/keploy.ts b/src/keploy.ts index 1de2cca..d69c201 100644 --- a/src/keploy.ts +++ b/src/keploy.ts @@ -29,6 +29,8 @@ export const V1_BETA2 = "api.keploy.io/v1beta2", type AppConfigFilter = { urlRegex?: string; + remove?: string[]; + replace?: { [key: string]: string }; }; type AppConfig = { @@ -163,6 +165,8 @@ export default class Keploy { } capture(req: TestCaseReq) { + req.Remove=this.appConfig.filter.remove + req.Replace=this.appConfig.filter.replace return this.put(req); } From e6cbd012e0cac5c74f701ecd9701357c547afcd2 Mon Sep 17 00:00:00 2001 From: Shreyansh Shah Date: Thu, 2 Mar 2023 21:45:12 +0530 Subject: [PATCH 2/3] feat: support for mock library Signed-off-by: Shreyansh Shah --- mock/mock.ts | 4 ++++ mock/utils.ts | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mock/mock.ts b/mock/mock.ts index 3c8cfc9..471a193 100644 --- a/mock/mock.ts +++ b/mock/mock.ts @@ -25,6 +25,8 @@ export interface Config { Name: string; Path: string; Mode: string; + Remove?: string[]; + Replace?: { [key: string]: string }; } export function NewContext(conf: Config) { let mode = MODE_TEST, @@ -71,6 +73,8 @@ export function NewContext(conf: Config) { testId: conf.Name, mocks: [], fileExport: true, + Remove: conf.Remove, + Replace: conf.Replace, }); const ctx = getExecutionContext().context; grpcClient.GetMocks({ Path: path, Name: conf.Name }, (err, response) => { diff --git a/mock/utils.ts b/mock/utils.ts index cbeee52..6cac1cf 100644 --- a/mock/utils.ts +++ b/mock/utils.ts @@ -1,9 +1,11 @@ import { response } from "express"; import { Mock } from "../proto/services/Mock"; +import { getExecutionContext } from "../src/context"; import { grpcClient, MockIds, mockPath } from "./mock"; export function putMocks(mock: Mock) { - grpcClient.PutMock({ Path: mockPath, Mock: mock }, (err, response) => { + const ctx = getExecutionContext().context + grpcClient.PutMock({ Path: mockPath, Mock: mock, Remove:ctx.Remove, Replace:ctx.Replace }, (err, response) => { if (err !== null) { console.error(err); } From 764b5229aff8c50661f85b219d7b1f4293957f60 Mon Sep 17 00:00:00 2001 From: Shreyansh Shah Date: Sat, 4 Mar 2023 19:48:59 +0530 Subject: [PATCH 3/3] fix: review comments Signed-off-by: Shreyansh Shah --- mock/mock.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mock/mock.ts b/mock/mock.ts index 471a193..f8ca4f3 100644 --- a/mock/mock.ts +++ b/mock/mock.ts @@ -73,8 +73,6 @@ export function NewContext(conf: Config) { testId: conf.Name, mocks: [], fileExport: true, - Remove: conf.Remove, - Replace: conf.Replace, }); const ctx = getExecutionContext().context; grpcClient.GetMocks({ Path: path, Name: conf.Name }, (err, response) => { @@ -92,6 +90,8 @@ export function NewContext(conf: Config) { testId: conf.Name, mocks: [], fileExport: true, + Remove: conf.Remove, + Replace: conf.Replace, }); break; default: