mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-21 10:54:08 +02:00
fix(openapi): keep authenticated cookie parameters
This commit is contained in:
@@ -1604,7 +1604,8 @@ function mergeHeaders(...headerGroups: HttpRequestHeader[][]): HttpRequestHeader
|
||||
for (const group of headerGroups) {
|
||||
const namesFromEarlierGroups = new Set(headers.map((header) => header.name.toLowerCase()));
|
||||
for (const header of group) {
|
||||
if (!namesFromEarlierGroups.has(header.name.toLowerCase())) {
|
||||
const name = header.name.toLowerCase();
|
||||
if (name === "cookie" || !namesFromEarlierGroups.has(name)) {
|
||||
headers.push(header);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -807,6 +807,53 @@ describe("importer-openapi", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("Preserves parameter cookies alongside cookie API-key authentication", async () => {
|
||||
const imported = await convertOpenApi(
|
||||
JSON.stringify({
|
||||
openapi: "3.0.4",
|
||||
info: { title: "Authenticated Cookie Test", version: "1.0.0" },
|
||||
paths: {
|
||||
"/items": {
|
||||
get: {
|
||||
security: [{ basicAuth: [], cookieKey: [] }],
|
||||
parameters: [
|
||||
{
|
||||
name: "session",
|
||||
in: "cookie",
|
||||
required: true,
|
||||
schema: { type: "string", example: "abc" },
|
||||
},
|
||||
{
|
||||
name: "debug",
|
||||
in: "cookie",
|
||||
schema: { type: "string", example: "verbose" },
|
||||
},
|
||||
],
|
||||
responses: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
securitySchemes: {
|
||||
basicAuth: { type: "http", scheme: "basic" },
|
||||
cookieKey: { type: "apiKey", in: "cookie", name: "api_key" },
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(imported?.resources.httpRequests[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
authenticationType: "basic",
|
||||
headers: [
|
||||
{ enabled: true, name: "Cookie", value: "api_key=${[auth_cookie_key_key]}" },
|
||||
{ enabled: true, name: "Cookie", value: "session=abc" },
|
||||
{ enabled: false, name: "Cookie", value: "debug=verbose" },
|
||||
],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test("Serializes structured query parameters according to style and explode", async () => {
|
||||
const imported = await convertOpenApi(
|
||||
JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user