Skip to content

test(alias): cover missing RC_HOST credentials#197

Open
overtrue wants to merge 1 commit into
mainfrom
test/rc-host-missing-credentials
Open

test(alias): cover missing RC_HOST credentials#197
overtrue wants to merge 1 commit into
mainfrom
test/rc-host-missing-credentials

Conversation

@overtrue
Copy link
Copy Markdown
Contributor

Related issue(s)

None.

Background

Recent alias validation work changed malformed RC_HOST_* values to surface as usage errors with structured JSON metadata. Existing coverage exercises invalid percent encoding and invalid schemes, but the missing-secret-key credential shape was still only covered indirectly at the core parser level.

Root cause

RC_HOST_badalias=https://ACCESS_KEY@rustfs.local:9000 reaches the alias list command through the environment alias loader. Before the recent alias command error handling changes, this command path could report the parser failure through generic JSON error inference instead of the explicit usage-error exit code metadata.

Solution

Add a focused subprocess regression in crates/cli/tests/env_alias.rs for a missing RC_HOST_* secret key. The test verifies that rc alias list --json exits with code 2, emits JSON on stderr, classifies the error as usage_error, and does not leak the provided access key.

Validation

  • cargo test -p rustfs-cli --test env_alias alias_list_rejects_rc_host_missing_secret_key_as_usage_error
  • make pre-commit

@overtrue overtrue marked this pull request as ready for review May 12, 2026 13:17
Copilot AI review requested due to automatic review settings May 12, 2026 13:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a focused regression test to ensure malformed RC_HOST_* values that are missing a secret key are surfaced as structured usage errors in --json mode, and that provided credentials are not leaked in error output. This strengthens CLI alias validation coverage specifically along the environment-alias loader → rc alias list --json path.

Changes:

  • Add an integration test covering RC_HOST_badalias=https://ACCESS_KEY@rustfs.local:9000 (missing secret key) for rc alias list --json.
  • Assert exit code 2, JSON error emitted on stderr, usage_error classification, and absence of the access key value in output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants