Diff

spec/util_pubsub_spec.lua @ 13549:3b357ab6b6eb

util.pubsub: Add method returning subset of config as metadata Allows granting read only access to other sets of users using a separate access control capability, which makes sense as some properties may be intended to be public but read-only.
author Kim Alvefur <zash@zash.se>
date Fri, 08 Nov 2024 02:11:00 +0100
parent 13536:272ea65c3087
line wrap: on
line diff
--- a/spec/util_pubsub_spec.lua	Fri Nov 08 10:31:25 2024 +0000
+++ b/spec/util_pubsub_spec.lua	Fri Nov 08 02:11:00 2024 +0100
@@ -605,4 +605,14 @@
 		end);
 
 	end)
+
+	describe("metadata", function()
+		it("works", function()
+			local service = pubsub.new { metadata_subset = { "title" } };
+			assert.truthy(service:create("node", true, { title = "Hello", secret = "hidden" }))
+			local ok, meta = service:get_node_metadata("node", "nobody");
+			assert.truthy(ok, meta);
+			assert.same({ title = "Hello" }, meta);
+		end)
+	end);
 end);