fix(fermata): empty masked text becomes [fermata]; a Monitor without a command is left alone; tests for the CRLF and JSON-escaped spellings
This commit is contained in:
@@ -230,3 +230,38 @@ fn an_unclosed_quote_leaves_the_next_key_alone() {
|
||||
let shown = read(&p, "nextfakevalue lastfakevalue");
|
||||
assert_eq!(shown, "***** *****");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Two spellings no other test needs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Short lines, so that no line is masked alone and only the whole value can match.
|
||||
const SHORT_A: &str = "fakeab1";
|
||||
const SHORT_B: &str = "fakecd2";
|
||||
|
||||
#[test]
|
||||
fn a_value_read_from_a_file_with_windows_line_ends() {
|
||||
let env = format!("API_TOKEN=\"{SHORT_A}\n{SHORT_B}\"\n");
|
||||
let p = project(&[(".env", &env)]);
|
||||
let shown = read(&p, &format!("{SHORT_A}\r\n{SHORT_B}\r\n"));
|
||||
assert!(!shown.contains(SHORT_A) && !shown.contains(SHORT_B), "{shown}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_value_with_a_quote_inside_a_json_string_of_a_tool_result() {
|
||||
let p = project(&[(".env", "API_TOKEN='a\"b-fakevalue123'\n")]);
|
||||
let text = json!({"k": "a\"b-fakevalue123"}).to_string();
|
||||
let payload = json!({"tool_name": "mcp__srv__t", "tool_input": {}, "tool_response": {"content": [{"type": "text", "text": text}]}});
|
||||
let output = Command::cargo_bin("fermata")
|
||||
.unwrap()
|
||||
.args(["hook", "--event", "post-tool-use", "--harness", "claude"])
|
||||
.current_dir(p.0.path())
|
||||
.env("HOME", p.1.path())
|
||||
.write_stdin(payload.to_string())
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.clone();
|
||||
let out = String::from_utf8(output.stdout).unwrap();
|
||||
assert!(out.contains("updatedToolOutput") && !out.contains("fakevalue123"), "{out}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user