Skip to content
Merged
Changes from all 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
30 changes: 15 additions & 15 deletions test/e2e/http-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('E2E HTTP QUERY method', () => {
it('should proxy QUERY method and uri-query to target', async () => {
let completedRequest: CompletedRequest | undefined;

await mockTargetServer.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenCallback((req) => {
completedRequest = req;
return { statusCode: 200, body: 'QUERY OK' };
});
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('E2E HTTP QUERY method', () => {
it('should preserve encoded query values in QUERY requests', async () => {
let completedRequest: CompletedRequest | undefined;

await mockTargetServer.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenCallback((req) => {
completedRequest = req;
return { statusCode: 200, body: 'ENCODING OK' };
});
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('E2E HTTP QUERY method', () => {
it('should proxy QUERY request body when fixRequestBody is enabled', async () => {
let completedRequest: CompletedRequest | undefined;

await mockTargetServer.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenCallback((req) => {
completedRequest = req;
return { statusCode: 200, body: 'BODY OK' };
});
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('E2E HTTP QUERY method', () => {
});

it('should pass through 204 responses for QUERY requests', async () => {
await mockTargetServer.forAnyRequest().thenReply(204);
await mockTargetServer.forQuery().thenReply(204);

const app = createApp(
createProxyMiddleware({
Expand All @@ -184,7 +184,7 @@ describe('E2E HTTP QUERY method', () => {
});

it('should pass through error responses for QUERY requests', async () => {
await mockTargetServer.forAnyRequest().thenReply(422, 'invalid-query');
await mockTargetServer.forQuery().thenReply(422, 'invalid-query');

const app = createApp(
createProxyMiddleware({
Expand All @@ -204,7 +204,7 @@ describe('E2E HTTP QUERY method', () => {
it('should pass through 400 when QUERY body uses fetch default Content-Type', async () => {
let completedRequest: CompletedRequest | undefined;

await mockTargetServer.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenCallback((req) => {
completedRequest = req;
return { statusCode: 400, body: 'unsupported-default-content-type' };
});
Expand All @@ -227,7 +227,7 @@ describe('E2E HTTP QUERY method', () => {
});

it('should pass through 400 when QUERY Content-Type is inconsistent with content', async () => {
await mockTargetServer.forAnyRequest().thenReply(400, 'invalid-content-for-type');
await mockTargetServer.forQuery().thenReply(400, 'invalid-content-for-type');

const app = createApp(
createProxyMiddleware({
Expand All @@ -246,7 +246,7 @@ describe('E2E HTTP QUERY method', () => {
});

it('should pass through 415 and Accept-Query for unsupported QUERY media type', async () => {
await mockTargetServer.forAnyRequest().thenReply(415, 'unsupported-media-type', {
await mockTargetServer.forQuery().thenReply(415, 'unsupported-media-type', {
'accept-query': 'application/jsonpath, application/sql',
});

Expand All @@ -268,7 +268,7 @@ describe('E2E HTTP QUERY method', () => {
});

it('should pass through 405 and Allow when QUERY is not supported on target resource', async () => {
await mockTargetServer.forAnyRequest().thenReply(405, 'method-not-allowed', {
await mockTargetServer.forQuery().thenReply(405, 'method-not-allowed', {
allow: 'GET, OPTIONS, HEAD',
});

Expand All @@ -294,7 +294,7 @@ describe('E2E HTTP QUERY method', () => {
it('should apply pathFilter for QUERY requests', async () => {
const targetSpy = vi.fn();

await mockTargetServer.forAnyRequest().thenCallback(() => {
await mockTargetServer.forQuery().thenCallback(() => {
targetSpy();
return { statusCode: 200, body: 'SHOULD NOT HAPPEN' };
});
Expand All @@ -315,7 +315,7 @@ describe('E2E HTTP QUERY method', () => {
it('should rewrite path for QUERY requests', async () => {
let completedRequest: CompletedRequest | undefined;

await mockTargetServer.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenCallback((req) => {
completedRequest = req;
return { statusCode: 200, body: 'REWRITE OK' };
});
Expand Down Expand Up @@ -349,8 +349,8 @@ describe('E2E HTTP QUERY method', () => {
let routedRequest: CompletedRequest | undefined;

try {
await mockTargetServer.forAnyRequest().thenReply(200, 'DEFAULT TARGET');
await routerTarget.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenReply(200, 'DEFAULT TARGET');
await routerTarget.forQuery().thenCallback((req) => {
routedRequest = req;
return { statusCode: 200, body: 'ROUTED TARGET' };
});
Expand Down Expand Up @@ -380,7 +380,7 @@ describe('E2E HTTP QUERY method', () => {
it('should change host header for QUERY when changeOrigin is true', async () => {
let completedRequest: CompletedRequest | undefined;

await mockTargetServer.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenCallback((req) => {
completedRequest = req;
return { statusCode: 200, body: 'CHANGE ORIGIN OK' };
});
Expand All @@ -405,7 +405,7 @@ describe('E2E HTTP QUERY method', () => {
it('should forward custom headers for QUERY requests', async () => {
let completedRequest: CompletedRequest | undefined;

await mockTargetServer.forAnyRequest().thenCallback((req) => {
await mockTargetServer.forQuery().thenCallback((req) => {
completedRequest = req;
return { statusCode: 200, body: 'HEADERS OK' };
});
Expand Down
Loading