mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
Clarify API key login and status messages (#55407)
## Why Saving an API key does not validate it. Login and status messages should make clear that authentication is checked when a request is sent. ## What changed Report `API key saved` after API key login and `API key configured` in `login status`. Both messages now explain when authentication is checked. ## Testing Update the API key login integration test with snapshots for login and status output, while retaining assertions that the key is saved to `auth.json`. GitOrigin-RevId: 2f36ebb270a48771be25060a596cf9731e8d0325
This commit is contained in:
+26
-10
@@ -52,22 +52,38 @@ fn login_with_api_key_reads_stdin_and_writes_auth_json() -> Result<()> {
|
||||
write_file_auth_config(codex_home.path())?;
|
||||
|
||||
let mut cmd = codex_command(codex_home.path())?;
|
||||
cmd.args([
|
||||
"-c",
|
||||
"forced_login_method=\"api\"",
|
||||
"login",
|
||||
"--with-api-key",
|
||||
])
|
||||
.write_stdin("sk-test\n")
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(contains("Successfully logged in"));
|
||||
let login = cmd
|
||||
.args([
|
||||
"-c",
|
||||
"forced_login_method=\"api\"",
|
||||
"login",
|
||||
"--with-api-key",
|
||||
])
|
||||
.write_stdin("sk-test\n")
|
||||
.assert()
|
||||
.success();
|
||||
insta::assert_snapshot!(String::from_utf8_lossy(&login.get_output().stderr), @r"
|
||||
Reading API key from stdin...
|
||||
API key saved. Authentication is checked when you send a request.
|
||||
");
|
||||
|
||||
let auth = read_auth_json(codex_home.path())?;
|
||||
assert_eq!(auth["OPENAI_API_KEY"], "sk-test");
|
||||
assert!(auth.get("tokens").is_none());
|
||||
assert!(auth.get("agent_identity").is_none());
|
||||
|
||||
let status = codex_command(codex_home.path())?
|
||||
.env_remove(CODEX_ACCESS_TOKEN_ENV_VAR)
|
||||
.env_remove(OPENAI_FEDERATION_RULE_ID_ENV_VAR)
|
||||
.env_remove(OPENAI_IDENTITY_TOKEN_FILE_ENV_VAR)
|
||||
.args(["login", "status"])
|
||||
.assert()
|
||||
.success();
|
||||
insta::assert_snapshot!(String::from_utf8_lossy(&status.get_output().stderr), @r"
|
||||
API key configured - ***
|
||||
Authentication is checked when you send a request.
|
||||
");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user