test(alias): cover missing RC_HOST credentials#197
Open
overtrue wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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) forrc alias list --json. - Assert exit code
2, JSON error emitted onstderr,usage_errorclassification, and absence of the access key value in output.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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:9000reaches 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.rsfor a missingRC_HOST_*secret key. The test verifies thatrc alias list --jsonexits with code 2, emits JSON on stderr, classifies the error asusage_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_errormake pre-commit