mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
test(cli): keep the raw refusal exit test independent of BUZZ_* env (#9733)
## Summary
Follow-up to #9653. Its new test
`cli_exits_nonzero_when_the_relay_refuses_a_raw_publish` went through
`run_from_args`, which resolves credentials from the caller's
environment. With `BUZZ_AUTH_TAG` set (as it is for agents run by the
ACP harness), the test client's key doesn't match the auth tag and the
test exits 3 instead of 2.
The check moves to an integration test,
[`tests/raw_publish_exit.rs`](c77555c348/crates/buzz-cli/tests/raw_publish_exit.rs),
that runs the built `buzz` binary against a fake relay answering
`accepted:false`, with every `BUZZ_*` variable removed from the child
only. It asserts exit 2, empty stdout, a `relay_error` and one
submission, so it covers the binary's real route and exit mapping.
## Regressions
None: test-only change.
### Validation
Ran the `buzz-cli` suite with a junk `BUZZ_AUTH_TAG` and
`BUZZ_FEDERATED_IDENTITY_TOKEN` set. Replacing the `Cmd::Raw` dispatch
with `Ok(())` makes the new test fail.
---------
Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
@@ -622,26 +622,4 @@ mod tests {
|
||||
assert!(out.is_empty(), "a refusal prints nothing to stdout");
|
||||
assert_eq!(crate::error::exit_code(&err), 2);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cli_exits_nonzero_when_the_relay_refuses_a_raw_publish() {
|
||||
let (url, captured) = fake_relay_acking("[]", false).await;
|
||||
let key = Keys::generate().secret_key().to_secret_hex();
|
||||
let code = crate::run_from_args([
|
||||
"buzz",
|
||||
"--relay",
|
||||
url.as_str(),
|
||||
"--private-key",
|
||||
key.as_str(),
|
||||
"raw",
|
||||
"publish",
|
||||
"--kind",
|
||||
"7",
|
||||
"--content",
|
||||
"+",
|
||||
])
|
||||
.await;
|
||||
assert_eq!(code, 2, "a refused publish is a relay error");
|
||||
assert_eq!(captured.events.lock().unwrap().len(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user