Watch
0
0
Fork
You've already forked hyperhive
0

swarm-nats-auth: let the controller list the bash task statuses

This commit is contained in:
damocles 2026-11-16 01:18:22 +01:00 • committed by mara
commit 802151820c

View file

@ -844,6 +844,14 @@ impl Policy {
"$JS.API.CONSUMER.CREATE.{}",
swarm_wire::agent_permissions::STREAM
));
// The bash task statuses, listed the same way: the task list calls
// `keys()` for an agent's tasks. Without this subject the create
// request is refused and reaches the client as a timeout, so the list
// timed out every time.
subjects.push(format!(
"$JS.API.CONSUMER.CREATE.{}",
swarm_wire::bash_task::STREAM
));
subjects
}
}
@ -917,6 +925,18 @@ mod tests {
);
}
#[test]
fn the_reader_can_list_the_bash_task_statuses_and_no_other_stream() {
let subjects = policy().reader_subjects();
let s = swarm_wire::bash_task::STREAM;
// The bare form is what `keys()` needs: its ephemeral consumer has
// no name.
assert!(subjects.contains(&format!("$JS.API.CONSUMER.CREATE.{s}")));
assert!(!subjects.contains(&format!("$JS.API.CONSUMER.CREATE.{s}.>")));
assert!(!subjects.contains(&"$JS.API.CONSUMER.CREATE.*".to_owned()));
assert_eq!(s, format!("KV_{}", swarm_wire::bash_task::BUCKET));
}
#[test]
fn no_hive_may_write_another_role_s_agent_status() {
// A hive publishes its *own* agents' status under