Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-44 remove/replace headers while recording tc #47

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mock/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -71,6 +73,8 @@ export function NewContext(conf: Config) {
testId: conf.Name,
mocks: [],
fileExport: true,
Remove: conf.Remove,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Remove and Replace should be added in record mode. Since we filtering during recording.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. I've fixed this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Replace: conf.Replace,
});
const ctx = getExecutionContext().context;
grpcClient.GetMocks({ Path: path, Name: conf.Name }, (err, response) => {
Expand Down
4 changes: 3 additions & 1 deletion mock/utils.ts
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/keploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const V1_BETA2 = "api.keploy.io/v1beta2",

type AppConfigFilter = {
urlRegex?: string;
remove?: string[];
replace?: { [key: string]: string };
};

type AppConfig = {
Expand Down Expand Up @@ -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);
}

Expand Down