-
Notifications
You must be signed in to change notification settings - Fork 489
fix(cli): wire --experimental gate into 7 ungated native leaves #5766
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
Open
Coly010
wants to merge
6
commits into
develop
Choose a base branch
from
columferry/cli-1854-wire-the-experimental-gate-into-the-7-ungated-native-leaves
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2443cfc
fix(cli): wire --experimental gate into 7 ungated native management-A…
Coly010 127fd49
fix(cli): validate --output enum before the experimental gate (review…
Coly010 0d35747
test(cli): isolate experimental-gate tests from ambient env/keyring (…
Coly010 06509cf
Merge remote-tracking branch 'origin/develop' into columferry/cli-185…
Coly010 30ffe1e
test(cli): isolate gate-open tests from the credentials file-fallback…
Coly010 e5ee27e
docs(cli): document the --experimental gate in the 7 newly-gated leav…
Coly010 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
114 changes: 114 additions & 0 deletions
114
apps/cli/src/legacy/commands/network-bans/network-bans.experimental-gate.integration.test.ts
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,114 @@ | ||
| import { describe, expect, it } from "@effect/vitest"; | ||
| import { Effect, Exit, Layer } from "effect"; | ||
| import { CliOutput, Command } from "effect/unstable/cli"; | ||
|
|
||
| import { textCliOutputFormatter } from "../../../shared/output/text-formatter.ts"; | ||
| import { LEGACY_GLOBAL_FLAGS } from "../../../shared/legacy/global-flags.ts"; | ||
| import { TelemetryRuntime } from "../../../shared/telemetry/runtime.service.ts"; | ||
| import { makeTelemetryIdentity } from "../../../shared/telemetry/identity.ts"; | ||
| import { mockOutput, processEnvLayer } from "../../../../tests/helpers/mocks.ts"; | ||
| import { | ||
| buildLegacyTestRuntime, | ||
| mockLegacyCliConfig, | ||
| mockLegacyPlatformApi, | ||
| useLegacyTempWorkdir, | ||
| } from "../../../../tests/helpers/legacy-mocks.ts"; | ||
| import { legacyNetworkBansCommand } from "./network-bans.command.ts"; | ||
|
|
||
| // See postgres-config.experimental-gate.integration.test.ts for the full | ||
| // rationale: this proves `--experimental` is wired into the actual | ||
| // `.command.ts` handler pipeline AND runs before | ||
| // `legacyManagementApiRuntimeLayer`'s eager access-token resolution | ||
| // (Go's `IsExperimental` check precedes `IsManagementAPI` in | ||
| // `apps/cli-go/cmd/root.go:91-109`). | ||
|
|
||
| const tempRoot = useLegacyTempWorkdir("supabase-network-bans-experimental-int-"); | ||
|
|
||
| const testRoot = Command.make("supabase").pipe( | ||
| Command.withGlobalFlags(LEGACY_GLOBAL_FLAGS), | ||
| Command.withSubcommands([legacyNetworkBansCommand]), | ||
| ); | ||
|
|
||
| function setup() { | ||
| const out = mockOutput({ format: "text" }); | ||
| const api = mockLegacyPlatformApi({ | ||
| response: { status: 200, body: { banned_ipv4_addresses: [] } }, | ||
| }); | ||
| const runtime = buildLegacyTestRuntime({ | ||
| out, | ||
| api, | ||
| cliConfig: mockLegacyCliConfig({ workdir: tempRoot.current }), | ||
| }); | ||
| const layer = Layer.mergeAll( | ||
| runtime, | ||
| CliOutput.layer(textCliOutputFormatter()), | ||
| // The "gate open" case reaches the real `legacyManagementApiRuntimeLayer` | ||
| // (provided inline inside the command, not by this test's mocked runtime), | ||
| // which reads credentials/env directly — an ambient SUPABASE_ACCESS_TOKEN, | ||
| // SUPABASE_EXPERIMENTAL, or OS keyring entry on the machine running the | ||
| // test would make these assertions non-deterministic. Wipe process.env | ||
| // down to just this and disable the keyring fallback. | ||
| processEnvLayer({ SUPABASE_NO_KEYRING: "1" }), | ||
| Layer.succeed( | ||
| TelemetryRuntime, | ||
| TelemetryRuntime.of({ | ||
| configDir: `${tempRoot.current}/.supabase`, | ||
| tracesDir: `${tempRoot.current}/.supabase/traces`, | ||
| consent: "granted", | ||
| showDebug: false, | ||
| deviceId: "test-device-id", | ||
| sessionId: "test-session-id", | ||
| identity: makeTelemetryIdentity(undefined), | ||
| isFirstRun: false, | ||
| isTty: false, | ||
| isCi: false, | ||
| os: "linux", | ||
| arch: "x64", | ||
| cliVersion: "0.1.0", | ||
| }), | ||
| ), | ||
| ); | ||
| return { layer, api }; | ||
| } | ||
|
|
||
| describe("legacy network-bans experimental gate (Go PersistentPreRunE parity)", () => { | ||
| const leaves: ReadonlyArray<{ readonly name: string; readonly args: ReadonlyArray<string> }> = [ | ||
| { name: "get", args: ["network-bans", "get"] }, | ||
| { name: "remove", args: ["network-bans", "remove"] }, | ||
| ]; | ||
|
|
||
| for (const { name, args } of leaves) { | ||
| it.live( | ||
| `${name} fails with LegacyExperimentalRequiredError when --experimental is unset`, | ||
| () => { | ||
| const { layer, api } = setup(); | ||
| return Effect.gen(function* () { | ||
| const exit = yield* Effect.exit( | ||
| Command.runWith(testRoot, { version: "0.0.0-test" })(args), | ||
| ); | ||
| expect(Exit.isFailure(exit)).toBe(true); | ||
| if (Exit.isFailure(exit)) { | ||
| expect(JSON.stringify(exit.cause)).toContain("LegacyExperimentalRequiredError"); | ||
| } | ||
| expect(api.requests).toHaveLength(0); | ||
| }).pipe(Effect.provide(layer)); | ||
| }, | ||
| ); | ||
|
|
||
| it.live(`${name} does not fail with the gate error once --experimental is set`, () => { | ||
| const { layer, api } = setup(); | ||
| return Effect.gen(function* () { | ||
| const exit = yield* Effect.exit( | ||
| Command.runWith(testRoot, { version: "0.0.0-test" })([...args, "--experimental"]), | ||
| ); | ||
| expect(Exit.isFailure(exit)).toBe(true); | ||
| if (Exit.isFailure(exit)) { | ||
| const causeText = JSON.stringify(exit.cause); | ||
| expect(causeText).not.toContain("LegacyExperimentalRequiredError"); | ||
| expect(causeText).toContain("LegacyPlatformAuthRequiredError"); | ||
| } | ||
| expect(api.requests).toHaveLength(0); | ||
| }).pipe(Effect.provide(layer)); | ||
| }); | ||
| } | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.