Skip to content

Commit 1701131

Browse files
committed
test(stack-encrypt): a target query of a null needs a sealed field and equality
The three survivors of cargo mutants on the null term: record::query's refusal of a null was reached by no test, since query_term refuses the same input before it. Claude-Session: https://claude.ai/code/session_01XQN1QpaWVDGjHEg39KEJF3
1 parent 19f5f3e commit 1701131

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎packages/stack-encrypt/src/dynamic/record.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6653,6 +6653,42 @@ mod tests {
66536653
assert_eq!(generates(&cipher), 0, "nothing minted");
66546654
}
66556655

6656+
/// A null is queried by its equality term, which only a field that
6657+
/// seals its nulls stores (#1298): through such a field's equality
6658+
/// index the null reaches the resolver; through any other index, or
6659+
/// a `"sql"` field, it is refused before. (The fake resolver reads
6660+
/// text, so it refuses the null it is handed with an error of its
6661+
/// own: what matters is that the lowering let it through.)
6662+
#[tokio::test]
6663+
async fn a_target_query_of_a_null_needs_a_sealed_field_and_equality() {
6664+
let cipher = cipher().await;
6665+
let keyset = cipher.default_keyset();
6666+
let with_null = |target: &str, null: &str| {
6667+
let mut spec = target_spec(label("f"), target);
6668+
if let Tree::Object(entries) = &mut spec {
6669+
entries.push(("null".to_string(), s(null)));
6670+
}
6671+
obj(vec![("f", spec)])
6672+
};
6673+
let sealed = plan_with(with_null("IntegerEq", "sealed"), &FakeEql).expect("parses");
6674+
let sql = plan_with(with_null(TEXT_EQ, "sql"), &FakeEql).expect("parses");
6675+
let null_query = |plan: &Plan, index: IndexSpec| {
6676+
query(&keyset, plan, "f", &index, &Tree::Null, &FakeEql).err()
6677+
};
6678+
let refused = |error: &Option<Error>| matches!(error, Some(Error::Source { field: Some(f), reason: Reason::NullQuery }) if f == "f");
6679+
let through = null_query(&sealed, IndexSpec::Equality);
6680+
assert!(
6681+
!refused(&through),
6682+
"a sealed field's equality takes a null: {through:?}"
6683+
);
6684+
for (what, error) in [
6685+
("another index", null_query(&sealed, IndexSpec::Ore)),
6686+
("a sql field", null_query(&sql, IndexSpec::Equality)),
6687+
] {
6688+
assert!(refused(&error), "{what}: {error:?}");
6689+
}
6690+
}
6691+
66566692
/// A target field stores a null as its plan says (#1298): under
66576693
/// `"sql"` in any type; sealed only in a type of fixed width whose
66586694
/// terms are equality's alone, since a null has an equality term and

0 commit comments

Comments
 (0)