diff options
Diffstat (limited to 'src/simtest/policy.rs')
| -rw-r--r-- | src/simtest/policy.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/simtest/policy.rs b/src/simtest/policy.rs index 8f89b39..d451497 100644 --- a/src/simtest/policy.rs +++ b/src/simtest/policy.rs @@ -854,8 +854,9 @@ async fn a_refusal_naming_the_root() { } /// A write the API would let through but every node's rules refuse (here: past the -/// API, to a path its user may not write): judged before it leaves, refused, rolled -/// back; what the node writes next goes everywhere. +/// API, to a path its user may not write; and before, where no policy judges, a strict +/// policy): judged before it leaves, refused, rolled back; what the node writes next +/// goes everywhere. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn a_write_every_node_would_refuse() { let sim = Sim::with_identity(79); @@ -870,6 +871,25 @@ async fn a_write_every_node_would_refuse() { &[(path("notes"), &[crate::access::Right::Write][..])], ); write_as(&a, "alice", "_continuum/users/bob", bob).await; + // Where no policy judges, a strict one written, which every node refuses: a swarm + // turns strict only at its start or through a strict remake. + let heads = a.doc.read().await.doc.get_heads(); + let policy = path("_continuum/access/policy"); + let strict = a + .mutate_doc_for( + Some("alice".to_owned()), + Sign::Write { + path: policy.clone(), + asked: false, + }, + move |doc| store::write_path(doc, &policy, &json!({"version": 1, "values": "signed"})), + ) + .await; + assert!( + matches!(strict, Err(store::StoreError::Refused(_))), + "a strict policy written where none judges" + ); + assert_eq!(a.doc.read().await.doc.get_heads(), heads, "rolled back"); write_as( &a, "alice", |
