mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Made the roles the only lists of topics, Refused PRAGMAs in queries
- Removed `[server] topics` and `[replication] replicated_topics`: a push is taken by its roles' `push_topics`, a replicated message by the peer's `accept_topics`; a topic exists from its first message. - Topics that only came from a peer are read and listed like any other; `ListNames` lists the topics with messages, filtered by the roles. - A push to a topic no role names is `NotAllowed`; `UnknownName` is only for nodes. - Clients' queries: every PRAGMA refused as it's prepared (SQLite's authorizer), `PRAGMA query_only = 0` used to take effect. - Noted the leads found by reading the code in `docs/known-issues.md`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,6 @@ ca = "ca.crt"
|
||||
certificate = "server.crt"
|
||||
key = "server.key"
|
||||
crl = "ca.crl"
|
||||
topics = ["logs", "sensors"]
|
||||
|
||||
[roles.sensor]
|
||||
push_topics = ["logs", "sensors"]
|
||||
@@ -237,9 +236,10 @@ fn refusals_keep_the_connection() {
|
||||
refused(reader.push("logs", "{}")),
|
||||
ErrorCode::NotAllowed.code()
|
||||
);
|
||||
// A topic is its roles': one that none of them names.
|
||||
assert_eq!(
|
||||
refused(sensor.push("nope", "{}")),
|
||||
ErrorCode::UnknownName.code()
|
||||
ErrorCode::NotAllowed.code()
|
||||
);
|
||||
// The client checks names before sending.
|
||||
assert_eq!(
|
||||
@@ -487,9 +487,13 @@ fn runs_of_messages() {
|
||||
refused(screen.get_messages("sensors", "kitchen", None, 1)),
|
||||
ErrorCode::NotAllowed.code()
|
||||
);
|
||||
assert_eq!(
|
||||
refused(kitchen.get_messages("nothing", "kitchen", None, 1)),
|
||||
ErrorCode::UnknownName.code()
|
||||
// A topic without messages: none, for a node that has some elsewhere.
|
||||
assert!(
|
||||
kitchen
|
||||
.get_messages("nothing", "kitchen", None, 1)
|
||||
.unwrap()
|
||||
.messages
|
||||
.is_empty()
|
||||
);
|
||||
assert_eq!(
|
||||
refused(kitchen.get_messages("logs", "nobody", None, 1)),
|
||||
@@ -746,7 +750,7 @@ fn attachments() {
|
||||
let error = kitchen
|
||||
.get_attachment("nothing", "kitchen", 1, &mut Vec::new())
|
||||
.unwrap_err();
|
||||
assert_eq!(error.code(), ErrorCode::UnknownName.code(), "{error}");
|
||||
assert_eq!(error.code(), ErrorCode::NotFound.code(), "{error}");
|
||||
let mut logs_only = running
|
||||
.connect(&running.issue("lounge", &["logs"]))
|
||||
.unwrap();
|
||||
@@ -1511,6 +1515,42 @@ fn replication_edges() {
|
||||
raw.refused(ErrorCode::DataMismatch);
|
||||
assert_eq!(sync_state(&mut raw).missing[0].next_part, 0);
|
||||
|
||||
// A topic nobody pushed here: it's there from its first replicated
|
||||
// message, read and listed by the roles that name it.
|
||||
raw.send(ReplicateMessages {
|
||||
topic: "elsewhere".into(),
|
||||
node: "far".into(),
|
||||
messages: vec![message(1, now, None)],
|
||||
});
|
||||
assert_eq!(raw.receive(), Some(MessagePushed { message_id: 1 }.into()));
|
||||
let mut reader = running
|
||||
.connect(&running.issue("screen", &["reader"]))
|
||||
.unwrap();
|
||||
let got = reader
|
||||
.get_messages("elsewhere", "far", Some(0), 10)
|
||||
.unwrap();
|
||||
assert_eq!(got.messages[0].data, "m1");
|
||||
// (`old` had a message, past its age.)
|
||||
assert_eq!(
|
||||
reader.list_names(NameKind::Topic).unwrap().names,
|
||||
["elsewhere", "logs", "old"]
|
||||
);
|
||||
let mut logs_only = running
|
||||
.connect(&running.issue("lounge", &["logs"]))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
logs_only.list_names(NameKind::Topic).unwrap().names,
|
||||
["logs"]
|
||||
);
|
||||
assert_eq!(
|
||||
code(
|
||||
logs_only
|
||||
.get_messages("elsewhere", "far", Some(0), 10)
|
||||
.unwrap_err()
|
||||
),
|
||||
ErrorCode::NotAllowed.code()
|
||||
);
|
||||
|
||||
// A certificate whose roles take nothing: refused.
|
||||
let mut other = Raw::connect(&running, &running.issue("nosy", &["reader"]));
|
||||
let state = sync_state(&mut other);
|
||||
|
||||
Reference in New Issue
Block a user