fix: use active env for auth login#26
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the built-in runtime auth login/auth logout commands to default their target environment from the active middleware environment when --env is not provided, while keeping an explicitly provided --env as an override. It also adds regression tests and updates documentation to reflect the new optional --env behavior.
Changes:
- Make
auth loginandauth logoutaccept omitted--envand resolve the environment from middleware state. - Add regression tests covering middleware default env behavior and explicit
--envoverride. - Update auth command docs to document
--envas optional for login/logout.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/foundation.rs |
Adds tests for env resolution behavior and adjusts command-spec assertions for optional --env. |
src/auth/commands.rs |
Makes --env optional for login/logout and adds env resolution helper with a runtime error when missing. |
docs/auth.md |
Updates built-in auth command documentation to reflect optional --env semantics for login/logout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn env_arg(context: &CommandContext) -> Result<String> { | ||
| let env = string_arg(&context.args, "env"); | ||
| if !env.is_empty() { | ||
| return Ok(env); | ||
| } | ||
|
|
||
| if !context.middleware.env.is_empty() { | ||
| return Ok(context.middleware.env.clone()); | ||
| } | ||
|
|
||
| Err(CliCoreError::message( | ||
| "auth: missing environment; pass --env or configure a default environment", | ||
| )) | ||
| } |
There was a problem hiding this comment.
Fixed in 8fc6485: env resolution now checks command-level user_args first, rejects explicit empty --env, then falls back to middleware.env. See src/auth/commands.rs:122.
| json!({"provider": "primary", "env": "dev", "status": "logged out"}) | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
Fixed in 8fc6485: added JSON error-path coverage for missing env and explicit empty env, plus logout explicit override coverage. See tests/foundation.rs:2414, tests/foundation.rs:2430, and tests/foundation.rs:2462.
jpage-godaddy
left a comment
There was a problem hiding this comment.
Thanks! This was bothering me too.
Summary