-
Notifications
You must be signed in to change notification settings - Fork 145
[codex] Fix OpenAPI multi-key auth inputs #1151
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
Merged
+203
−18
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@executor-js/plugin-openapi": patch | ||
| --- | ||
|
|
||
| Derive separate credential inputs for OpenAPI auth strategies that require multiple API key headers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| // Cross-target (browser): OpenAPI security strategies that require multiple | ||
| // API key headers must collect one credential value per header. Cloudflare's | ||
| // legacy API key auth is the concrete regression: one OpenAPI security object | ||
| // requires both `api_email` and `api_key`, so Add connection must show two | ||
| // credential inputs, not one shared token field. | ||
| import { randomBytes } from "node:crypto"; | ||
|
|
||
| import { expect } from "@effect/vitest"; | ||
| import { Effect } from "effect"; | ||
| import { composePluginApi } from "@executor-js/api/server"; | ||
| import { openApiHttpPlugin } from "@executor-js/plugin-openapi/api"; | ||
| import { IntegrationSlug } from "@executor-js/sdk/shared"; | ||
|
|
||
| import { scenario } from "../src/scenario"; | ||
| import { Api, Browser, Target } from "../src/services"; | ||
|
|
||
| const api = composePluginApi([openApiHttpPlugin()] as const); | ||
|
|
||
| const cloudflareStyleSpec = (): string => | ||
| JSON.stringify({ | ||
| openapi: "3.0.3", | ||
| info: { title: "Cloudflare Auth Fixture", version: "1.0.0" }, | ||
| servers: [{ url: "https://api.cloudflare.test/client/v4" }], | ||
| security: [{ api_email: [], api_key: [] }], | ||
| components: { | ||
| securitySchemes: { | ||
| api_email: { type: "apiKey", in: "header", name: "X-Auth-Email" }, | ||
| api_key: { type: "apiKey", in: "header", name: "X-Auth-Key" }, | ||
| }, | ||
| }, | ||
| paths: { | ||
| "/accounts": { | ||
| get: { | ||
| operationId: "listAccounts", | ||
| summary: "List accounts", | ||
| responses: { "200": { description: "ok" } }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| scenario( | ||
| "OpenAPI · the Cloudflare email and key auth method shows separate credential fields", | ||
| {}, | ||
| Effect.gen(function* () { | ||
| const target = yield* Target; | ||
| const { client: makeApiClient } = yield* Api; | ||
| const browser = yield* Browser; | ||
| const identity = yield* target.newIdentity(); | ||
| const apiClient = yield* makeApiClient(api, identity); | ||
| const slug = `openapi_auth_fields_${randomBytes(4).toString("hex")}`; | ||
|
|
||
| yield* Effect.ensuring( | ||
| Effect.gen(function* () { | ||
| yield* apiClient.openapi.addSpec({ | ||
| payload: { | ||
| spec: { kind: "blob", value: cloudflareStyleSpec() }, | ||
| slug, | ||
| }, | ||
| }); | ||
|
|
||
| yield* browser.session(identity, async ({ page, step }) => { | ||
| await step("Open the Cloudflare-style integration", async () => { | ||
| await page.goto(`/integrations/${slug}`, { waitUntil: "networkidle" }); | ||
| await page.getByText("Connections").first().waitFor(); | ||
| }); | ||
|
|
||
| await step("Open the add-connection modal", async () => { | ||
| await page.getByRole("button", { name: "Add connection" }).first().click(); | ||
| await page.getByRole("dialog", { name: /Add connection/ }).waitFor(); | ||
| }); | ||
|
|
||
| await step("The legacy Cloudflare method asks for email and key separately", async () => { | ||
| await page.getByRole("tab", { name: "API key (X-Auth-Email)" }).click(); | ||
| const dialog = page.getByRole("dialog", { name: /Add connection/ }); | ||
|
|
||
| const credentialInputs = dialog.locator('input[type="password"]'); | ||
| await dialog.getByPlaceholder("paste X-Auth-Email").waitFor(); | ||
| await dialog.getByPlaceholder("paste X-Auth-Key").waitFor(); | ||
| expect( | ||
| await credentialInputs.count(), | ||
| "the modal renders one secret input for each required header", | ||
| ).toBe(2); | ||
| expect( | ||
| await dialog.getByPlaceholder("paste X-Auth-Email").isVisible(), | ||
| "email has its own input", | ||
| ).toBe(true); | ||
| expect( | ||
| await dialog.getByPlaceholder("paste X-Auth-Key").isVisible(), | ||
| "API key has its own input", | ||
| ).toBe(true); | ||
| }); | ||
| }); | ||
| }), | ||
| apiClient.openapi | ||
| .removeSpec({ params: { slug: IntegrationSlug.make(slug) } }) | ||
| .pipe(Effect.ignore), | ||
| ); | ||
| }), | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitFor()waitFor()with its default state ("visible") already confirms each element is present and visible. The twoisVisible()checks below add no assertion value and do not improve failure messages over thewaitFor()lines above them. Per the AGENTS.md quality bar ("no tautologies — don't assert what the setup already guarantees"), these can be removed; thecount()assertion pluswaitFor()already pin the exact UI state the test needs to prove.Context Used: e2e/AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!