Public release release-b8454b34d38c
Source commit: b8454b34d38cc2ba0bd278e842060db45d091e1c Public tree identity: sha256:69d6c8143bf6227e1bb07852aa94e8af9c26793eca252bb46788894f728cb6d2
This commit is contained in:
commit
d2e84229c5
221 changed files with 80960 additions and 0 deletions
72
scripts/cli-login-smoke.js
Normal file
72
scripts/cli-login-smoke.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const assert = require("assert");
|
||||
const cp = require("child_process");
|
||||
const path = require("path");
|
||||
|
||||
const repo = path.resolve(__dirname, "..");
|
||||
const coordinator = "https://coord.example.test";
|
||||
const defaultHostedCoordinatorEndpoint = "https://clusterflux.michelpaulissen.com";
|
||||
|
||||
function clusterflux(args) {
|
||||
return JSON.parse(
|
||||
cp.execFileSync(
|
||||
"cargo",
|
||||
["run", "-q", "-p", "clusterflux-cli", "--bin", "clusterflux", "--", ...args],
|
||||
{ cwd: repo, encoding: "utf8" }
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function clusterfluxRaw(args, env = {}) {
|
||||
return cp.spawnSync(
|
||||
"cargo",
|
||||
["run", "-q", "-p", "clusterflux-cli", "--bin", "clusterflux", "--", ...args],
|
||||
{
|
||||
cwd: repo,
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
...process.env,
|
||||
...env,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const browser = clusterflux(["login", "--plan", "--coordinator", coordinator, "--json"]);
|
||||
assert.strictEqual(browser.coordinator, coordinator);
|
||||
assert(browser.human_flow.Browser, "browser login should be available for human users");
|
||||
assert.strictEqual(browser.human_flow.Browser.authorization_url, null);
|
||||
assert.strictEqual(browser.human_flow.Browser.server_owns_state, true);
|
||||
assert.strictEqual(browser.human_flow.Browser.server_owns_nonce, true);
|
||||
assert.strictEqual(browser.human_flow.Browser.pkce_required, true);
|
||||
assert.strictEqual(browser.human_flow.Browser.hosted_callback, true);
|
||||
assert.strictEqual(browser.human_flow.Browser.cli_receives_provider_authorization_code, false);
|
||||
assert.strictEqual(browser.human_flow.Browser.cli_submits_identity_claims, false);
|
||||
|
||||
const defaultBrowser = clusterflux(["login", "--plan", "--json"]);
|
||||
assert.strictEqual(defaultBrowser.coordinator, defaultHostedCoordinatorEndpoint);
|
||||
assert(defaultBrowser.human_flow.Browser);
|
||||
|
||||
const nonInteractiveBrowser = clusterfluxRaw(
|
||||
["login", "--browser", "--non-interactive", "--coordinator", coordinator, "--json"],
|
||||
{
|
||||
CLUSTERFLUX_BROWSER_OPEN_COMMAND:
|
||||
"node -e 'require(\"fs\").writeFileSync(\"/tmp/clusterflux-browser-should-not-open\", \"opened\")'",
|
||||
}
|
||||
);
|
||||
assert.strictEqual(nonInteractiveBrowser.status, 20, nonInteractiveBrowser.stderr);
|
||||
assert.doesNotMatch(nonInteractiveBrowser.stderr, /Opening Clusterflux browser login/);
|
||||
const nonInteractiveReport = JSON.parse(nonInteractiveBrowser.stdout);
|
||||
assert.strictEqual(nonInteractiveReport.status, "authentication_required");
|
||||
assert.strictEqual(nonInteractiveReport.non_interactive, true);
|
||||
assert.strictEqual(nonInteractiveReport.browser_opened, false);
|
||||
assert.strictEqual(nonInteractiveReport.machine_error.category, "authentication");
|
||||
assert.strictEqual(nonInteractiveReport.machine_error.stable_exit_code, 20);
|
||||
assert(
|
||||
nonInteractiveReport.machine_error.next_actions.includes(
|
||||
"rerun without --non-interactive to open the browser"
|
||||
)
|
||||
);
|
||||
|
||||
console.log("CLI login smoke passed");
|
||||
Loading…
Add table
Add a link
Reference in a new issue